-
Notifications
You must be signed in to change notification settings - Fork 32
/
orchestrate-instance.yml
68 lines (64 loc) · 1.97 KB
/
orchestrate-instance.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
- name: Launch instance on OpenStack
hosts: localhost
gather_facts: false
tasks:
- name: Create ansible security group
os_security_group:
state: present
name: ansible
verify: false
- name: Create a new security group rule to allow http connectinos
os_security_group_rule:
security_group: ansible
protocol: tcp
port_range_min: 22
port_range_max: 22
remote_ip_prefix: 0.0.0.0/0
verify: false
- name: Create webserver security group
os_security_group:
state: present
name: webserver
verify: false
- name: Create a new security group rule to allow http connectinos
os_security_group_rule:
security_group: webserver
protocol: tcp
port_range_min: 80
port_range_max: 80
remote_ip_prefix: 0.0.0.0/0
verify: false
- name: Deploy an instance
os_server:
state: present
name: cookbook1
image: xenial-image
key_name: demokey
timeout: 200
flavor: m1.tiny
network: private-net
security_groups: default,ansible,webserver
verify: false
register: nova_cookbook
- name: Add instance to Inventory
add_host: name=cookbook1 groups=webservers
ansible_ssh_host={{ nova_cookbook.server.accessIPv4 }}
- 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