
Rather than expecting a user to create keypair prior to run infra-ansible, just make infra-ansible to create the keypair per the variable passed as keypair_contents on infra_config.yml. Role provision_infra_servers not only creates instances, but also volumes and now kepairs, thus also renaming the provision_infra_servers role and playbook to setup_openstack_resources. Change-Id: I810edf1b8956d2f5653aa789ce908428c2904549
50 lines
1.3 KiB
YAML
50 lines
1.3 KiB
YAML
---
|
|
- name: Create keypairs
|
|
os_keypair:
|
|
state: present
|
|
cloud: "{{item.os_client_config_cloud | default(os_client_config_cloud) }}"
|
|
name: "{{ item.name }}"
|
|
public_key: "{{ item.contents }}"
|
|
validate_certs: no
|
|
with_items: keypairs
|
|
|
|
- name: Create instances
|
|
os_server:
|
|
state: present
|
|
cloud: "{{item.os_client_config_cloud | default(os_client_config_cloud) }}"
|
|
name: "{{ item.name }}.{{ domainname }}"
|
|
image: "{{ item.image }}"
|
|
key_name: "{{ key_name }}"
|
|
timeout: 200
|
|
flavor: "{{ item.flavor }}"
|
|
nics:
|
|
- net-name: "{{ item.net_name }}"
|
|
security_groups: "{{ item.security_groups }}"
|
|
auto_floating_ip: yes
|
|
meta:
|
|
group: infra
|
|
infra_type: "{{ item.infra_type }}"
|
|
with_items: infra_servers
|
|
|
|
- name: Create volumes
|
|
os_volume:
|
|
state: present
|
|
cloud: "{{item.os_client_config_cloud | default(os_client_config_cloud) }}"
|
|
display_name: "{{ item.1.name }}"
|
|
size: "{{ item.1.size }}"
|
|
with_subelements:
|
|
- infra_servers
|
|
- volumes
|
|
- { skip_missing: yes }
|
|
|
|
- name: Attach volumes
|
|
os_server_volume:
|
|
state: present
|
|
cloud: "{{item.os_client_config_cloud | default(os_client_config_cloud) }}"
|
|
server: "{{ item.0.name }}.{{ domainname }}"
|
|
volume: "{{ item.1.name }}"
|
|
with_subelements:
|
|
- infra_servers
|
|
- volumes
|
|
- { skip_missing: yes }
|