diff options
Diffstat (limited to 'deployment/noheat/infra-openstack/ansible/roles/create_keypair')
-rw-r--r-- | deployment/noheat/infra-openstack/ansible/roles/create_keypair/tasks/main.yml | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/deployment/noheat/infra-openstack/ansible/roles/create_keypair/tasks/main.yml b/deployment/noheat/infra-openstack/ansible/roles/create_keypair/tasks/main.yml new file mode 100644 index 000000000..a330875d8 --- /dev/null +++ b/deployment/noheat/infra-openstack/ansible/roles/create_keypair/tasks/main.yml @@ -0,0 +1,25 @@ +- name: Create keypair + os_keypair: + state: present + name: "{{ keypair.name }}" + register: keypair + +- name: Create local public key + local_action: + module: copy + content: "{{ keypair.key.public_key }}" + dest: "~/.ssh/{{ keypair.key.name }}.pub" + mode: 0600 + +- name: Check if local private key exists + stat: + path: "~/.ssh/{{ keypair.key.name }}" + register: local_private_key + +- name: Create local private key + local_action: + module: copy + content: "{{ keypair.key.private_key }}" + dest: "~/.ssh/{{ keypair.key.name }}" + mode: 0600 + when: local_private_key.stat.exists == False |