summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTong Li <litong01@us.ibm.com>2017-03-22 13:31:01 -0400
committertian shi <tian.shi@ecloud.com.cn>2017-04-11 11:09:17 +0000
commita58bab3adfb153f638f4ebdf05a92586b19c7cb2 (patch)
treebc261a66a96a5b10512aa6041966eb7567b02513
parent791fbe78d1722ebb4dd8aac3d066fe6869b05df5 (diff)
Rework the lampstack workload to enable provision parallel
Notes
Notes (review): Code-Review+2: litong01 <email4tong@yahoo.com> Workflow+1: litong01 <email4tong@yahoo.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 11 Apr 2017 12:06:24 +0000 Reviewed-on: https://review.openstack.org/448677 Project: openstack/interop-workloads Branch: refs/heads/master
-rwxr-xr-xworkloads/ansible/shade/lampstack/.gitignore1
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/apply/tasks/main.yml193
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml12
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/cleaner/tasks/apply.yml21
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml11
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml13
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/database/tasks/main.yml8
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/destroy/tasks/main.yml79
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/postprovision/tasks/apply.yml44
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/postprovision/tasks/destroy.yml30
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/prepare/tasks/apply.yml100
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/prepare/tasks/destroy.yml25
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/provision/tasks/apply.yml49
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/provision/tasks/destroy.yml14
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/provision/templates/userdata.j2 (renamed from workloads/ansible/shade/lampstack/roles/apply/templates/userdata.j2)0
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/webserver/tasks/main.yml23
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml13
-rwxr-xr-xworkloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml30
-rwxr-xr-xworkloads/ansible/shade/lampstack/site.yml49
-rwxr-xr-xworkloads/ansible/shade/lampstack/vars/bluebox.yml14
-rwxr-xr-xworkloads/ansible/shade/lampstack/vars/leap.yml7
21 files changed, 359 insertions, 377 deletions
diff --git a/workloads/ansible/shade/lampstack/.gitignore b/workloads/ansible/shade/lampstack/.gitignore
index 5ab4be3..0a5769c 100755
--- a/workloads/ansible/shade/lampstack/.gitignore
+++ b/workloads/ansible/shade/lampstack/.gitignore
@@ -1,5 +1,6 @@
1*.out 1*.out
2vars/* 2vars/*
3run/*
3*/**/*.log 4*/**/*.log
4*/**/.DS_Store 5*/**/.DS_Store
5*/**/._ 6*/**/._
diff --git a/workloads/ansible/shade/lampstack/roles/apply/tasks/main.yml b/workloads/ansible/shade/lampstack/roles/apply/tasks/main.yml
deleted file mode 100755
index b980652..0000000
--- a/workloads/ansible/shade/lampstack/roles/apply/tasks/main.yml
+++ /dev/null
@@ -1,193 +0,0 @@
1---
2- name: Get start timestamp
3 set_fact: starttime="{{ ansible_date_time }}"
4
5- name: Retrieve specified flavor
6 os_flavor_facts:
7 auth: "{{ auth }}"
8 region_name: "{{ app_env.region_name }}"
9 availability_zone: "{{ app_env.availability_zone }}"
10 validate_certs: "{{ app_env.validate_certs }}"
11 name: "{{ app_env.flavor_name }}"
12
13- name: Create a key-pair
14 os_keypair:
15 state: "present"
16 auth: "{{ auth }}"
17 region_name: "{{ app_env.region_name }}"
18 availability_zone: "{{ app_env.availability_zone }}"
19 validate_certs: "{{ app_env.validate_certs }}"
20 name: "lampstack"
21 public_key_file: "{{ app_env.public_key_file }}"
22
23- name: Create volume
24 os_volume:
25 state: present
26 auth: "{{ auth }}"
27 region_name: "{{ app_env.region_name }}"
28 availability_zone: "{{ app_env.availability_zone }}"
29 validate_certs: "{{ app_env.validate_certs }}"
30 size: "{{ app_env.volume_size }}"
31 wait: yes
32 display_name: db_volume
33
34- name: Create security group
35 os_security_group:
36 state: present
37 auth: "{{ auth }}"
38 region_name: "{{ app_env.region_name }}"
39 availability_zone: "{{ app_env.availability_zone }}"
40 validate_certs: "{{ app_env.validate_certs }}"
41 name: lampstack_sg
42 description: security group for lampstack
43
44- name: Add security rules
45 os_security_group_rule:
46 state: present
47 auth: "{{ auth }}"
48 region_name: "{{ app_env.region_name }}"
49 availability_zone: "{{ app_env.availability_zone }}"
50 validate_certs: "{{ app_env.validate_certs }}"
51 security_group: lampstack_sg
52 protocol: "{{ item.protocol }}"
53 direction: "{{ item.dir }}"
54 port_range_min: "{{ item.p_min }}"
55 port_range_max: "{{ item.p_max }}"
56 remote_ip_prefix: 0.0.0.0/0
57 with_items:
58 - { p_min: 22, p_max: 22, dir: ingress, protocol: tcp }
59 - { p_min: 80, p_max: 80, dir: ingress, protocol: tcp }
60 - { p_min: 2049, p_max: 2049, dir: ingress, protocol: tcp }
61 - { p_min: 2049, p_max: 2049, dir: egress, protocol: tcp }
62 - { p_min: 3306, p_max: 3306, dir: ingress, protocol: tcp }
63 - { p_min: -1, p_max: -1, dir: ingress, protocol: icmp }
64 - { p_min: -1, p_max: -1, dir: egress, protocol: icmp }
65
66- name: Create database node
67 os_server:
68 state: "present"
69 auth: "{{ auth }}"
70 region_name: "{{ app_env.region_name }}"
71 availability_zone: "{{ app_env.availability_zone }}"
72 validate_certs: "{{ app_env.validate_certs }}"
73 name: database
74 image: "{{ app_env.image_name }}"
75 key_name: "lampstack"
76 timeout: 200
77 flavor: "{{ app_env.flavor_name }}"
78 network: "{{ app_env.private_net_name }}"
79 userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
80 config_drive: "{{ app_env.config_drive | default('no') }}"
81 security_groups: lampstack_sg
82 floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
83 meta:
84 hostname: database
85 register: database
86
87- name: Add database node to the dbservers host group
88 add_host:
89 name: "{{ database.openstack.public_v4 }}"
90 groups: dbservers
91 when: database.openstack.public_v4 != ""
92
93- name: Add database node to the dbservers host group
94 add_host:
95 name: "{{ database.openstack.private_v4 }}"
96 groups: dbservers
97 when: database.openstack.public_v4 == ""
98
99- name: Create balancer node
100 os_server:
101 state: "present"
102 auth: "{{ auth }}"
103 region_name: "{{ app_env.region_name }}"
104 availability_zone: "{{ app_env.availability_zone }}"
105 validate_certs: "{{ app_env.validate_certs }}"
106 name: balancer
107 image: "{{ app_env.image_name }}"
108 key_name: "lampstack"
109 timeout: 200
110 flavor: "{{ app_env.flavor_name }}"
111 network: "{{ app_env.private_net_name }}"
112 userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
113 config_drive: "{{ app_env.config_drive | default('no') }}"
114 security_groups: lampstack_sg
115 floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
116 meta:
117 hostname: balancer
118 register: balancer
119
120- name: Add balancer node to the balancers host group
121 add_host:
122 name: "{{ balancer.openstack.public_v4 }}"
123 groups: balancers
124 when: balancer.openstack.public_v4 != ""
125
126- name: Add balancer node to the balancers host group
127 add_host:
128 name: "{{ balancer.openstack.private_v4 }}"
129 groups: balancers
130 when: balancer.openstack.public_v4 == ""
131
132- name: Create a volume for database to save data
133 os_server_volume:
134 state: present
135 auth: "{{ auth }}"
136 region_name: "{{ app_env.region_name }}"
137 availability_zone: "{{ app_env.availability_zone }}"
138 validate_certs: "{{ app_env.validate_certs }}"
139 server: database
140 volume: db_volume
141 device: "{{ app_env.block_device_name }}"
142
143- name: Create web server nodes to host application
144 os_server:
145 state: "present"
146 auth: "{{ auth }}"
147 region_name: "{{ app_env.region_name }}"
148 availability_zone: "{{ app_env.availability_zone }}"
149 validate_certs: "{{ app_env.validate_certs }}"
150 name: apache-{{ item }}
151 image: "{{ app_env.image_name }}"
152 key_name: "lampstack"
153 timeout: 200
154 flavor: "{{ app_env.flavor_name }}"
155 network: "{{ app_env.private_net_name }}"
156 floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
157 userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
158 config_drive: "{{ app_env.config_drive | default('no') }}"
159 security_groups: lampstack_sg
160 meta:
161 hostname: apache-{{ item }}
162 with_sequence: count={{ app_env.stack_size - 2 }}
163 register: webserver
164
165- name: Add web servers to webservers host group
166 add_host:
167 name: "{{ item.openstack.public_v4 }}"
168 groups: webservers
169 when: item.openstack.public_v4 != ""
170 with_items: "{{ webserver.results }}"
171 no_log: True
172
173- name: Add web servers to webservers host group
174 add_host:
175 name: "{{ item.openstack.private_v4 }}"
176 groups: webservers
177 when: item.openstack.public_v4 == ""
178 with_items: "{{ webserver.results }}"
179 no_log: True
180
181- name: Add one web servers to wps host group
182 add_host:
183 name: "{{ webserver.results[0].openstack.public_v4 }}"
184 groups: wps
185 when: webserver.results[0].openstack.public_v4 != ""
186 no_log: True
187
188- name: Add one web servers to wps host group
189 add_host:
190 name: "{{ webserver.results[0].openstack.private_v4 }}"
191 groups: wps
192 when: webserver.results[0].openstack.public_v4 == ""
193 no_log: True
diff --git a/workloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml b/workloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml
index c3d9b6d..9808e27 100755
--- a/workloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml
+++ b/workloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml
@@ -1,4 +1,8 @@
1--- 1---
2- name: update apt cache
3 apt: update_cache=yes
4 when: ansible_os_family == "Debian"
5
2- name: Haproxy install 6- name: Haproxy install
3 package: 7 package:
4 name: haproxy 8 name: haproxy
@@ -28,11 +32,9 @@
28- name: Add web servers to the haproxy 32- name: Add web servers to the haproxy
29 lineinfile: 33 lineinfile:
30 dest: /etc/haproxy/haproxy.cfg 34 dest: /etc/haproxy/haproxy.cfg
31 line: " server ws{{ item[0].openstack[item[1]] }} {{ item[0].openstack[item[1]] }}:80 check" 35 line: " server ws{{ hostvars[item].inter_ip }} {{ hostvars[item].inter_ip }}:80 check"
32 with_nested: 36 with_flattened:
33 - "{{ hostvars.cloud.webserver.results }}" 37 - "{{ groups['webservers'] }}"
34 - ["private_v4", "public_v4"]
35 when: item[0].openstack[item[1]] != ''
36 no_log: True 38 no_log: True
37 39
38- service: name=haproxy state=restarted enabled=yes 40- service: name=haproxy state=restarted enabled=yes
diff --git a/workloads/ansible/shade/lampstack/roles/cleaner/tasks/apply.yml b/workloads/ansible/shade/lampstack/roles/cleaner/tasks/apply.yml
index 5245e08..4862053 100755
--- a/workloads/ansible/shade/lampstack/roles/cleaner/tasks/apply.yml
+++ b/workloads/ansible/shade/lampstack/roles/cleaner/tasks/apply.yml
@@ -5,19 +5,10 @@
5 availability_zone: "{{ app_env.availability_zone }}" 5 availability_zone: "{{ app_env.availability_zone }}"
6 validate_certs: "{{ app_env.validate_certs }}" 6 validate_certs: "{{ app_env.validate_certs }}"
7 state: absent 7 state: absent
8 floating_ip_address: "{{ database.openstack.public_v4 }}" 8 floating_ip_address: "{{ item }}"
9 server: "{{ database.openstack.name }}" 9 purge: True
10 when: database.openstack.private_v4 != "" 10 server: "{{ hostvars[item].inter_name }}"
11 with_flattened:
12 - "{{ groups['webservers'] }}"
13 - "{{ groups['dbservers'] }}"
11 no_log: True 14 no_log: True
12
13- os_floating_ip:
14 auth: "{{ auth }}"
15 region_name: "{{ app_env.region_name }}"
16 availability_zone: "{{ app_env.availability_zone }}"
17 validate_certs: "{{ app_env.validate_certs }}"
18 state: absent
19 floating_ip_address: "{{ item.openstack.public_v4 }}"
20 server: "{{ item.openstack.name }}"
21 with_items: "{{ webserver.results }}"
22 when: item.openstack.private_v4 != ""
23 no_log: True \ No newline at end of file
diff --git a/workloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml b/workloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml
index 9a13c0a..eeea145 100755
--- a/workloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml
+++ b/workloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml
@@ -1,8 +1,4 @@
1--- 1---
2- name: Wait until server is up and runnning
3 local_action: wait_for port=22 host="{{ ansible_ssh_host | default(inventory_hostname) }}" search_regex=OpenSSH delay=10
4 become: no
5
6- name: Install python2 for Ansible 2- name: Install python2 for Ansible
7 raw: dnf install -y python2 python2-dnf libselinux-python 3 raw: dnf install -y python2 python2-dnf libselinux-python
8 register: result 4 register: result
@@ -10,3 +6,10 @@
10 6
11- name: Set SELinux to permisive 7- name: Set SELinux to permisive
12 selinux: policy=targeted state=permissive 8 selinux: policy=targeted state=permissive
9
10- name: Setup /etc/hosts on every node
11 lineinfile:
12 dest: /etc/hosts
13 line: "{{ item }}"
14 state: present
15 with_lines: cat "{{ playbook_dir }}/run/lampstackhosts" \ No newline at end of file
diff --git a/workloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml b/workloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml
index a67a4f0..043909b 100755
--- a/workloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml
+++ b/workloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml
@@ -1,4 +1,11 @@
1--- 1---
2- name: Wait until server is up and runnning 2- name: Setup /etc/hosts on every node
3 local_action: wait_for port=22 host="{{ ansible_ssh_host | default(inventory_hostname) }}" search_regex=OpenSSH delay=10 3 lineinfile:
4 become: no 4 dest: /etc/hosts
5 line: "{{ item }}"
6 state: present
7 with_lines: cat "{{ playbook_dir }}/run/lampstackhosts"
8
9- name: Make sure that cloud-init script has completed
10 wait_for:
11 path: "/run/cloud-init/result.json"
diff --git a/workloads/ansible/shade/lampstack/roles/database/tasks/main.yml b/workloads/ansible/shade/lampstack/roles/database/tasks/main.yml
index 48fce5a..5638d2e 100755
--- a/workloads/ansible/shade/lampstack/roles/database/tasks/main.yml
+++ b/workloads/ansible/shade/lampstack/roles/database/tasks/main.yml
@@ -62,11 +62,9 @@
62- name: Setup NFS webserver access 62- name: Setup NFS webserver access
63 lineinfile: 63 lineinfile:
64 dest: /etc/exports 64 dest: /etc/exports
65 line: "/storage/wpcontent {{ item[0].openstack[item[1]] }}/32(rw,sync,no_root_squash,no_subtree_check)" 65 line: "/storage/wpcontent {{ hostvars[item].inter_ip }}/32(rw,sync,no_root_squash,no_subtree_check)"
66 with_nested: 66 with_flattened:
67 - "{{ hostvars.cloud.webserver.results }}" 67 - "{{ groups['webservers'] }}"
68 - ["private_v4", "public_v4"]
69 when: item[0].openstack[item[1]] != ''
70 no_log: True 68 no_log: True
71 69
72- name: nfs export 70- name: nfs export
diff --git a/workloads/ansible/shade/lampstack/roles/destroy/tasks/main.yml b/workloads/ansible/shade/lampstack/roles/destroy/tasks/main.yml
deleted file mode 100755
index fc82301..0000000
--- a/workloads/ansible/shade/lampstack/roles/destroy/tasks/main.yml
+++ /dev/null
@@ -1,79 +0,0 @@
1---
2- name: Get start timestamp
3 set_fact: starttime="{{ ansible_date_time }}"
4
5- name: Delete key pairs
6 os_keypair:
7 state: "absent"
8 auth: "{{ auth }}"
9 region_name: "{{ app_env.region_name }}"
10 availability_zone: "{{ app_env.availability_zone }}"
11 validate_certs: "{{ app_env.validate_certs }}"
12 name: "lampstack"
13 public_key_file: "{{ app_env.public_key_file }}"
14
15- name: Delete database node
16 os_server:
17 state: "absent"
18 auth: "{{ auth }}"
19 region_name: "{{ app_env.region_name }}"
20 availability_zone: "{{ app_env.availability_zone }}"
21 validate_certs: "{{ app_env.validate_certs }}"
22 name: database
23 image: "{{ app_env.image_name }}"
24 key_name: "lampstack"
25 timeout: 200
26 network: "{{ app_env.private_net_name }}"
27 meta:
28 hostname: database
29
30- name: Delete balancer node
31 os_server:
32 state: "absent"
33 auth: "{{ auth }}"
34 region_name: "{{ app_env.region_name }}"
35 availability_zone: "{{ app_env.availability_zone }}"
36 validate_certs: "{{ app_env.validate_certs }}"
37 name: balancer
38 image: "{{ app_env.image_name }}"
39 key_name: "lampstack"
40 timeout: 200
41 network: "{{ app_env.private_net_name }}"
42 meta:
43 hostname: balancer
44
45- name: Delete web server nodes
46 os_server:
47 state: "absent"
48 auth: "{{ auth }}"
49 region_name: "{{ app_env.region_name }}"
50 availability_zone: "{{ app_env.availability_zone }}"
51 validate_certs: "{{ app_env.validate_certs }}"
52 name: apache-{{ item }}
53 image: "{{ app_env.image_name }}"
54 key_name: "lampstack"
55 timeout: 200
56 network: "{{ app_env.private_net_name }}"
57 meta:
58 hostname: apache-{{ item }}
59 with_sequence: count={{ app_env.stack_size - 2 }}
60
61- name: Delete security group
62 os_security_group:
63 state: absent
64 auth: "{{ auth }}"
65 region_name: "{{ app_env.region_name }}"
66 availability_zone: "{{ app_env.availability_zone }}"
67 validate_certs: "{{ app_env.validate_certs }}"
68 name: lampstack_sg
69 description: secuirty group for lampstack
70
71- name: Delete cinder volume
72 os_volume:
73 state: absent
74 auth: "{{ auth }}"
75 region_name: "{{ app_env.region_name }}"
76 availability_zone: "{{ app_env.availability_zone }}"
77 validate_certs: "{{ app_env.validate_certs }}"
78 wait: yes
79 display_name: db_volume
diff --git a/workloads/ansible/shade/lampstack/roles/postprovision/tasks/apply.yml b/workloads/ansible/shade/lampstack/roles/postprovision/tasks/apply.yml
new file mode 100755
index 0000000..ed2eda9
--- /dev/null
+++ b/workloads/ansible/shade/lampstack/roles/postprovision/tasks/apply.yml
@@ -0,0 +1,44 @@
1---
2- name: Add the node to host group with private IP
3 add_host:
4 name: "{{ hostvars[item].public_ip }}"
5 inter_ip: "{{ hostvars[item].private_ip }}"
6 inter_name: "{{ item }}"
7 groups: "{{ hostvars[item].targetgroup }}"
8 with_items: "{{ groups['prohosts'] }}"
9
10- name: Add one web server to wps host group
11 add_host:
12 name: "{{ groups['webservers'][0] }}"
13 groups: wps
14 no_log: True
15
16- name: Remove the lampstackhosts file
17 file:
18 path: "{{ playbook_dir }}/run/lampstackhosts"
19 state: absent
20
21- name: Build up hosts file
22 lineinfile:
23 dest: "{{ playbook_dir }}/run/lampstackhosts"
24 line: "{{ hostvars[item].inter_ip }} {{ hostvars[item].inter_name }}"
25 state: present
26 create: yes
27 with_flattened:
28 - '{{ groups["dbservers"] }}'
29 - '{{ groups["balancers"] }}'
30 - '{{ groups["webservers"] }}'
31
32- name: Wait until servers are up and runnning
33 wait_for:
34 host: "{{ item }}"
35 port: 22
36 state: started
37 delay: 15
38 connect_timeout: 20
39 timeout: 300
40 with_items:
41 - '{{ groups["dbservers"] }}'
42 - '{{ groups["balancers"] }}'
43 - '{{ groups["webservers"] }}'
44
diff --git a/workloads/ansible/shade/lampstack/roles/postprovision/tasks/destroy.yml b/workloads/ansible/shade/lampstack/roles/postprovision/tasks/destroy.yml
new file mode 100755
index 0000000..d24380c
--- /dev/null
+++ b/workloads/ansible/shade/lampstack/roles/postprovision/tasks/destroy.yml
@@ -0,0 +1,30 @@
1---
2- name: Delete key pairs
3 os_keypair:
4 state: "absent"
5 auth: "{{ auth }}"
6 region_name: "{{ app_env.region_name }}"
7 availability_zone: "{{ app_env.availability_zone }}"
8 validate_certs: "{{ app_env.validate_certs }}"
9 name: "lampstack"
10 public_key_file: "{{ app_env.public_key_file }}"
11
12- name: Delete security group
13 os_security_group:
14 state: absent
15 auth: "{{ auth }}"
16 region_name: "{{ app_env.region_name }}"
17 availability_zone: "{{ app_env.availability_zone }}"
18 validate_certs: "{{ app_env.validate_certs }}"
19 name: lampstack_sg
20 description: secuirty group for lampstack
21
22- name: Delete cinder volume
23 os_volume:
24 state: absent
25 auth: "{{ auth }}"
26 region_name: "{{ app_env.region_name }}"
27 availability_zone: "{{ app_env.availability_zone }}"
28 validate_certs: "{{ app_env.validate_certs }}"
29 wait: yes
30 display_name: db_volume
diff --git a/workloads/ansible/shade/lampstack/roles/prepare/tasks/apply.yml b/workloads/ansible/shade/lampstack/roles/prepare/tasks/apply.yml
new file mode 100755
index 0000000..832c8cd
--- /dev/null
+++ b/workloads/ansible/shade/lampstack/roles/prepare/tasks/apply.yml
@@ -0,0 +1,100 @@
1---
2- name: Ensure we have a working directory to save runtime files
3 file: "path={{ playbook_dir }}/run state=directory"
4
5- name: Retrieve specified flavor
6 os_flavor_facts:
7 auth: "{{ auth }}"
8 region_name: "{{ app_env.region_name }}"
9 availability_zone: "{{ app_env.availability_zone }}"
10 validate_certs: "{{ app_env.validate_certs }}"
11 name: "{{ app_env.flavor_name }}"
12
13- name: Create a key-pair
14 os_keypair:
15 state: "present"
16 auth: "{{ auth }}"
17 region_name: "{{ app_env.region_name }}"
18 availability_zone: "{{ app_env.availability_zone }}"
19 validate_certs: "{{ app_env.validate_certs }}"
20 name: "lampstack"
21 public_key_file: "{{ app_env.public_key_file }}"
22
23- name: Create volume
24 os_volume:
25 state: present
26 auth: "{{ auth }}"
27 region_name: "{{ app_env.region_name }}"
28 availability_zone: "{{ app_env.availability_zone }}"
29 validate_certs: "{{ app_env.validate_certs }}"
30 size: "{{ app_env.volume_size }}"
31 wait: yes
32 display_name: db_volume
33
34- name: Create security group
35 os_security_group:
36 state: present
37 auth: "{{ auth }}"
38 region_name: "{{ app_env.region_name }}"
39 availability_zone: "{{ app_env.availability_zone }}"
40 validate_certs: "{{ app_env.validate_certs }}"
41 name: lampstack_sg
42 description: security group for lampstack
43
44- name: Add security rules
45 os_security_group_rule:
46 state: present
47 auth: "{{ auth }}"
48 region_name: "{{ app_env.region_name }}"
49 availability_zone: "{{ app_env.availability_zone }}"
50 validate_certs: "{{ app_env.validate_certs }}"
51 security_group: lampstack_sg
52 protocol: "{{ item.protocol }}"
53 direction: "{{ item.dir }}"
54 port_range_min: "{{ item.p_min }}"
55 port_range_max: "{{ item.p_max }}"
56 remote_ip_prefix: 0.0.0.0/0
57 with_items:
58 - { p_min: 22, p_max: 22, dir: ingress, protocol: tcp }
59 - { p_min: 80, p_max: 80, dir: ingress, protocol: tcp }
60 - { p_min: 2049, p_max: 2049, dir: ingress, protocol: tcp }
61 - { p_min: 2049, p_max: 2049, dir: egress, protocol: tcp }
62 - { p_min: 3306, p_max: 3306, dir: ingress, protocol: tcp }
63 - { p_min: -1, p_max: -1, dir: ingress, protocol: icmp }
64 - { p_min: -1, p_max: -1, dir: egress, protocol: icmp }
65
66- name: Create volume
67 os_volume:
68 state: present
69 auth: "{{ auth }}"
70 region_name: "{{ app_env.region_name }}"
71 availability_zone: "{{ app_env.availability_zone }}"
72 validate_certs: "{{ app_env.validate_certs }}"
73 size: "{{ app_env.volume_size }}"
74 wait: yes
75 display_name: db_volume
76
77- name: Add database node to provisioning host group
78 add_host:
79 name: "database"
80 targetgroup: "dbservers"
81 ansible_host: "127.0.0.1"
82 groups: "prohosts"
83 no_log: True
84
85- name: Add balancer node to provisioning host group
86 add_host:
87 name: "balancer"
88 targetgroup: "balancers"
89 ansible_host: "127.0.0.1"
90 groups: "prohosts"
91 no_log: True
92
93- name: Add apache nodes to provisioning host group
94 add_host:
95 name: "apache-{{ item }}"
96 targetgroup: "webservers"
97 ansible_host: "127.0.0.1"
98 groups: "prohosts"
99 with_sequence: count={{ app_env.stack_size - 2 }}
100 no_log: True
diff --git a/workloads/ansible/shade/lampstack/roles/prepare/tasks/destroy.yml b/workloads/ansible/shade/lampstack/roles/prepare/tasks/destroy.yml
new file mode 100755
index 0000000..4c12a22
--- /dev/null
+++ b/workloads/ansible/shade/lampstack/roles/prepare/tasks/destroy.yml
@@ -0,0 +1,25 @@
1---
2- name: Add database node to provisioning host group
3 add_host:
4 name: "database"
5 targetgroup: "dbservers"
6 ansible_host: "127.0.0.1"
7 groups: "prohosts"
8 no_log: True
9
10- name: Add balancer node to provisioning host group
11 add_host:
12 name: "balancer"
13 targetgroup: "balancers"
14 ansible_host: "127.0.0.1"
15 groups: "prohosts"
16 no_log: True
17
18- name: Add apache nodes to provisioning host group
19 add_host:
20 name: "apache-{{ item }}"
21 targetgroup: "webservers"
22 ansible_host: "127.0.0.1"
23 groups: "prohosts"
24 with_sequence: count={{ app_env.stack_size - 2 }}
25 no_log: True
diff --git a/workloads/ansible/shade/lampstack/roles/provision/tasks/apply.yml b/workloads/ansible/shade/lampstack/roles/provision/tasks/apply.yml
new file mode 100755
index 0000000..83a6bce
--- /dev/null
+++ b/workloads/ansible/shade/lampstack/roles/provision/tasks/apply.yml
@@ -0,0 +1,49 @@
1---
2- name: Create an OpenStack virtual machine
3 os_server:
4 state: "present"
5 auth: "{{ auth }}"
6 region_name: "{{ app_env.region_name }}"
7 availability_zone: "{{ app_env.availability_zone }}"
8 validate_certs: "{{ app_env.validate_certs }}"
9 name: "{{ inventory_hostname }}"
10 image: "{{ app_env.image_name }}"
11 key_name: "lampstack"
12 timeout: 200
13 flavor: "{{ app_env.flavor_name }}"
14 network: "{{ app_env.private_net_name }}"
15 userdata: "{{ lookup('template', 'roles/provision/templates/userdata.j2') }}"
16 config_drive: "{{ app_env.config_drive | default('no') }}"
17 security_groups: lampstack_sg
18 floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
19 meta:
20 hostname: "{{ inventory_hostname }}"
21 register: osvm
22
23- name: Setup variables for generating host groups
24 set_fact:
25 inter_name: "{{ osvm.openstack.name }}"
26 public_ip: "{{ osvm.openstack.public_v4 }}"
27 private_ip: "{{ osvm.openstack.private_v4 }}"
28
29- name: Use public ip address when private ip is empty
30 set_fact:
31 private_ip: "{{ osvm.openstack.public_v4 }}"
32 when: osvm.openstack.private_v4 == ""
33
34- name: Use private ip address when public ip is empty
35 set_fact:
36 public_ip: "{{ osvm.openstack.private_v4 }}"
37 when: osvm.openstack.public_v4 == ""
38
39- name: Attach a volume to the node
40 os_server_volume:
41 state: present
42 auth: "{{ auth }}"
43 region_name: "{{ app_env.region_name }}"
44 availability_zone: "{{ app_env.availability_zone }}"
45 validate_certs: "{{ app_env.validate_certs }}"
46 server: "{{ inventory_hostname }}"
47 volume: "db_volume"
48 device: "{{ app_env.block_device_name }}"
49 when: inventory_hostname == "database" \ No newline at end of file
diff --git a/workloads/ansible/shade/lampstack/roles/provision/tasks/destroy.yml b/workloads/ansible/shade/lampstack/roles/provision/tasks/destroy.yml
new file mode 100755
index 0000000..fcc2dc7
--- /dev/null
+++ b/workloads/ansible/shade/lampstack/roles/provision/tasks/destroy.yml
@@ -0,0 +1,14 @@
1---
2- name: Destroy an OpenStack virtual machine
3 os_server:
4 state: "absent"
5 auth: "{{ auth }}"
6 region_name: "{{ app_env.region_name }}"
7 availability_zone: "{{ app_env.availability_zone }}"
8 validate_certs: "{{ app_env.validate_certs }}"
9 name: "{{ inventory_hostname }}"
10 image: "{{ app_env.image_name }}"
11 timeout: 200
12 network: "{{ app_env.private_net_name }}"
13 meta:
14 hostname: "{{ inventory_hostname }}"
diff --git a/workloads/ansible/shade/lampstack/roles/apply/templates/userdata.j2 b/workloads/ansible/shade/lampstack/roles/provision/templates/userdata.j2
index 7767d2e..7767d2e 100755
--- a/workloads/ansible/shade/lampstack/roles/apply/templates/userdata.j2
+++ b/workloads/ansible/shade/lampstack/roles/provision/templates/userdata.j2
diff --git a/workloads/ansible/shade/lampstack/roles/webserver/tasks/main.yml b/workloads/ansible/shade/lampstack/roles/webserver/tasks/main.yml
index 0ad10ed..1113118 100755
--- a/workloads/ansible/shade/lampstack/roles/webserver/tasks/main.yml
+++ b/workloads/ansible/shade/lampstack/roles/webserver/tasks/main.yml
@@ -89,18 +89,9 @@
89- name: Mount the directory using private IP 89- name: Mount the directory using private IP
90 mount: 90 mount:
91 name: /var/www/html/wp-content 91 name: /var/www/html/wp-content
92 src: "{{ hostvars.cloud.database.openstack.private_v4 }}:/storage/wpcontent" 92 src: "{{ hostvars[groups['dbservers'][0]].inter_ip }}:/storage/wpcontent"
93 state: mounted 93 state: mounted
94 fstype: nfs 94 fstype: nfs
95 when: hostvars.cloud.database.openstack.private_v4 != ""
96
97- name: Mount the directory using public IP
98 mount:
99 name: /var/www/html/wp-content
100 src: "{{ hostvars.cloud.database.openstack.public_v4 }}:/storage/wpcontent"
101 state: mounted
102 fstype: nfs
103 when: hostvars.cloud.database.openstack.private_v4 == ""
104 95
105- lineinfile: dest=/etc/apache2/apache2.conf line="ServerName localhost" 96- lineinfile: dest=/etc/apache2/apache2.conf line="ServerName localhost"
106 when: ansible_distribution == 'Ubuntu' 97 when: ansible_distribution == 'Ubuntu'
@@ -134,22 +125,14 @@
134 - { then: 'database_name_here', now: 'decision2016' } 125 - { then: 'database_name_here', now: 'decision2016' }
135 - { then: 'username_here', now: "{{ db_user }}" } 126 - { then: 'username_here', now: "{{ db_user }}" }
136 - { then: 'password_here', now: "{{ db_pass }}" } 127 - { then: 'password_here', now: "{{ db_pass }}" }
128 no_log: True
137 129
138- name: Configure wordpress network access using private IP 130- name: Configure wordpress network access using private IP
139 replace: 131 replace:
140 dest: /var/www/html/wp-config.php 132 dest: /var/www/html/wp-config.php
141 regexp: "'localhost'" 133 regexp: "'localhost'"
142 replace: "'{{ hostvars.cloud.database.openstack.private_v4 }}'" 134 replace: "'{{ hostvars[groups['dbservers'][0]].inter_ip }}'"
143 backup: no
144 when: hostvars.cloud.database.openstack.private_v4 != ""
145
146- name: Configure wordpress network access using public IP
147 replace:
148 dest: /var/www/html/wp-config.php
149 regexp: "'localhost'"
150 replace: "'{{ hostvars.cloud.database.openstack.public_v4 }}'"
151 backup: no 135 backup: no
152 when: hostvars.cloud.database.openstack.private_v4 == ""
153 136
154- name: Change ownership of wordpress 137- name: Change ownership of wordpress
155 shell: chown -R www-data:www-data /var/www/html 138 shell: chown -R www-data:www-data /var/www/html
diff --git a/workloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml b/workloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml
index 05b5e1f..90fe294 100755
--- a/workloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml
+++ b/workloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml
@@ -13,22 +13,11 @@
13- name: Install wordpress 13- name: Install wordpress
14 command: > 14 command: >
15 wp core install --path=/var/www/html 15 wp core install --path=/var/www/html
16 --url="http://{{ hostvars.cloud.balancer.openstack.public_v4 }}" 16 --url="http://{{ groups['balancers'][0] }}"
17 --title='OpenStack Interop Challenge' 17 --title='OpenStack Interop Challenge'
18 --admin_user=wpuser 18 --admin_user=wpuser
19 --admin_password="{{ db_pass }}" 19 --admin_password="{{ db_pass }}"
20 --admin_email='interop@openstack.org' 20 --admin_email='interop@openstack.org'
21 when: hostvars.cloud.balancer.openstack.public_v4 != ""
22
23- name: Install wordpress
24 command: >
25 wp core install --path=/var/www/html
26 --url="http://{{ hostvars.cloud.balancer.openstack.private_v4 }}"
27 --title='OpenStack Interop Challenge'
28 --admin_user=wpuser
29 --admin_password="{{ db_pass }}"
30 --admin_email='interop@openstack.org'
31 when: hostvars.cloud.balancer.openstack.public_v4 == ""
32 21
33- name: Install package for automated plugin activation 22- name: Install package for automated plugin activation
34 shell: > 23 shell: >
diff --git a/workloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml b/workloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml
index eb2cddd..f2a5a21 100755
--- a/workloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml
+++ b/workloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml
@@ -13,28 +13,12 @@
13- name: Install wordpress 13- name: Install wordpress
14 command: > 14 command: >
15 wp core install --path=/var/www/html 15 wp core install --path=/var/www/html
16 --url="http://{{ hostvars.cloud.balancer.openstack.public_v4 }}" 16 --url="http://{{ groups['balancers'][0] }}"
17 --title='OpenStack Interop Challenge' 17 --title='OpenStack Interop Challenge'
18 --admin_user=wpuser 18 --admin_user=wpuser
19 --admin_password="{{ db_pass }}" 19 --admin_password="{{ db_pass }}"
20 --admin_email='interop@openstack.org' 20 --admin_email='interop@openstack.org'
21 --allow-root 21 --allow-root
22 when: hostvars.cloud.balancer.openstack.public_v4 != ""
23
24- name: Install wordpress
25 command: >
26 wp core install --path=/var/www/html
27 --url="http://{{ hostvars.cloud.balancer.openstack.private_v4 }}"
28 --title='OpenStack Interop Challenge'
29 --admin_user=wpuser
30 --admin_password="{{ db_pass }}"
31 --admin_email='interop@openstack.org'
32 --allow-root
33 when: hostvars.cloud.balancer.openstack.public_v4 == ""
34
35- name: Install package for automated plugin activation
36 shell: >
37 wp package install itspriddle/wp-cli-tgmpa-plugin --allow-root
38 22
39- name: Make an initial request, so that later switch-theme hooks work. 23- name: Make an initial request, so that later switch-theme hooks work.
40 shell: > 24 shell: >
@@ -47,8 +31,16 @@
47 31
48- name: Install and activate required plugins 32- name: Install and activate required plugins
49 shell: > 33 shell: >
50 sudo -u www-data wp --path=/var/www/html 34 sudo -u www-data wp --path=/var/www/html plugin install {{ item }} --activate
51 tgmpa-plugin install --all-required --activate 35 with_items:
36 - advanced-custom-fields
37 - cforms2
38 - co-authors-plus
39 - disable-comments
40 - pmzez-page-loader
41 - responsive-lightbox
42 - /var/www/html/wp-content/themes/superuser/src/plugins/pbd-ajax-load-posts.zip
43 - /var/www/html/wp-content/themes/superuser/src/plugins/share-links.zip
52 args: 44 args:
53 warn: no 45 warn: no
54 46
diff --git a/workloads/ansible/shade/lampstack/site.yml b/workloads/ansible/shade/lampstack/site.yml
index 47728b9..5f08d48 100755
--- a/workloads/ansible/shade/lampstack/site.yml
+++ b/workloads/ansible/shade/lampstack/site.yml
@@ -1,14 +1,47 @@
1--- 1---
2- name: Get start timestamp
3 hosts: cloud
4 connection: local
5 tasks:
6 - set_fact:
7 starttime: "{{ ansible_date_time }}"
8 tags: "info"
9
10- name: Prepare to run the workload
11 hosts: cloud
12 connection: local
13 vars_files:
14 - "vars/{{ env }}.yml"
15 tasks:
16 - include: "roles/prepare/tasks/{{ action }}.yml"
17 roles:
18 - prepare
19 tags: "{{ action }}"
20
2- name: provision servers 21- name: provision servers
22 hosts: prohosts
23 connection: local
24 strategy: free
25 vars_files:
26 - "vars/{{ env }}.yml"
27 tasks:
28 - include: "roles/provision/tasks/{{ action }}.yml"
29 roles:
30 - provision
31 tags: "{{ action }}"
32
33- name: Post provision process
3 hosts: cloud 34 hosts: cloud
4 connection: local 35 connection: local
5 vars_files: 36 vars_files:
6 - "vars/{{ env }}.yml" 37 - "vars/{{ env }}.yml"
38 tasks:
39 - include: "roles/postprovision/tasks/{{ action }}.yml"
7 roles: 40 roles:
8 - "{{ action }}" 41 - postprovision
9 tags: "{{ action }}" 42 tags: "{{ action }}"
10 43
11- name: Install python2 for ansible to work 44- name: Performe common tasks on all servers
12 hosts: dbservers, webservers, balancers 45 hosts: dbservers, webservers, balancers
13 gather_facts: false 46 gather_facts: false
14 user: "{{ app_env.ssh_user }}" 47 user: "{{ app_env.ssh_user }}"
@@ -91,17 +124,9 @@
91 - debug: 124 - debug:
92 msg: >- 125 msg: >-
93 Access wordpress at 126 Access wordpress at
94 http://{{ hostvars.cloud.balancer.openstack.public_v4 }}. 127 http://{{ groups['balancers'][0] }}.
95 wordpress userid is wpuser, password is {{ db_pass }}
96 when: hostvars.cloud.balancer is defined and
97 hostvars.cloud.balancer.openstack.public_v4 != ""
98 - debug:
99 msg: >-
100 Access wordpress at
101 http://{{ hostvars.cloud.balancer.openstack.private_v4 }}.
102 wordpress userid is wpuser, password is {{ db_pass }} 128 wordpress userid is wpuser, password is {{ db_pass }}
103 when: hostvars.cloud.balancer is defined and 129 when: groups['balancers'] is defined
104 hostvars.cloud.balancer.openstack.public_v4 == ""
105 - debug: 130 - debug:
106 msg: >- 131 msg: >-
107 The work load test started at {{ hostvars.cloud.starttime.time }}, 132 The work load test started at {{ hostvars.cloud.starttime.time }},
diff --git a/workloads/ansible/shade/lampstack/vars/bluebox.yml b/workloads/ansible/shade/lampstack/vars/bluebox.yml
index 0d4e5dd..ef2f09c 100755
--- a/workloads/ansible/shade/lampstack/vars/bluebox.yml
+++ b/workloads/ansible/shade/lampstack/vars/bluebox.yml
@@ -11,16 +11,16 @@ auth: {
11app_env: { 11app_env: {
12 target_os: "ubuntu", 12 target_os: "ubuntu",
13 ssh_user: "ubuntu", 13 ssh_user: "ubuntu",
14 image_name: "ubuntu-16.10", 14 image_name: "Ubuntu 16.04",
15 region_name: "", 15 region_name: "",
16 availability_zone: "", 16 availability_zone: "",
17 validate_certs: True, 17 validate_certs: False,
18 private_net_name: "interopnet", 18 private_net_name: "demonet",
19 flavor_name: "m1.small", 19 flavor_name: "m1.small",
20 public_key_file: "/home/ubuntu/.ssh/id_rsa.pub", 20 public_key_file: "/home/ubuntu/.ssh/interop.pub",
21 stack_size: 4, 21 stack_size: 4,
22 volume_size: 10, 22 volume_size: 4,
23 block_device_name: "/dev/vdb", 23 block_device_name: "/dev/vdb",
24 wp_latest: "https://wordpress.org/wordpress-4.6.1.tar.gz", 24 wp_latest: "http://10.0.10.41/lampstack/wordpress-4.6.1.tar.gz",
25 wp_importer: "http://downloads.wordpress.org/plugin/wordpress-importer.0.6.3.zip" 25 wp_importer: "http://10.0.10.41/lampstack/wordpress-importer.0.6.3.zip"
26} 26}
diff --git a/workloads/ansible/shade/lampstack/vars/leap.yml b/workloads/ansible/shade/lampstack/vars/leap.yml
index 1a6b5fe..a943799 100755
--- a/workloads/ansible/shade/lampstack/vars/leap.yml
+++ b/workloads/ansible/shade/lampstack/vars/leap.yml
@@ -11,16 +11,17 @@ auth: {
11 11
12app_env: { 12app_env: {
13 target_os: "ubuntu", 13 target_os: "ubuntu",
14 image_name: "ubuntu-14.04", 14 image_name: "ubuntu-16.04",
15 region_name: "RegionOne", 15 region_name: "RegionOne",
16 availability_zone: "nova", 16 availability_zone: "nova",
17 validate_certs: False, 17 validate_certs: False,
18 ssh_user: "ubuntu", 18 ssh_user: "ubuntu",
19 private_net_name: "demonet", 19 private_net_name: "demonet",
20 flavor_name: "m1.large", 20 flavor_name: "m1.large",
21 public_key_file: "/home/ubuntu/.ssh/id_rsa.pub", 21 public_key_file: "/home/ubuntu/.ssh/interop.pub",
22 stack_size: 4, 22 stack_size: 4,
23 volume_size: 2, 23 volume_size: 2,
24 block_device_name: "/dev/vdb", 24 block_device_name: "/dev/vdb",
25 wp_latest: "https://wordpress.org/wordpress-4.6.tar.gz" 25 wp_latest: "http://10.0.10.12/lampstack/wordpress-4.6.1.tar.gz",
26 wp_importer: "http://10.0.10.12/lampstack/wordpress-importer.0.6.3.zip"
26} 27}