blob: e0046b24d121acb46dde5105bd82e5e24e124505 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
|