Create and attach other required openstack resources

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
This commit is contained in:
Ricardo Carrillo Cruz 2016-02-12 13:54:15 +01:00
parent ab9554c77f
commit 50ccb8c835
5 changed files with 19 additions and 10 deletions

View File

@ -1,6 +0,0 @@
---
# file: provision_infra_servers.yml
- hosts: localhost
connection: local
roles:
- { role: provision_infra_servers }

View File

@ -1,5 +1,14 @@
---
- name: Create OpenStack instances
- 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) }}"
@ -17,7 +26,7 @@
infra_type: "{{ item.infra_type }}"
with_items: infra_servers
- name: Create OpenStack volumes
- name: Create volumes
os_volume:
state: present
cloud: "{{item.os_client_config_cloud | default(os_client_config_cloud) }}"
@ -28,7 +37,7 @@
- volumes
- { skip_missing: yes }
- name: Attach OpenStack volumes
- name: Attach volumes
os_server_volume:
state: present
cloud: "{{item.os_client_config_cloud | default(os_client_config_cloud) }}"

2
run.sh
View File

@ -1,3 +1,3 @@
#!/bin/bash
ansible-playbook -i hosts provision_infra_servers.yml -e "@infra_config.yml"
ansible-playbook -i hosts setup_openstack_resources.yml -e "@infra_config.yml"
ansible-playbook -i inventory/openstack.py site.yml -e "@infra_config.yml"

View File

@ -0,0 +1,6 @@
---
# file: setup_openstack_resources.yml
- hosts: localhost
connection: local
roles:
- { role: setup_openstack_resources }