ansible-role-cloud-launcher/tasks/generate_keypair.yml
Ricardo Carrillo Cruz 0f933d768a Fix creation of servers with on-the-fly keypairs
On 301ae3faee refactor, I overlooked
the creation of servers with the generate_keypair flag enabled.
This change adds it back.

Change-Id: I891eba482db38e0b4f97222e37c9bd2e214571d1
2016-07-19 17:24:18 +00:00

19 lines
995 B
YAML

---
- block:
- name: Generate keypair name
set_fact: cl_generated_keypair_name=launch-{{ lookup('pipe', "date +'%s'") }}
- name: Generate SSH keys
shell: ssh-keygen -t "{{ generate_keypair_key_type }}" -b "{{ generate_keypair_key_bits }}" -N '' -f "{{ generate_keypair_folder }}"/"{{ cl_generated_keypair_name }}"
- name: Store public key filename path
set_fact: cl_generated_keypair_public_key_filename={{ generate_keypair_folder}}/{{ cl_generated_keypair_name }}.pub
- name: Store private key filename path
set_fact: cl_generated_keypair_private_key_filename={{ generate_keypair_folder}}/{{ cl_generated_keypair_name }}
- name: Create OpenStack keypair {{ cl_generated_keypair_name }}
os_keypair:
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
state: present
name: "{{ cl_generated_keypair_name }}"
public_key_file: "{{ cl_generated_keypair_public_key_filename }}"
when: generate_keypair|bool