forked from OpenStackCookbook/vagrant-openstack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
multi-orchestrate-instances.yml
49 lines (43 loc) · 1.3 KB
/
multi-orchestrate-instances.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
- name: Launch instance on OpenStack
hosts: localhost
gather_facts: false
vars:
count: 2
tasks:
- name: Deploy an instance
os_server:
state: present
name: cookbook{{ item }}
image: xenial-image
key_name: demokey
timeout: 200
flavor: m1.tiny
network: private-net
verify: false
register: nova_cookbook
with_sequence:
count={{ count }}
# - debug: var=nova_cookbook
- name: Add instance to Inventory
add_host: name="{{ item.server.name }}" groups=webservers
ansible_ssh_host="{{ item.server.accessIPv4 }}"
with_items: "{{ nova_cookbook.results }}"
- name: Wait for port 22 to be ready
hosts: webservers
gather_facts: False
tasks:
- local_action: wait_for port=22 host="{{ ansible_ssh_host }}" search_regex=OpenSSH delay=10
- hosts: webservers
remote_user: ubuntu
become: yes
gather_facts: no
pre_tasks:
- name: Set APT proxy
raw: echo "Acquire::http::Proxy \"http://192.168.1.20:3128\";" > /etc/apt/apt.conf
- name: 'install python2'
raw: sudo apt-get -y install python-simplejson
tasks:
- name: Ensure Apache is installed
apt: name=apache2 state=latest
- name: Ensure that Apache is started
service: name=apache2 state=started