From 649f0dd9c5ca586d8b637400dd19c0c4059447d6 Mon Sep 17 00:00:00 2001 From: Carlos Konstanski Date: Wed, 30 Aug 2017 13:09:56 -0600 Subject: initial commit --- salt/openbook/ansible/files/ssh_keys.yaml | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 salt/openbook/ansible/files/ssh_keys.yaml (limited to 'salt/openbook/ansible/files/ssh_keys.yaml') diff --git a/salt/openbook/ansible/files/ssh_keys.yaml b/salt/openbook/ansible/files/ssh_keys.yaml new file mode 100644 index 0000000..e0046b2 --- /dev/null +++ b/salt/openbook/ansible/files/ssh_keys.yaml @@ -0,0 +1,39 @@ +--- +- name: "Generate SSH keypair" + hosts: all + vars: + ssh_privkey_path: /root/.ssh/id_rsa + tasks: + - name: "Detect existing SSH privkey" + stat: + path: "{{ ssh_privkey_path }}" + register: ssh_privkey + + - name: "Detect existing SSH pubkey" + stat: + path: "{{ ssh_privkey_path }}.pub" + register: ssh_pubkey + + - name: "Generate SSH keypair" + shell: ssh-keygen -q -t rsa -b 4096 -f "{{ ssh_privkey_path }}" -N '' + when: ssh_privkey.stat.exists == False or ssh_pubkey.stat.exists == False + +- name: "Generate SSH keypair" + hosts: all + become_user: jenkins + vars: + ssh_privkey_path: /var/lib/jenkins/.ssh/id_rsa + tasks: + - name: "Detect existing SSH privkey" + stat: + path: "{{ ssh_privkey_path }}" + register: ssh_privkey + + - name: "Detect existing SSH pubkey" + stat: + path: "{{ ssh_privkey_path }}.pub" + register: ssh_pubkey + + - name: "Generate SSH keypair" + shell: ssh-keygen -q -t rsa -b 4096 -f "{{ ssh_privkey_path }}" -N '' + when: ssh_privkey.stat.exists == False or ssh_pubkey.stat.exists == False -- cgit v1.3