Newer
Older
---
# WP Configuration for MU

Maarten de Waard
committed
- name: Set content directory variable in wp-config
shell: wp {{ cli_args }} config set 'WP_CONTENT_DIR' "ABSPATH . 'wp-content'" --raw --type=constant

Maarten de Waard
committed
- name: Set MU plugins directory in wp-config
shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "ABSPATH . 'wp-content/{{ WP_MU_PLUGINS_DIR }}'" --raw --type=constant

Maarten de Waard
committed
- name: Set content url variable in wp-config
shell: wp {{ cli_args }} config set 'WP_CONTENT_URL' "'{{ WP_URL }}/wp-content'" --raw --type=constant

Maarten de Waard
committed
- name: Set MU plugins url in wp-config
shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_URL' "'{{ WP_URL }}/wp-content/mu-plugins'" --raw --type=constant
# MU plugins directory and loader
- name: Add a MU plugins directory when WP_MU_PLUGINS_DIR is set
file:
path: "{{ WP_CONTENT_MOUNT }}/{{ WP_MU_PLUGINS_DIR }}"
mode: 0750
state: directory
- name: Fetch and unzip plugins in-place
shell: curl -L {{ wp_mu_plugin.url }} | unzip -q -o -d {{ WP_CONTENT_MOUNT }}/{{ WP_MU_PLUGINS_DIR }} -

Maarten de Waard
committed
loop: "{{ WP_MU_PLUGINS }}"
loop_control:
loop_var: wp_mu_plugin
- name: Insert the base code into MU plugins load.php file
lineinfile:
dest: "{{ WP_CONTENT_MOUNT }}/{{ WP_MU_PLUGINS_DIR }}/load.php"
line: "<?php // {{ WP_MU_PLUGINS_DIR }}/load.php"
create: yes
- name: Echo all the MU plugins filenames into the load.php file
lineinfile:
dest: "{{ WP_CONTENT_MOUNT }}/{{ WP_MU_PLUGINS_DIR }}/load.php"
line: "require(WPMU_PLUGIN_DIR . '/{{ wp_mu_plugin.path }}/{{ wp_mu_plugin.phpfile }}');"
loop_control:
loop_var: wp_mu_plugin

Maarten de Waard
committed
### Install wp-cron as mu
- name: Set mu_cron salt value
shell: wp {{ cli_args }} config set 'WP_CRON_CONTROL_SECRET' "{{ WP_MU_CRON_SETTINGS.secret }}" --add --type=constant
when: WP_MU_CRON_ENABLED
- name: Shallow clone from the github repository
git:
repo: "{{ WP_MU_CRON_SETTINGS.repo}}"
dest: "{{ WP_CONTENT_MOUNT }}/{{ WP_MU_PLUGINS_DIR }}/{{ WP_MU_CRON_SETTINGS.path }}"
force: yes
depth: 1
version: "{{ WP_MU_CRON_SETTINGS.version}}"
when: WP_MU_CRON_ENABLED
- name: Append cron control plugin filename to the load.php file
lineinfile:
dest: "{{ WP_CONTENT_MOUNT }}/{{ WP_MU_PLUGINS_DIR }}/load.php"
line: "require(WPMU_PLUGIN_DIR . '/{{ WP_MU_CRON_SETTINGS.path }}/{{ WP_MU_CRON_SETTINGS.phpfile}}');"
insertbefore: EOF
when: WP_MU_CRON_ENABLED
- name: Switch off wordpress native cron
shell: wp {{ cli_args }} config set DISABLE_WP_CRON true --add --raw --type=constant