-
Notifications
You must be signed in to change notification settings - Fork 7
/
openstack.yml
53 lines (48 loc) · 1.42 KB
/
openstack.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# vim: set ft=ansible
- name: Deploy on OpenStack
hosts: localhost
tags:
- always
gather_facts: false
vars_files:
- ~/.ansible/vars/toad_vars.yml
tasks:
- name: Deploy an instance
os_server:
name: "{{ cloud_name_prefix }}-{{ item.name }}"
state: present
cloud: "{{ cloud_name }}"
region_name: "{{ cloud_region_name }}"
availability_zone: "{{ cloud_availability_zone }}"
image: "{{ cloud_image }}"
flavor: "{{ cloud_flavor }}"
key_name: "{{ cloud_key_name }}"
boot_from_volume: true
terminate_volume: true
volume_size: 20
security_groups: "{{ item.security_groups }}"
auto_ip: yes
timeout: 200
register: instances
with_items: "{{ instance_list }}"
- debug:
var: instances
verbosity: 1
- name: Validate the host is available
command: >
ssh -o BatchMode=yes -o StrictHostKeyChecking=no
centos@{{ item.server.public_v4 }}
register: result
until: result|success
retries: 300
delay: 5
with_items: "{{ instances.results }}"
changed_when: false
- name: Add host to inventory
add_host:
name: "{{ item.item.name }}"
groups: "{{ item.item.name }}"
ansible_host: "{{ item.server.public_v4 }}"
ansible_user: centos
ansible_become: true
with_items: "{{ instances.results }}"