diff options
| author | Carlos Konstanski <ckonstanski@pippiandcarlos.com> | 2017-11-13 16:50:55 -0700 |
|---|---|---|
| committer | Carlos Konstanski <ckonstanski@pippiandcarlos.com> | 2017-11-13 16:50:55 -0700 |
| commit | ffa2a169ea98fb54a29d90ca158059e79e2816ba (patch) | |
| tree | 018461d031b71178fa48b9672d8e39bac4de1270 /playbooks/ssh_keys.yaml | |
initial commit
Diffstat (limited to 'playbooks/ssh_keys.yaml')
| -rw-r--r-- | playbooks/ssh_keys.yaml | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/playbooks/ssh_keys.yaml b/playbooks/ssh_keys.yaml new file mode 100644 index 0000000..e0046b2 --- /dev/null +++ b/playbooks/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 |
