examples/nginx_openstack/library/openstack/vm/playbooks/create.yaml
---
- hosts: all
gather_facts: no
tasks:
- name: Create VM
os_server:
state: present
name: "{{ vm_name }}"
image: "{{ image }}"
key_name: "{{ key_name }}"
flavor: "{{ flavor }}"
network: "{{ network }}"
security_groups: "{{ security_groups }}"
register: server_info
- name: Set attributes
set_stats:
data:
private_address: "{{ server_info.server.private_v4 }}"
public_address: "{{ server_info.server.public_v4 }}"
id: "{{ server_info.server.id }}"
- name: Create temporary invetory for ssh wait
add_host:
name: server
groups: vms
ansible_host: "{{ server_info.server.public_v4 }}"
ansible_user: centos
ansible_ssh_common_args: >
-o IdentitiesOnly=yes
-o BatchMode=yes
-o UserKnownHostsFile=/dev/null
-o StrictHostKeyChecking=no
- hosts: vms
gather_facts: no
tasks:
- name: Wait for ssh to wake up
wait_for_connection: