blob: 8a7c7209282ffd87bb0a127d954bd0cd0fee64c2 (
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
|
- name: Create keypair
os_keypair:
state: present
name: "{{ keypair.name }}"
register: keypair
- name: Create local public key
copy:
content: "{{ keypair.key.public_key }}"
dest: "~/.ssh/{{ keypair.key.name }}.pub"
mode: 0600
delegate_to: localhost
- name: Check if local private key exists
stat:
path: "~/.ssh/{{ keypair.key.name }}"
register: local_private_key
- name: Create local private key
copy:
content: "{{ keypair.key.private_key }}"
dest: "~/.ssh/{{ keypair.key.name }}"
mode: 0600
delegate_to: localhost
when: not local_private_key.stat.exists
|