Browse Source

Rework the lampstack workload to enable provision parallel

Change-Id: Ic5047a1fd0e9d158f33f86ab013a445aa334da2a
changes/77/448677/8
Tong Li 2 years ago
parent
commit
a58bab3adf
21 changed files with 359 additions and 377 deletions
  1. 1
    0
      workloads/ansible/shade/lampstack/.gitignore
  2. 0
    193
      workloads/ansible/shade/lampstack/roles/apply/tasks/main.yml
  3. 7
    5
      workloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml
  4. 6
    15
      workloads/ansible/shade/lampstack/roles/cleaner/tasks/apply.yml
  5. 7
    4
      workloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml
  6. 10
    3
      workloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml
  7. 3
    5
      workloads/ansible/shade/lampstack/roles/database/tasks/main.yml
  8. 0
    79
      workloads/ansible/shade/lampstack/roles/destroy/tasks/main.yml
  9. 44
    0
      workloads/ansible/shade/lampstack/roles/postprovision/tasks/apply.yml
  10. 30
    0
      workloads/ansible/shade/lampstack/roles/postprovision/tasks/destroy.yml
  11. 100
    0
      workloads/ansible/shade/lampstack/roles/prepare/tasks/apply.yml
  12. 25
    0
      workloads/ansible/shade/lampstack/roles/prepare/tasks/destroy.yml
  13. 49
    0
      workloads/ansible/shade/lampstack/roles/provision/tasks/apply.yml
  14. 14
    0
      workloads/ansible/shade/lampstack/roles/provision/tasks/destroy.yml
  15. 0
    0
      workloads/ansible/shade/lampstack/roles/provision/templates/userdata.j2
  16. 3
    20
      workloads/ansible/shade/lampstack/roles/webserver/tasks/main.yml
  17. 1
    12
      workloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml
  18. 11
    19
      workloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml
  19. 37
    12
      workloads/ansible/shade/lampstack/site.yml
  20. 7
    7
      workloads/ansible/shade/lampstack/vars/bluebox.yml
  21. 4
    3
      workloads/ansible/shade/lampstack/vars/leap.yml

+ 1
- 0
workloads/ansible/shade/lampstack/.gitignore View File

@@ -1,5 +1,6 @@
1 1
 *.out
2 2
 vars/*
3
+run/*
3 4
 */**/*.log
4 5
 */**/.DS_Store
5 6
 */**/._

+ 0
- 193
workloads/ansible/shade/lampstack/roles/apply/tasks/main.yml View File

@@ -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

+ 7
- 5
workloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml View File

@@ -1,4 +1,8 @@
1 1
 ---
2
+- name: update apt cache
3
+  apt: update_cache=yes
4
+  when: ansible_os_family == "Debian"
5
+
2 6
 - name: Haproxy install
3 7
   package:
4 8
     name: haproxy
@@ -28,11 +32,9 @@
28 32
 - name: Add web servers to the haproxy
29 33
   lineinfile:
30 34
     dest: /etc/haproxy/haproxy.cfg
31
-    line: "    server ws{{ item[0].openstack[item[1]] }} {{ item[0].openstack[item[1]] }}:80 check"
32
-  with_nested:
33
-    - "{{ hostvars.cloud.webserver.results }}"
34
-    - ["private_v4", "public_v4"]
35
-  when: item[0].openstack[item[1]] != ''
35
+    line: "    server ws{{ hostvars[item].inter_ip }} {{ hostvars[item].inter_ip }}:80 check"
36
+  with_flattened:
37
+    - "{{ groups['webservers'] }}"
36 38
   no_log: True
37 39
 
38 40
 - service: name=haproxy state=restarted enabled=yes

+ 6
- 15
workloads/ansible/shade/lampstack/roles/cleaner/tasks/apply.yml View File

@@ -5,19 +5,10 @@
5 5
     availability_zone: "{{ app_env.availability_zone }}"
6 6
     validate_certs: "{{ app_env.validate_certs }}"
7 7
     state: absent
8
-    floating_ip_address: "{{ database.openstack.public_v4 }}"
9
-    server: "{{ database.openstack.name }}"
10
-  when: database.openstack.private_v4 != ""
8
+    floating_ip_address: "{{ item }}"
9
+    purge: True
10
+    server: "{{ hostvars[item].inter_name }}"
11
+  with_flattened:
12
+    - "{{ groups['webservers'] }}"
13
+    - "{{ groups['dbservers'] }}"
11 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

+ 7
- 4
workloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml View File

@@ -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 2
 - name: Install python2 for Ansible
7 3
   raw: dnf install -y python2 python2-dnf libselinux-python
8 4
   register: result
@@ -10,3 +6,10 @@
10 6
 
11 7
 - name: Set SELinux to permisive
12 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"

+ 10
- 3
workloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml View File

@@ -1,4 +1,11 @@
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
2
+- name: Setup /etc/hosts on every node
3
+  lineinfile:
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"

+ 3
- 5
workloads/ansible/shade/lampstack/roles/database/tasks/main.yml View File

@@ -62,11 +62,9 @@
62 62
 - name: Setup NFS webserver access
63 63
   lineinfile:
64 64
     dest: /etc/exports
65
-    line: "/storage/wpcontent {{ item[0].openstack[item[1]] }}/32(rw,sync,no_root_squash,no_subtree_check)"
66
-  with_nested:
67
-    - "{{ hostvars.cloud.webserver.results }}"
68
-    - ["private_v4", "public_v4"]
69
-  when: item[0].openstack[item[1]] != ''
65
+    line: "/storage/wpcontent {{ hostvars[item].inter_ip }}/32(rw,sync,no_root_squash,no_subtree_check)"
66
+  with_flattened:
67
+    - "{{ groups['webservers'] }}"
70 68
   no_log: True
71 69
 
72 70
 - name: nfs export

+ 0
- 79
workloads/ansible/shade/lampstack/roles/destroy/tasks/main.yml View File

@@ -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

+ 44
- 0
workloads/ansible/shade/lampstack/roles/postprovision/tasks/apply.yml View File

@@ -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
+

+ 30
- 0
workloads/ansible/shade/lampstack/roles/postprovision/tasks/destroy.yml View File

@@ -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

+ 100
- 0
workloads/ansible/shade/lampstack/roles/prepare/tasks/apply.yml View File

@@ -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

+ 25
- 0
workloads/ansible/shade/lampstack/roles/prepare/tasks/destroy.yml View File

@@ -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

+ 49
- 0
workloads/ansible/shade/lampstack/roles/provision/tasks/apply.yml View File

@@ -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"

+ 14
- 0
workloads/ansible/shade/lampstack/roles/provision/tasks/destroy.yml View File

@@ -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 }}"

workloads/ansible/shade/lampstack/roles/apply/templates/userdata.j2 → workloads/ansible/shade/lampstack/roles/provision/templates/userdata.j2 View File


+ 3
- 20
workloads/ansible/shade/lampstack/roles/webserver/tasks/main.yml View File

@@ -89,18 +89,9 @@
89 89
 - name: Mount the directory using private IP
90 90
   mount:
91 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 93
     state: mounted
94 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 96
 - lineinfile: dest=/etc/apache2/apache2.conf line="ServerName localhost"
106 97
   when: ansible_distribution == 'Ubuntu'
@@ -134,22 +125,14 @@
134 125
     - { then: 'database_name_here', now: 'decision2016' }
135 126
     - { then: 'username_here', now: "{{ db_user }}" }
136 127
     - { then: 'password_here', now: "{{ db_pass }}" }
128
+  no_log: True
137 129
 
138 130
 - name: Configure wordpress network access using private IP
139 131
   replace:
140 132
     dest: /var/www/html/wp-config.php
141 133
     regexp: "'localhost'"
142
-    replace: "'{{ hostvars.cloud.database.openstack.private_v4 }}'"
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 }}'"
134
+    replace: "'{{ hostvars[groups['dbservers'][0]].inter_ip }}'"
151 135
     backup: no
152
-  when: hostvars.cloud.database.openstack.private_v4 == ""
153 136
 
154 137
 - name: Change ownership of wordpress
155 138
   shell: chown -R www-data:www-data /var/www/html

+ 1
- 12
workloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml View File

@@ -13,22 +13,11 @@
13 13
 - name: Install wordpress
14 14
   command: >
15 15
     wp core install --path=/var/www/html
16
-    --url="http://{{ hostvars.cloud.balancer.openstack.public_v4 }}"
16
+    --url="http://{{ groups['balancers'][0] }}"
17 17
     --title='OpenStack Interop Challenge'
18 18
     --admin_user=wpuser
19 19
     --admin_password="{{ db_pass }}"
20 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 22
 - name: Install package for automated plugin activation
34 23
   shell: >

+ 11
- 19
workloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml View File

@@ -13,28 +13,12 @@
13 13
 - name: Install wordpress
14 14
   command: >
15 15
     wp core install --path=/var/www/html
16
-    --url="http://{{ hostvars.cloud.balancer.openstack.public_v4 }}"
16
+    --url="http://{{ groups['balancers'][0] }}"
17 17
     --title='OpenStack Interop Challenge'
18 18
     --admin_user=wpuser
19 19
     --admin_password="{{ db_pass }}"
20 20
     --admin_email='interop@openstack.org'
21 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 23
 - name: Make an initial request, so that later switch-theme hooks work.
40 24
   shell: >
@@ -47,8 +31,16 @@
47 31
 
48 32
 - name: Install and activate required plugins
49 33
   shell: >
50
-    sudo -u www-data wp --path=/var/www/html
51
-    tgmpa-plugin install --all-required --activate
34
+    sudo -u www-data wp --path=/var/www/html plugin install {{ item }} --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 44
   args:
53 45
     warn: no
54 46
 

+ 37
- 12
workloads/ansible/shade/lampstack/site.yml View File

@@ -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 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 34
   hosts: cloud
4 35
   connection: local
5 36
   vars_files:
6 37
     - "vars/{{ env }}.yml"
38
+  tasks:
39
+    - include: "roles/postprovision/tasks/{{ action }}.yml"
7 40
   roles:
8
-    - "{{ action }}"
41
+    - postprovision
9 42
   tags: "{{ action }}"
10 43
 
11
-- name: Install python2 for ansible to work
44
+- name: Performe common tasks on all servers
12 45
   hosts: dbservers, webservers, balancers
13 46
   gather_facts: false
14 47
   user: "{{ app_env.ssh_user }}"
@@ -91,17 +124,9 @@
91 124
     - debug:
92 125
         msg: >-
93 126
           Access wordpress at
94
-          http://{{ hostvars.cloud.balancer.openstack.public_v4 }}.
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 }}.
127
+          http://{{ groups['balancers'][0] }}.
102 128
           wordpress userid is wpuser, password is {{ db_pass }}
103
-      when: hostvars.cloud.balancer is defined and
104
-            hostvars.cloud.balancer.openstack.public_v4 == ""
129
+      when: groups['balancers'] is defined
105 130
     - debug:
106 131
         msg: >-
107 132
           The work load test started at {{ hostvars.cloud.starttime.time }},

+ 7
- 7
workloads/ansible/shade/lampstack/vars/bluebox.yml View File

@@ -11,16 +11,16 @@ auth: {
11 11
 app_env: {
12 12
   target_os: "ubuntu",
13 13
   ssh_user: "ubuntu",
14
-  image_name: "ubuntu-16.10",
14
+  image_name: "Ubuntu 16.04",
15 15
   region_name: "",
16 16
   availability_zone: "",
17
-  validate_certs: True,
18
-  private_net_name: "interopnet",
17
+  validate_certs: False,
18
+  private_net_name: "demonet",
19 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 21
   stack_size: 4,
22
-  volume_size: 10,
22
+  volume_size: 4,
23 23
   block_device_name: "/dev/vdb",
24
-  wp_latest: "https://wordpress.org/wordpress-4.6.1.tar.gz",
25
-  wp_importer: "http://downloads.wordpress.org/plugin/wordpress-importer.0.6.3.zip"
24
+  wp_latest: "http://10.0.10.41/lampstack/wordpress-4.6.1.tar.gz",
25
+  wp_importer: "http://10.0.10.41/lampstack/wordpress-importer.0.6.3.zip"
26 26
 }

+ 4
- 3
workloads/ansible/shade/lampstack/vars/leap.yml View File

@@ -11,16 +11,17 @@ auth: {
11 11
 
12 12
 app_env: {
13 13
   target_os: "ubuntu",
14
-  image_name: "ubuntu-14.04",
14
+  image_name: "ubuntu-16.04",
15 15
   region_name: "RegionOne",
16 16
   availability_zone: "nova",
17 17
   validate_certs: False,
18 18
   ssh_user: "ubuntu",
19 19
   private_net_name: "demonet",
20 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 22
   stack_size: 4,
23 23
   volume_size: 2,
24 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
 }

Loading…
Cancel
Save