-
-
Notifications
You must be signed in to change notification settings - Fork 605
/
Copy pathmain.yml
71 lines (64 loc) · 3.14 KB
/
main.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
---
- include: directories.yml
tags: wordpress-install-directories
- name: Create .env file
template:
src: "env.j2"
dest: "/tmp/{{ item.key }}.env"
owner: "{{ web_user }}"
group: "{{ web_group }}"
with_dict: "{{ wordpress_sites }}"
- name: Copy .env file into web root
command: rsync -ac --info=NAME /tmp/{{ item.key }}.env {{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/.env
with_dict: "{{ wordpress_sites }}"
register: env_file
changed_when: env_file.stdout == "{{ item.key }}.env"
- name: Install Dependencies with Composer
command: composer install
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
register: composer_results
with_dict: "{{ wordpress_sites }}"
changed_when: "'Nothing to install or update' not in composer_results.stderr"
- name: Install WP
command: wp core install
--allow-root
--url="{{ site_env.wp_home }}"
--title="{{ item.value.site_title | default(item.key) }}"
--admin_user="{{ item.value.admin_user | default('admin') }}"
--admin_password="{{ vault_wordpress_sites[item.key].admin_password }}"
--admin_email="{{ item.value.admin_email }}"
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
register: wp_install_results
with_dict: "{{ wordpress_sites }}"
when: item.value.site_install | default(true) and not item.value.multisite.enabled | default(false)
changed_when: "'WordPress is already installed.' not in wp_install_results.stdout"
- name: Install WP Multisite
command: wp core multisite-install
--allow-root
--url="{{ site_env.wp_home }}"
--base="{{ item.value.multisite.base_path | default('/') }}"
--subdomains="{{ item.value.multisite.subdomains | default('false') }}"
--title="{{ item.value.site_title | default(item.key) }}"
--admin_user="{{ item.value.admin_user | default('admin') }}"
--admin_password="{{ vault_wordpress_sites[item.key].admin_password }}"
--admin_email="{{ item.value.admin_email }}"
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
register: wp_install_results
with_dict: "{{ wordpress_sites }}"
when: item.value.site_install | default(true) and item.value.multisite.enabled | default(false)
changed_when: "'The network already exists.' not in wp_install_results.stdout"
- name: Setup Permalink Structure
command: wp rewrite structure {{ item.value.initial_permalink_structure | default("/%postname%/") }} --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
when: wp_install_results | changed
- name: Update WP Multisite Home URL
command: wp option update home {{ site_env.wp_home }} --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
when: item.value.site_install | default(true) and item.value.multisite.enabled | default(false)