Browse Source

Fix the following issues

1. mysql 5.6+ configuration
2. noting supporting ubuntu 16.xx
3. different platform code mixing
4. tags so that you can run selected tasks by role
5. uses openstack superuser theme and posts
6. haproxy used old configuration format

Closes-Bug #1654240
Closes-Bug #1649949

Change-Id: Ibbde92ed4fc18f85d004d54f00d3547c3df8fcc4
Tong Li 2 years ago
parent
commit
d09502f4f8
23 changed files with 330 additions and 231 deletions
  1. 8
    6
      workloads/ansible/shade/lampstack/README.md
  2. BIN
      workloads/ansible/shade/lampstack/files/wp-cli.phar
  3. BIN
      workloads/ansible/shade/lampstack/files/wpposts.zip
  4. BIN
      workloads/ansible/shade/lampstack/files/wptheme.zip
  5. 6
    1
      workloads/ansible/shade/lampstack/roles/apply/templates/userdata.j2
  6. 12
    27
      workloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml
  7. 0
    33
      workloads/ansible/shade/lampstack/roles/balancer/templates/haproxy.cfg.j2
  8. 0
    34
      workloads/ansible/shade/lampstack/roles/balancer/templates/haproxy_fedora.cfg.j2
  9. 0
    7
      workloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml
  10. 4
    0
      workloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml
  11. 16
    5
      workloads/ansible/shade/lampstack/roles/database/tasks/main.yml
  12. 50
    20
      workloads/ansible/shade/lampstack/roles/webserver/tasks/main.yml
  13. 100
    0
      workloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml
  14. 0
    73
      workloads/ansible/shade/lampstack/roles/wordpress/tasks/main.yml
  15. 100
    0
      workloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml
  16. 14
    1
      workloads/ansible/shade/lampstack/site.yml
  17. 4
    3
      workloads/ansible/shade/lampstack/vars/bluebox.yml
  18. 2
    3
      workloads/ansible/shade/lampstack/vars/dreamhost.yml
  19. 6
    6
      workloads/ansible/shade/lampstack/vars/leap.yml
  20. 2
    3
      workloads/ansible/shade/lampstack/vars/osic.yml
  21. 2
    3
      workloads/ansible/shade/lampstack/vars/otc.yml
  22. 2
    3
      workloads/ansible/shade/lampstack/vars/ovh.yml
  23. 2
    3
      workloads/ansible/shade/lampstack/vars/trystack.yml

+ 8
- 6
workloads/ansible/shade/lampstack/README.md View File

@@ -53,6 +53,7 @@ You may create one such file per cloud for your tests.
53 53
     }
54 54
 
55 55
     app_env: {
56
+      target_os: "ubuntu",
56 57
       image_name: "ubuntu-15.04",
57 58
       region_name: "RegionOne",
58 59
       availability_zone: "nova",
@@ -63,9 +64,7 @@ You may create one such file per cloud for your tests.
63 64
       stack_size: 4,
64 65
       volume_size: 2,
65 66
       block_device_name: "/dev/vdb",
66
-      config_drive: no,
67
-      wp_theme: "https://downloads.wordpress.org/theme/iribbon.2.0.65.zip",
68
-      wp_posts: "http://wpcandy.s3.amazonaws.com/resources/postsxml.zip"
67
+      config_drive: no
69 68
     }
70 69
 
71 70
 It's also possible to provide download URL's for wordpress and associated
@@ -75,11 +74,10 @@ outbound network access to the Internet (defaults show below):
75 74
     app_env: {
76 75
       ...
77 76
       wp_latest: 'https://wordpress.org/latest.tar.gz',
78
-      wp_cli: 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar',
79 77
       wp_importer: 'http://downloads.wordpress.org/plugin/wordpress-importer.0.6.3.zip'
80 78
     }
81 79
 
82
-The values of these variables should be provided by your cloud provider. When
80
+The values of the auth section should be provided by your cloud provider. When
83 81
 use keystone 2.0 API, you will not need to setup domain name. You can leave
84 82
 region_name empty if you have just one region. You can also leave
85 83
 private_net_name empty if your cloud does not support tenant network or you
@@ -88,7 +86,11 @@ have multiple tenant networks. validate_certs should be normally set to True
88 86
 when your cloud uses tls(ssl) and your cloud is not using self signed
89 87
 certificate. If your cloud is using self signed certificate, then the
90 88
 certificate can not be easily validated by ansible. You can skip it by setting
91
-the parameter to False.
89
+the parameter to False. currently the only values available for target_os are
90
+ubuntu and fedora. Supported ubuntu releases are 14.04, 15.04, 15.10, 16.04
91
+and 16.10. The wordpress theme and sample content are now provided by
92
+OpenStack foundation. If the test is successful, the OpenStack Superuser
93
+award site should be fully functional.
92 94
 
93 95
 
94 96
 ## Provision the LAMP stack

BIN
workloads/ansible/shade/lampstack/files/wp-cli.phar View File


BIN
workloads/ansible/shade/lampstack/files/wpposts.zip View File


BIN
workloads/ansible/shade/lampstack/files/wptheme.zip View File


+ 6
- 1
workloads/ansible/shade/lampstack/roles/apply/templates/userdata.j2 View File

@@ -1,4 +1,9 @@
1 1
 #cloud-config
2
+packages:
3
+ - python2.7
4
+
2 5
 runcmd:
6
+ - if [ ! -x /usr/bin/python ]; then update-alternatives --install /usr/bin/python python /usr/bin/python2.7 10; fi
3 7
  - addr=$(ip -4 -o addr | grep -v '127.0.0.1' | awk 'NR==1{print $4}' | cut -d '/' -f 1)
4
- - echo $addr `hostname` >> /etc/hosts
8
+ - echo $addr `hostname` >> /etc/hosts
9
+ 

+ 12
- 27
workloads/ansible/shade/lampstack/roles/balancer/tasks/main.yml View File

@@ -1,20 +1,8 @@
1 1
 ---
2 2
 - name: Haproxy install
3 3
   package:
4
-    name="{{ item }}"
5
-    state=latest
6
-    update_cache=yes
7
-  with_items:
8
-    - haproxy
9
-  when: ansible_distribution == 'Ubuntu'
10
-
11
-- name: Haproxy install
12
-  package:
13
-    name="{{ item }}"
14
-    state=latest
15
-  with_items:
16
-    - haproxy
17
-  when: ansible_distribution == 'Fedora'
4
+    name: haproxy
5
+    state: latest
18 6
 
19 7
 - name: Enable haproxy service
20 8
   replace:
@@ -24,21 +12,18 @@
24 12
     backup: no
25 13
   when: ansible_distribution == 'Ubuntu'
26 14
 
27
-- name: Place the haproxy configuration file
28
-  copy:
29
-    src: templates/haproxy.cfg.j2
15
+- name: Modify haproxy configuration
16
+  blockinfile:
30 17
     dest: /etc/haproxy/haproxy.cfg
31
-    owner: root
32
-    group: root
33
-  when: ansible_distribution == 'Ubuntu'
18
+    insertafter: EOF
19
+    block: |
20
+      frontend http-in
21
+          bind *:80
22
+          default_backend backend_servers
23
+          option forwardfor
34 24
 
35
-- name: Place the haproxy configuration file
36
-  copy:
37
-    src: templates/haproxy_fedora.cfg.j2
38
-    dest: /etc/haproxy/haproxy.cfg
39
-    owner: root
40
-    group: root
41
-  when: ansible_distribution == 'Fedora'
25
+      backend backend_servers
26
+          balance     roundrobin
42 27
 
43 28
 - name: Add web servers to the haproxy
44 29
   lineinfile:

+ 0
- 33
workloads/ansible/shade/lampstack/roles/balancer/templates/haproxy.cfg.j2 View File

@@ -1,33 +0,0 @@
1
-global
2
-        log /dev/log    local0
3
-        log /dev/log    local1 notice
4
-        chroot /var/lib/haproxy
5
-        user haproxy
6
-        group haproxy
7
-        daemon
8
-
9
-defaults
10
-        log     global
11
-        mode    http
12
-        option  httplog
13
-        option  dontlognull
14
-        option  redispatch
15
-        retries 3
16
-        contimeout 5000
17
-        clitimeout 50000
18
-        srvtimeout 50000
19
-        errorfile 400 /etc/haproxy/errors/400.http
20
-        errorfile 403 /etc/haproxy/errors/403.http
21
-        errorfile 408 /etc/haproxy/errors/408.http
22
-        errorfile 500 /etc/haproxy/errors/500.http
23
-        errorfile 502 /etc/haproxy/errors/502.http
24
-        errorfile 503 /etc/haproxy/errors/503.http
25
-        errorfile 504 /etc/haproxy/errors/504.http
26
-
27
-listen webfarm 0.0.0.0:80
28
-    mode http
29
-    stats enable
30
-    stats uri /haproxy?stats
31
-    balance roundrobin
32
-    option httpclose
33
-    option forwardfor

+ 0
- 34
workloads/ansible/shade/lampstack/roles/balancer/templates/haproxy_fedora.cfg.j2 View File

@@ -1,34 +0,0 @@
1
-global
2
-        log /dev/log    local0
3
-        log /dev/log    local1 notice
4
-        chroot /var/lib/haproxy
5
-        user haproxy
6
-        group haproxy
7
-        daemon
8
-
9
-defaults
10
-        log     global
11
-        mode    http
12
-        option  httplog
13
-        option  dontlognull
14
-        option  redispatch
15
-        retries 3
16
-        contimeout 5000
17
-        clitimeout 50000
18
-        srvtimeout 50000
19
-        errorfile 400 /usr/share/haproxy/400.http
20
-        errorfile 403 /usr/share/haproxy/403.http
21
-        errorfile 408 /usr/share/haproxy/408.http
22
-        errorfile 500 /usr/share/haproxy/500.http
23
-        errorfile 502 /usr/share/haproxy/502.http
24
-        errorfile 503 /usr/share/haproxy/503.http
25
-        errorfile 504 /usr/share/haproxy/504.http
26
-
27
-listen webfarm
28
-    bind 0.0.0.0:80
29
-    mode http
30
-    stats enable
31
-    stats uri /haproxy?stats
32
-    balance roundrobin
33
-    option httpclose
34
-    option forwardfor

workloads/ansible/shade/lampstack/roles/common/tasks/main.yml → workloads/ansible/shade/lampstack/roles/common/tasks/fedora.yml View File

@@ -3,17 +3,10 @@
3 3
   local_action: wait_for port=22 host="{{ ansible_ssh_host | default(inventory_hostname) }}" search_regex=OpenSSH delay=10
4 4
   become: no
5 5
 
6
-- name: Check if running on Fedora
7
-  raw: "[ -f /etc/fedora-release ]"
8
-  register: fedora_release
9
-  ignore_errors: yes
10
-
11 6
 - name: Install python2 for Ansible
12 7
   raw: dnf install -y python2 python2-dnf libselinux-python
13 8
   register: result
14 9
   until: result|success
15
-  when: fedora_release.rc == 0
16 10
 
17 11
 - name: Set SELinux to permisive
18 12
   selinux: policy=targeted state=permissive
19
-  when: fedora_release.rc == 0

+ 4
- 0
workloads/ansible/shade/lampstack/roles/common/tasks/ubuntu.yml View File

@@ -0,0 +1,4 @@
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

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

@@ -104,6 +104,12 @@
104 104
     - python2-mysql
105 105
   when: ansible_distribution == 'Fedora'
106 106
 
107
+- name: Update MySQL root password for all root accounts
108
+  mysql_user: name=root host={{ item }} password={{ db_pass }} state=present
109
+  with_items:
110
+    - 127.0.0.1
111
+    - localhost
112
+
107 113
 - service: name=mysql state=stopped enabled=yes
108 114
   when: ansible_distribution == 'Ubuntu'
109 115
 
@@ -125,10 +131,11 @@
125 131
   register: mysqlflag
126 132
 
127 133
 - name: Configure mysql 5.6+
128
-  replace:
129
-    dest: "/etc/mysql/mysql.conf.d/mysqld.cnf"
130
-    replace: "bind-address  = {{ local_ip.stdout }}"
131
-    backup: no
134
+  ini_file:
135
+    dest=/etc/mysql/mysql.conf.d/mysqld.cnf
136
+    section=mysqld
137
+    option=bind-address
138
+    value={{ local_ip.stdout }}
132 139
   when: mysqlflag.stat.exists == true
133 140
 
134 141
 - stat: path=/etc/my.cnf
@@ -152,13 +159,17 @@
152 159
   mysql_db:
153 160
     name: "decision2016"
154 161
     state: "{{ item }}"
162
+    login_user: root
163
+    login_password: "{{ db_pass }}"
155 164
   with_items:
156
-    - ['present', 'absent', 'present']
165
+    - ['absent', 'present']
157 166
 
158 167
 - name: Add a user
159 168
   mysql_user:
160 169
     name: "{{ db_user }}"
161 170
     password: "{{ db_pass }}"
171
+    login_user: root
172
+    login_password: "{{ db_pass }}"
162 173
     host: "%"
163 174
     priv: 'decision2016.*:ALL'
164 175
     state: present

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

@@ -8,10 +8,29 @@
8 8
     - apache2
9 9
     - php5
10 10
     - php5-mysql
11
+    - php5-gd
11 12
     - nfs-common
12 13
     - unzip
13 14
     - ssmtp
14
-  when: ansible_distribution == 'Ubuntu'
15
+  when: ansible_distribution == 'Ubuntu' and ansible_distribution_version < '16.04'
16
+
17
+- name: Apache and php 7
18
+  package:
19
+    name="{{ item }}"
20
+    state=latest
21
+    update_cache=yes
22
+  with_items:
23
+    - apache2
24
+    - php7.0
25
+    - php7.0-mysql
26
+    - libapache2-mod-php7.0
27
+    - php7.0-cli
28
+    - php7.0-cgi
29
+    - php7.0-gd
30
+    - nfs-common
31
+    - unzip
32
+    - ssmtp
33
+  when: ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '16.04'
15 34
 
16 35
 - name: Apache and php 5
17 36
   package:
@@ -21,6 +40,7 @@
21 40
     - httpd
22 41
     - php
23 42
     - php-mysqlnd
43
+    - php5-gd
24 44
     - nfs-utils
25 45
     - unzip
26 46
     - ssmtp
@@ -30,9 +50,29 @@
30 50
   args:
31 51
     warn: no
32 52
 
53
+- name: Enable mod_rewrite
54
+  apache2_module: name=rewrite state=present
55
+
56
+- name: Enable htaccess
57
+  blockinfile:
58
+    dest: /etc/apache2/sites-enabled/000-default.conf
59
+    insertafter: "DocumentRoot /var/www/html"
60
+    content: |
61
+      <Directory /var/www/html>
62
+              AllowOverride All
63
+              <IfModule mod_rewrite.c>
64
+                RewriteEngine On
65
+                RewriteBase /
66
+                RewriteRule ^index\.php$ - [L]
67
+                RewriteCond %{REQUEST_FILENAME} !-f
68
+                RewriteCond %{REQUEST_FILENAME} !-d
69
+                RewriteRule . /index.php [L]
70
+              </IfModule>
71
+      </Directory>          
72
+
33 73
 - name: Creates share directory for wpcontent
34 74
   file:
35
-    path: /var/www/html/wp-content/uploads
75
+    path: /var/www/html/wp-content
36 76
     state: directory
37 77
     owner: www-data
38 78
     group: www-data
@@ -40,7 +80,7 @@
40 80
 
41 81
 - name: Creates share directory for wpcontent
42 82
   file:
43
-    path: /var/www/html/wp-content/uploads
83
+    path: /var/www/html/wp-content
44 84
     state: directory
45 85
     owner: apache
46 86
     group: apache
@@ -48,7 +88,7 @@
48 88
 
49 89
 - name: Mount the directory using private IP
50 90
   mount:
51
-    name: /var/www/html/wp-content/uploads
91
+    name: /var/www/html/wp-content
52 92
     src: "{{ hostvars.cloud.database.openstack.private_v4 }}:/storage/wpcontent"
53 93
     state: mounted
54 94
     fstype: nfs
@@ -56,7 +96,7 @@
56 96
 
57 97
 - name: Mount the directory using public IP
58 98
   mount:
59
-    name: /var/www/html/wp-content/uploads
99
+    name: /var/www/html/wp-content
60 100
     src: "{{ hostvars.cloud.database.openstack.public_v4 }}:/storage/wpcontent"
61 101
     state: mounted
62 102
     fstype: nfs
@@ -70,8 +110,9 @@
70 110
 
71 111
 - name: Download wordpress
72 112
   get_url:
73
-    url: "{{ app_env.wp_latest | default('https://wordpress.org/latest.tar.gz') }}"
113
+    url: "{{ app_env.wp_latest | default('https://wordpress.org/wordpress-4.6.1.tar.gz') }}"
74 114
     dest: /var/www/latest.tar.gz
115
+    force: no
75 116
 
76 117
 - name: Unpack latest wordpress
77 118
   shell: tar -xf /var/www/latest.tar.gz -C /var/www/html --strip-components=1
@@ -129,19 +170,8 @@
129 170
   when: ansible_distribution == 'Fedora'
130 171
 
131 172
 - name: Install wordpress command line tool
132
-  get_url:
133
-    url: "{{ app_env.wp_cli | default('https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar') }}"
173
+  copy:
174
+    src: files/wp-cli.phar
134 175
     dest: /usr/local/bin/wp
135 176
     mode: "a+x"
136
-    force: no
137
-
138
-- name: Download a wordpress theme
139
-  get_url:
140
-    url: "{{ app_env.wp_theme }}"
141
-    dest: /tmp/wptheme.zip
142
-    force: yes
143
-
144
-- name: Install the theme
145
-  shell: unzip -o -q /tmp/wptheme.zip -d /var/www/html/wp-content/themes
146
-  args:
147
-    warn: no
177
+    force: no

+ 100
- 0
workloads/ansible/shade/lampstack/roles/wordpress/tasks/fedora.yml View File

@@ -0,0 +1,100 @@
1
+---
2
+- name: Download a wordpress theme
3
+  copy:
4
+    src: files/wptheme.zip
5
+    dest: /tmp/wptheme.zip
6
+    force: no
7
+
8
+- name: Install the theme
9
+  shell: sudo -u apache unzip -o -q /tmp/wptheme.zip -d /var/www/html/wp-content/themes
10
+  args:
11
+    warn: no
12
+
13
+- name: Install wordpress
14
+  command: >
15
+    wp core install --path=/var/www/html
16
+    --url="http://{{ hostvars.cloud.balancer.openstack.public_v4 }}"
17
+    --title='OpenStack Interop Challenge'
18
+    --admin_user=wpuser
19
+    --admin_password="{{ db_pass }}"
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
+
33
+- name: Install package for automated plugin activation
34
+  shell: >
35
+    wp package install itspriddle/wp-cli-tgmpa-plugin
36
+
37
+- name: Make an initial request, so that later switch-theme hooks work.
38
+  shell: >
39
+    sudo -u apache wp --path=/var/www/html
40
+    cron test
41
+
42
+- name: Activate wordpress theme
43
+  command: >
44
+    wp --path=/var/www/html theme activate superuser
45
+
46
+- name: Install and activate required plugins
47
+  shell: >
48
+    sudo -u apache wp --path=/var/www/html
49
+    tgmpa-plugin install --all-required --activate
50
+  args:
51
+    warn: no
52
+
53
+- name: Download wordpress importer plugin
54
+  get_url:
55
+    url: "{{ app_env.wp_importer | default('http://downloads.wordpress.org/plugin/wordpress-importer.0.6.3.zip') }}"
56
+    dest: "/tmp/wordpress-importer.zip"
57
+    force: "yes"
58
+
59
+- name: Install wordpress importer plugin
60
+  command: >
61
+    sudo -u apache wp --path=/var/www/html plugin install /tmp/wordpress-importer.zip --activate
62
+  args:
63
+    warn: "no"
64
+
65
+- name: Create temporary post directory
66
+  file:
67
+    path: /tmp/posts
68
+    state: directory
69
+    mode: "u=rwx,g=rwx,o=rx"
70
+
71
+- name: Unpack the posts
72
+  unarchive:
73
+    src: files/wpposts.zip
74
+    dest: /tmp/posts
75
+    remote_src: no
76
+
77
+- name: Wait for the posts to be unpacked
78
+  wait_for:
79
+    path: /tmp/posts
80
+    state: present
81
+
82
+- name: Import wordpress posts
83
+  command: >
84
+    wp --path=/var/www/html import /tmp/posts/superuser_content.xml --authors=create --quiet
85
+
86
+- name: Regenerate thumbnails for the imported posts
87
+  shell: >
88
+    sudo -u apache wp --path=/var/www/html media regenerate --yes --quiet
89
+
90
+- name: Trigger post-activation hooks
91
+  shell: >
92
+    sudo -u apache wp --path=/var/www/html
93
+    cron test
94
+
95
+- name: Flush rewrite rules, setup htaccess for nice permalinks
96
+  shell: >
97
+    sudo -u apache
98
+    WP_CLI_CONFIG_PATH=/var/www/html/wp-content/themes/superuser/wp-cli.yml
99
+    wp --path=/var/www/html
100
+    rewrite flush --hard

+ 0
- 73
workloads/ansible/shade/lampstack/roles/wordpress/tasks/main.yml View File

@@ -1,73 +0,0 @@
1
----
2
-- name: Install wordpress
3
-  command: >
4
-    wp core install --path=/var/www/html
5
-    --url="http://{{ hostvars.cloud.balancer.openstack.public_v4 }}"
6
-    --title='OpenStack Interop Challenge'
7
-    --admin_user=wpuser
8
-    --admin_password="{{ db_pass }}"
9
-    --admin_email='interop@openstack.org'
10
-  when: hostvars.cloud.balancer.openstack.public_v4 != ""
11
-
12
-- name: Install wordpress
13
-  command: >
14
-    wp core install --path=/var/www/html
15
-    --url="http://{{ hostvars.cloud.balancer.openstack.private_v4 }}"
16
-    --title='OpenStack Interop Challenge'
17
-    --admin_user=wpuser
18
-    --admin_password="{{ db_pass }}"
19
-    --admin_email='interop@openstack.org'
20
-  when: hostvars.cloud.balancer.openstack.public_v4 == ""
21
-
22
-- name: Activate wordpress theme
23
-  command: >
24
-    wp --path=/var/www/html theme activate
25
-    "{{ app_env.wp_theme.split('/').pop().split('.')[0] }}"
26
-
27
-- name: Download wordpress importer plugin
28
-  get_url:
29
-    url: "{{ app_env.wp_importer | default('http://downloads.wordpress.org/plugin/wordpress-importer.0.6.3.zip') }}"
30
-    dest: "/tmp/wordpress-importer.zip"
31
-    force: "yes"
32
-
33
-- name: Install wordpress importer plugin
34
-  command: >
35
-    sudo -u www-data wp --path=/var/www/html plugin install /tmp/wordpress-importer.zip --activate
36
-  args:
37
-    warn: "no"
38
-  when: ansible_distribution == 'Ubuntu'
39
-
40
-- name: Install wordpress importer plugin
41
-  command: >
42
-    sudo -u apache /usr/local/bin/wp --path=/var/www/html plugin install /tmp/wordpress-importer.zip
43
-  args:
44
-    warn: "no"
45
-  when: ansible_distribution == 'Fedora'
46
-
47
-- name: Enable wordpress importer plugin
48
-  command: >
49
-    sudo -u apache /usr/local/bin/wp --path=/var/www/html plugin activate wordpress-importer
50
-  args:
51
-    warn: "no"
52
-  when: ansible_distribution == 'Fedora'
53
-
54
-- name: Download wordpress sample posts
55
-  get_url:
56
-    url: "{{ app_env.wp_posts }}"
57
-    dest: "/tmp/wpposts.zip"
58
-    force: "yes"
59
-
60
-- name: Unpack the posts
61
-  command: unzip -o -q /tmp/wpposts.zip -d /tmp/posts
62
-  args:
63
-    warn: "no"
64
-
65
-- name: Import wordpress posts
66
-  command: >
67
-    sudo -u www-data wp --path=/var/www/html import /tmp/posts/*.xml --authors=create --quiet
68
-  when: ansible_distribution == 'Ubuntu'
69
-
70
-- name: Import wordpress posts
71
-  shell: >
72
-    sudo -u apache /usr/local/bin/wp --path=/var/www/html import /tmp/posts/*.xml --authors=create --quiet
73
-  when: ansible_distribution == 'Fedora'

+ 100
- 0
workloads/ansible/shade/lampstack/roles/wordpress/tasks/ubuntu.yml View File

@@ -0,0 +1,100 @@
1
+---
2
+- name: Download a wordpress theme
3
+  copy:
4
+    src: files/wptheme.zip
5
+    dest: /tmp/wptheme.zip
6
+    force: no
7
+
8
+- name: Install the theme
9
+  shell: sudo -u www-data unzip -o -q /tmp/wptheme.zip -d /var/www/html/wp-content/themes
10
+  args:
11
+    warn: no
12
+
13
+- name: Install wordpress
14
+  command: >
15
+    wp core install --path=/var/www/html
16
+    --url="http://{{ hostvars.cloud.balancer.openstack.public_v4 }}"
17
+    --title='OpenStack Interop Challenge'
18
+    --admin_user=wpuser
19
+    --admin_password="{{ db_pass }}"
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
+
33
+- name: Install package for automated plugin activation
34
+  shell: >
35
+    wp package install itspriddle/wp-cli-tgmpa-plugin
36
+
37
+- name: Make an initial request, so that later switch-theme hooks work.
38
+  shell: >
39
+    sudo -u www-data wp --path=/var/www/html
40
+    cron test
41
+
42
+- name: Activate wordpress theme
43
+  command: >
44
+    wp --path=/var/www/html theme activate superuser
45
+
46
+- name: Install and activate required plugins
47
+  shell: >
48
+    sudo -u www-data wp --path=/var/www/html
49
+    tgmpa-plugin install --all-required --activate
50
+  args:
51
+    warn: no
52
+
53
+- name: Download wordpress importer plugin
54
+  get_url:
55
+    url: "{{ app_env.wp_importer | default('http://downloads.wordpress.org/plugin/wordpress-importer.0.6.3.zip') }}"
56
+    dest: "/tmp/wordpress-importer.zip"
57
+    force: "yes"
58
+
59
+- name: Install wordpress importer plugin
60
+  command: >
61
+    sudo -u www-data wp --path=/var/www/html plugin install /tmp/wordpress-importer.zip --activate
62
+  args:
63
+    warn: "no"
64
+
65
+- name: Create temporary post directory
66
+  file:
67
+    path: /tmp/posts
68
+    state: directory
69
+    mode: "u=rwx,g=rwx,o=rx"
70
+
71
+- name: Unpack the posts
72
+  unarchive:
73
+    src: files/wpposts.zip
74
+    dest: /tmp/posts
75
+    remote_src: no
76
+
77
+- name: Wait for the posts to be unpacked
78
+  wait_for:
79
+    path: /tmp/posts
80
+    state: present
81
+
82
+- name: Import wordpress posts
83
+  command: >
84
+    wp --path=/var/www/html import /tmp/posts/superuser_content.xml --authors=create --quiet
85
+
86
+- name: Regenerate thumbnails for the imported posts
87
+  shell: >
88
+    sudo -u www-data wp --path=/var/www/html media regenerate --yes --quiet
89
+
90
+- name: Trigger post-activation hooks
91
+  shell: >
92
+    sudo -u www-data wp --path=/var/www/html
93
+    cron test
94
+
95
+- name: Flush rewrite rules, setup htaccess for nice permalinks
96
+  shell: >
97
+    sudo -u www-data
98
+    WP_CLI_CONFIG_PATH=/var/www/html/wp-content/themes/superuser/wp-cli.yml
99
+    wp --path=/var/www/html
100
+    rewrite flush --hard

+ 14
- 1
workloads/ansible/shade/lampstack/site.yml View File

@@ -6,18 +6,22 @@
6 6
     - "vars/{{ env }}.yml"
7 7
   roles:
8 8
     - "{{ action }}"
9
+  tags: "{{ action }}"
9 10
 
10 11
 - name: Install python2 for ansible to work
11
-  hosts: dbservers, webservers, balancers, wps
12
+  hosts: dbservers, webservers, balancers
12 13
   gather_facts: false
13 14
   user: "{{ app_env.ssh_user }}"
14 15
   become: true
15 16
   become_user: root
16 17
   vars_files:
17 18
     - "vars/{{ env }}.yml"
19
+  tasks:
20
+    - include: "roles/common/tasks/{{ app_env.target_os }}.yml"
18 21
   roles:
19 22
     - common
20 23
   environment: "{{ proxy_env }}"
24
+  tags: "common"
21 25
 
22 26
 - name: setup database
23 27
   hosts: dbservers
@@ -29,9 +33,11 @@
29 33
   roles:
30 34
     - database
31 35
   environment: "{{proxy_env}}"
36
+  tags: "database"
32 37
 
33 38
 - name: setup web servers
34 39
   hosts: webservers
40
+  gather_facts: true
35 41
   user: "{{ app_env.ssh_user }}"
36 42
   become: true
37 43
   become_user: root
@@ -40,6 +46,7 @@
40 46
   roles:
41 47
     - webserver
42 48
   environment: "{{proxy_env}}"
49
+  tags: "webserver"
43 50
 
44 51
 - name: setup load balancer servers
45 52
   hosts: balancers
@@ -51,15 +58,19 @@
51 58
   roles:
52 59
     - balancer
53 60
   environment: "{{proxy_env}}"
61
+  tags: "balancer"
54 62
 
55 63
 - name: install wordpress
56 64
   hosts: wps
57 65
   user: "{{ app_env.ssh_user }}"
58 66
   vars_files:
59 67
     - "vars/{{ env }}.yml"
68
+  tasks:
69
+    - include: "roles/wordpress/tasks/{{ app_env.target_os }}.yml"
60 70
   roles:
61 71
     - wordpress
62 72
   environment: "{{proxy_env}}"
73
+  tags: "wordpress"
63 74
 
64 75
 - name: clean up resources
65 76
   hosts: cloud
@@ -71,6 +82,7 @@
71 82
   roles:
72 83
     - cleaner
73 84
   environment: "{{proxy_env}}"
85
+  tags: "cleaner"
74 86
 
75 87
 - name: Inform the installer
76 88
   hosts: cloud
@@ -94,3 +106,4 @@
94 106
         msg: >-
95 107
           The work load test started at {{ hostvars.cloud.starttime.time }},
96 108
           ended at {{ ansible_date_time.time }}
109
+  tags: "info"

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

@@ -9,8 +9,9 @@ auth: {
9 9
 }
10 10
 
11 11
 app_env: {
12
+  target_os: "ubuntu",
12 13
   ssh_user: "ubuntu",
13
-  image_name: "ubuntu-15.04",
14
+  image_name: "ubuntu-16.10",
14 15
   region_name: "",
15 16
   availability_zone: "",
16 17
   validate_certs: True,
@@ -20,6 +21,6 @@ app_env: {
20 21
   stack_size: 4,
21 22
   volume_size: 10,
22 23
   block_device_name: "/dev/vdb",
23
-  wp_theme: "https://downloads.wordpress.org/theme/iribbon.2.0.65.zip",
24
-  wp_posts: "http://wpcandy.s3.amazonaws.com/resources/postsxml.zip"
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"
25 26
 }

+ 2
- 3
workloads/ansible/shade/lampstack/vars/dreamhost.yml View File

@@ -9,6 +9,7 @@ auth: {
9 9
 }
10 10
 
11 11
 app_env: {
12
+  target_os: "ubuntu",
12 13
   ssh_user: "ubuntu",
13 14
   region_name: "RegionOne",
14 15
   image_name: "Ubuntu-14.04",
@@ -19,7 +20,5 @@ app_env: {
19 20
   public_key_file: "/home/reed/.ssh/id_rsa.pub",
20 21
   stack_size: 4,
21 22
   volume_size: 10,
22
-  block_device_name: "/dev/vdb",
23
-  wp_theme: "https://downloads.wordpress.org/theme/iribbon.2.0.65.zip",
24
-  wp_posts: "http://wpcandy.s3.amazonaws.com/resources/postsxml.zip"
23
+  block_device_name: "/dev/vdb"
25 24
 }

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

@@ -10,17 +10,17 @@ auth: {
10 10
 }
11 11
 
12 12
 app_env: {
13
-  image_name: "ubuntu-15.04",
13
+  target_os: "ubuntu",
14
+  image_name: "ubuntu-14.04",
14 15
   region_name: "RegionOne",
15 16
   availability_zone: "nova",
16 17
   validate_certs: False,
17 18
   ssh_user: "ubuntu",
18
-  private_net_name: "Bluebox",
19
-  flavor_name: "m1.small",
20
-  public_key_file: "/home/tong/.ssh/id_rsa.pub",
19
+  private_net_name: "demonet",
20
+  flavor_name: "m1.large",
21
+  public_key_file: "/home/ubuntu/.ssh/id_rsa.pub",
21 22
   stack_size: 4,
22 23
   volume_size: 2,
23 24
   block_device_name: "/dev/vdb",
24
-  wp_theme: "https://downloads.wordpress.org/theme/iribbon.2.0.65.zip",
25
-  wp_posts: "http://wpcandy.s3.amazonaws.com/resources/postsxml.zip"
25
+  wp_latest: "https://wordpress.org/wordpress-4.6.tar.gz"
26 26
 }

+ 2
- 3
workloads/ansible/shade/lampstack/vars/osic.yml View File

@@ -10,6 +10,7 @@ auth: {
10 10
 }
11 11
 
12 12
 app_env: {
13
+  target_os: "ubuntu",
13 14
   image_name: "ubuntu-server-14.04",
14 15
   region_name: "",
15 16
   availability_zone: "nova",
@@ -19,7 +20,5 @@ app_env: {
19 20
   public_key_file: "/home/tong/.ssh/id_rsa.pub",
20 21
   stack_size: 4,
21 22
   volume_size: 2,
22
-  block_device_name: "/dev/vdb",
23
-  wp_theme: "https://downloads.wordpress.org/theme/iribbon.2.0.65.zip",
24
-  wp_posts: "http://wpcandy.s3.amazonaws.com/resources/postsxml.zip"
23
+  block_device_name: "/dev/vdb"
25 24
 }

+ 2
- 3
workloads/ansible/shade/lampstack/vars/otc.yml View File

@@ -8,6 +8,7 @@ auth: {
8 8
 }
9 9
 
10 10
 app_env: {
11
+  target_os: "ubuntu",
11 12
   image_name: "Community_Ubuntu_14.04_TSI_20161004_0",
12 13
   region_name: "",
13 14
   availability_zone: "eu-de-01",
@@ -18,7 +19,5 @@ app_env: {
18 19
   ssh_user: "ubuntu",
19 20
   stack_size: 4,
20 21
   volume_size: 2,
21
-  block_device_name: "/dev/xvdb",
22
-  wp_theme: "https://downloads.wordpress.org/theme/iribbon.2.0.65.zip",
23
-  wp_posts: "http://wpcandy.s3.amazonaws.com/resources/postsxml.zip"
22
+  block_device_name: "/dev/xvdb"
24 23
 }

+ 2
- 3
workloads/ansible/shade/lampstack/vars/ovh.yml View File

@@ -9,6 +9,7 @@ auth: {
9 9
 }
10 10
 
11 11
 app_env: {
12
+  target_os: "ubuntu",
12 13
   ssh_user: "ubuntu",
13 14
   region_name: "SBG1",
14 15
   image_name: "Ubuntu 14.04",
@@ -19,7 +20,5 @@ app_env: {
19 20
   public_key_file: "/home/ubuntu/.ssh/id_rsa.pub",
20 21
   stack_size: 4,
21 22
   volume_size: 4,
22
-  block_device_name: "/dev/vdb",
23
-  wp_theme: "https://downloads.wordpress.org/theme/iribbon.2.0.65.zip",
24
-  wp_posts: "http://wpcandy.s3.amazonaws.com/resources/postsxml.zip"
23
+  block_device_name: "/dev/vdb"
25 24
 }

+ 2
- 3
workloads/ansible/shade/lampstack/vars/trystack.yml View File

@@ -25,6 +25,7 @@ auth: {
25 25
 }
26 26
 
27 27
 app_env: {
28
+  target_os: "ubuntu",
28 29
   ssh_user: "ubuntu",
29 30
   image_name: "ubuntu1404",
30 31
   region_name: "regionOne",
@@ -35,7 +36,5 @@ app_env: {
35 36
   public_key_file: "/root/.ssh/id_rsa.pub",
36 37
   stack_size: 4,
37 38
   volume_size: 2,
38
-  block_device_name: "/dev/vdb",
39
-  wp_theme: "https://downloads.wordpress.org/theme/iribbon.2.0.65.zip",
40
-  wp_posts: "http://wpcandy.s3.amazonaws.com/resources/postsxml.zip"
39
+  block_device_name: "/dev/vdb"
41 40
 }

Loading…
Cancel
Save