This repository has been archived by the owner on Oct 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathwordpress.yml
78 lines (68 loc) · 2.02 KB
/
wordpress.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
- hosts: all
become: true
vars:
apache_user: www-data
apache_group: "{{ apache_user }}"
wp_install_dir: /usr/share/wordpress
wp_content_dir: "{{ wp_install_dir }}/wp-content"
pre_tasks:
- name: Wait until boot finished
wait_for:
path: /var/lib/cloud/instance/boot-finished
state: present
- name: Wait for automatic system updates
become: yes
shell: while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do sleep 1; done;
- name: wait 10 seconds
wait_for:
timeout: 10
- name: Update apt/dpkg cache
apt:
update_cache: yes
- name: wait 5 seconds
wait_for:
timeout: 5
tasks:
# based on
# https://groups.google.com/d/msg/ansible-project/iIcXrvyNysU/Pej62thzLfIJ
- name: Check for required variables
fail:
msg: Variable '{{ item }}' is not defined
when: item not in hostvars[inventory_hostname] or hostvars[inventory_hostname][item] == ""
with_items:
- db_host
- db_name
- db_user
- db_pass
# https://help.ubuntu.com/lts/serverguide/wordpress.html
- name: Install WordPress
apt:
name:
- python-mysqldb
- wordpress
- name: Configure WordPress
template:
src: config.php
# https://superuser.com/a/559371/102684
dest: /etc/wordpress/config-default.php
owner: "{{ apache_user }}"
group: "{{ apache_group }}"
# https://help.ubuntu.com/community/WordPress#Install_WordPress
- name: Fix permissions on WordPress directory
file:
path: "{{ wp_install_dir }}"
owner: "{{ apache_user }}"
group: "{{ apache_group }}"
state: directory
recurse: true
- name: Configure Apache
template:
src: wordpress.conf
dest: /etc/apache2/sites-available/wordpress.conf
- name: Enable WordPress in Apache
command: a2ensite wordpress
- name: Restart Apache
systemd:
name: apache2
state: restarted