From 9340848beb4c1346e5e20f24c1aedc1812039d15 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Fri, 20 Mar 2020 13:09:48 +0000 Subject: [PATCH 01/28] Added mu file structure Added mu tasks main Sketch of cron crontrol --- values.yaml | 1 + .../roles/wordpress-mu/tasks/main.yml | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 wp-cli-docker/roles/wordpress-mu/tasks/main.yml diff --git a/values.yaml b/values.yaml index 11d458d..0119608 100644 --- a/values.yaml +++ b/values.yaml @@ -144,6 +144,7 @@ ansibleVars: special_files: "[index.php, .htaccess]" ## Plugins + wordpress_mu_plugins: "[block-bad-queries]" wordpress_default_plugins: "[block-bad-queries, wps-hide-login]" # - flush-opcache # - logbook diff --git a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml b/wp-cli-docker/roles/wordpress-mu/tasks/main.yml new file mode 100644 index 0000000..469f8e6 --- /dev/null +++ b/wp-cli-docker/roles/wordpress-mu/tasks/main.yml @@ -0,0 +1,68 @@ +--- + +# WP Environment + +- name: Set content directory variable in wp-config + shell: wp {{ cli_args }} config set 'WP_CONTENT_DIR' "ABSPATH . 'wp-content'" --raw --type=constant + +- name: Set MU plugins directory in wp-config + shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "WP_CONTENT_DIR . '/mu-plugins'" --raw --type=constant + +# MU plugins directory and loader + +- name: Add a MU plugins directory + file: + path: "{{ wordpress_homedir }}/wp-content/mu-plugins" + mode: 0750 + owner: {{ wp_user }} + group: {{ wp_group }} + state: directory + +- name: Add MU plugins load.php file + file: + path: {{ wordpress_homedir }}/wp-content/mu-plugins/load.php + owner: {{ wp_user }} + group: {{ wp_group }} + mode: 0640 + +- name: Insert the base code into MU plugins load.php file + lineinfile: + dest: {{ wordpress_homedir }}/wp-content/mu-plugins/load.php + line: " Date: Fri, 20 Mar 2020 15:16:25 +0000 Subject: [PATCH 02/28] Cron crontrol in tasks MU plugins in values MU cron in values --- values.yaml | 11 +++++++- .../roles/wordpress-mu/tasks/main.yml | 26 +++++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/values.yaml b/values.yaml index 0119608..e0dd75d 100644 --- a/values.yaml +++ b/values.yaml @@ -144,12 +144,21 @@ ansibleVars: special_files: "[index.php, .htaccess]" ## Plugins - wordpress_mu_plugins: "[block-bad-queries]" wordpress_default_plugins: "[block-bad-queries, wps-hide-login]" # - flush-opcache # - logbook # - wp-cron-control + wordpress_mu_plugins: + block-bad-queries: + name: Block Bad Queries + version: 20191109 + phpfile: block-bad-queries.php + redis-cache: + name: Redis Cache + version: 1.5.6 + phpfile: redis-cache.php + wpSalts: {} image: diff --git a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml b/wp-cli-docker/roles/wordpress-mu/tasks/main.yml index 469f8e6..1b2e4f7 100644 --- a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml +++ b/wp-cli-docker/roles/wordpress-mu/tasks/main.yml @@ -12,7 +12,7 @@ - name: Add a MU plugins directory file: - path: "{{ wordpress_homedir }}/wp-content/mu-plugins" + path: {{ wordpress_homedir }}/wp-content/mu-plugins mode: 0750 owner: {{ wp_user }} group: {{ wp_group }} @@ -27,42 +27,42 @@ - name: Insert the base code into MU plugins load.php file lineinfile: - dest: {{ wordpress_homedir }}/wp-content/mu-plugins/load.php + dest: "{{ wordpress_homedir }}/wp-content/mu-plugins/load.php" line: " Date: Fri, 20 Mar 2020 17:29:40 +0000 Subject: [PATCH 03/28] Add the mu role to wpdeploy,yml --- wp-cli-docker/wpdeploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/wp-cli-docker/wpdeploy.yml b/wp-cli-docker/wpdeploy.yml index 380dc0e..2e0e6ba 100644 --- a/wp-cli-docker/wpdeploy.yml +++ b/wp-cli-docker/wpdeploy.yml @@ -2,3 +2,4 @@ hosts: localhost roles: - wordpress-init + - wordpress-mu -- GitLab From 416c8e47ee63b395a17c9a8d0a553540d401d3c2 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Mon, 23 Mar 2020 12:46:15 +0000 Subject: [PATCH 04/28] Add defined to wp-deploy --- values.yaml | 3 +++ wp-cli-docker/roles/wordpress-mu/tasks/main.yml | 12 ++++++++---- wp-cli-docker/wpdeploy.yml | 4 ++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/values.yaml b/values.yaml index e0dd75d..e4e0fe5 100644 --- a/values.yaml +++ b/values.yaml @@ -149,6 +149,9 @@ ansibleVars: # - logbook # - wp-cron-control + ## The directory for mu plugins eg: 'mu-plugins' maps to wp-content/mu-plugins + wordpress_mudir: mu-plugins + wordpress_mu_plugins: block-bad-queries: name: Block Bad Queries diff --git a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml b/wp-cli-docker/roles/wordpress-mu/tasks/main.yml index 1b2e4f7..821ba0d 100644 --- a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml +++ b/wp-cli-docker/roles/wordpress-mu/tasks/main.yml @@ -5,12 +5,17 @@ - name: Set content directory variable in wp-config shell: wp {{ cli_args }} config set 'WP_CONTENT_DIR' "ABSPATH . 'wp-content'" --raw --type=constant +- name: Create the mu-plugins directory if it does not exist + file: + + - name: Set MU plugins directory in wp-config - shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "WP_CONTENT_DIR . '/mu-plugins'" --raw --type=constant + shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "WP_CONTENT_DIR . '/{{ wordpress_mudir }}'" --raw --type=constant + # MU plugins directory and loader -- name: Add a MU plugins directory +- name: Add a MU plugins directory when wordpress_mudir is set file: path: {{ wordpress_homedir }}/wp-content/mu-plugins mode: 0750 @@ -51,7 +56,7 @@ insertbefore: EOF with_items: wordpress_mu_plugins -### Install wp-cron +### Install wp-cron as mu - name: Shallow clone from the github repository git: @@ -65,4 +70,3 @@ dest: "{{ wordpress_homedir }}/wp-content/mu-plugins/load.php" line: "require(WPMU_PLUGIN_DIR . '/{{ wordpress_mu_cron.key }}/{{ wordpress_mu_cron.value.phpfile}}');" insertbefore: EOF - diff --git a/wp-cli-docker/wpdeploy.yml b/wp-cli-docker/wpdeploy.yml index 2e0e6ba..8be2a9c 100644 --- a/wp-cli-docker/wpdeploy.yml +++ b/wp-cli-docker/wpdeploy.yml @@ -3,3 +3,7 @@ roles: - wordpress-init - wordpress-mu + when: ++ - wordpress_mudir is defined ++ - wordpress_mu_plugins is defined + -- GitLab From 61cdb0359b07e931305c2d298d6e3eee386ca68d Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Mon, 23 Mar 2020 13:34:41 +0000 Subject: [PATCH 05/28] Better cron and conditional --- values-local.yaml.example | 24 ++++++++++++++ values.yaml | 12 ++++++- .../roles/wordpress-mu/tasks/main.yml | 32 ++++++++++--------- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/values-local.yaml.example b/values-local.yaml.example index d36ff26..bc6dfb2 100644 --- a/values-local.yaml.example +++ b/values-local.yaml.example @@ -57,6 +57,30 @@ wordpress: Require all granted + ## Detailed list of mu values and plugins with versions + ## mu_dir 'mu-plugins' maps to wp-content/mu-plugins + ## mu_plugins are installed as hidden and cannot be updated from the UI + ## mu_cron is an externally triggered cron + + wordpress_mu_dir: mu-plugins + wordpress_mu_plugins: + block-bad-queries: + name: Block Bad Queries + version: 20191109 + phpfile: block-bad-queries.php + redis-cache: + name: Redis Cache + version: 1.5.6 + phpfile: redis-cache.php + + wordpress_mu_cron_enabled: true + wordpress_mu_cron: + name: Cron Control + repo: https://github.com/Automattic/Cron-Control.git + slug: cron-control + version: master + phpfile: wp-cron-control.php + # These settings make sense to overwrite if you want to use the OpenID connect # plugin openid_connect_settings: diff --git a/values.yaml b/values.yaml index e4e0fe5..c7cb641 100644 --- a/values.yaml +++ b/values.yaml @@ -152,6 +152,7 @@ ansibleVars: ## The directory for mu plugins eg: 'mu-plugins' maps to wp-content/mu-plugins wordpress_mudir: mu-plugins + ## Detailed list of mu plugins and versions eg: 'mu-plugins' maps to wp-content/mu-plugins wordpress_mu_plugins: block-bad-queries: name: Block Bad Queries @@ -161,7 +162,16 @@ ansibleVars: name: Redis Cache version: 1.5.6 phpfile: redis-cache.php - + + wordpress_mu_cron_enabled: true + wordpress_mu_cron: + name: Cron Control + repo: https://github.com/Automattic/Cron-Control.git + slug: cron-control + version: master + phpfile: wp-cron-control.php + + wpSalts: {} image: diff --git a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml b/wp-cli-docker/roles/wordpress-mu/tasks/main.yml index 821ba0d..2d9ded9 100644 --- a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml +++ b/wp-cli-docker/roles/wordpress-mu/tasks/main.yml @@ -5,10 +5,6 @@ - name: Set content directory variable in wp-config shell: wp {{ cli_args }} config set 'WP_CONTENT_DIR' "ABSPATH . 'wp-content'" --raw --type=constant -- name: Create the mu-plugins directory if it does not exist - file: - - - name: Set MU plugins directory in wp-config shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "WP_CONTENT_DIR . '/{{ wordpress_mudir }}'" --raw --type=constant @@ -17,7 +13,7 @@ - name: Add a MU plugins directory when wordpress_mudir is set file: - path: {{ wordpress_homedir }}/wp-content/mu-plugins + path: {{ wordpress_homedir }}/wp-content/{{ wordpress_mudir }} mode: 0750 owner: {{ wp_user }} group: {{ wp_group }} @@ -25,15 +21,15 @@ - name: Add MU plugins load.php file file: - path: {{ wordpress_homedir }}/wp-content/mu-plugins/load.php + path: {{ wordpress_homedir }}/wp-content/{{ wordpress_mudir }}/load.php owner: {{ wp_user }} group: {{ wp_group }} mode: 0640 - name: Insert the base code into MU plugins load.php file lineinfile: - dest: "{{ wordpress_homedir }}/wp-content/mu-plugins/load.php" - line: " Date: Tue, 24 Mar 2020 15:59:47 +0000 Subject: [PATCH 06/28] MU plugins and cron are an included task --- install.original | 8 ++++ values-local.yaml.example | 9 +++-- values.yaml | 38 ++++++++++-------- .../roles/wordpress-init/tasks/main.yml | 3 ++ .../tasks/mu-plugins-cron.yml} | 40 +++++++++---------- wp-cli-docker/wpdeploy.yml | 4 -- 6 files changed, 57 insertions(+), 45 deletions(-) create mode 100755 install.original rename wp-cli-docker/roles/{wordpress-mu/tasks/main.yml => wordpress-init/tasks/mu-plugins-cron.yml} (56%) diff --git a/install.original b/install.original new file mode 100755 index 0000000..772a607 --- /dev/null +++ b/install.original @@ -0,0 +1,8 @@ +#!/bin/bash + +set -v + +. variables.sh + +# Upgrade or install application using the current git branch as docker tag +helm upgrade $releaseName . --install -f values-local.yaml --set initImage.tag=$dockerTag --set image.tag=$dockerTag diff --git a/values-local.yaml.example b/values-local.yaml.example index bc6dfb2..71ff87d 100644 --- a/values-local.yaml.example +++ b/values-local.yaml.example @@ -62,8 +62,9 @@ wordpress: ## mu_plugins are installed as hidden and cannot be updated from the UI ## mu_cron is an externally triggered cron - wordpress_mu_dir: mu-plugins - wordpress_mu_plugins: + mu_plugins_enabled: true + mu_plugins_dir: mu-plugins + mu_plugins: block-bad-queries: name: Block Bad Queries version: 20191109 @@ -73,8 +74,8 @@ wordpress: version: 1.5.6 phpfile: redis-cache.php - wordpress_mu_cron_enabled: true - wordpress_mu_cron: + mu_cron_enabled: true + mu_cron: name: Cron Control repo: https://github.com/Automattic/Cron-Control.git slug: cron-control diff --git a/values.yaml b/values.yaml index c7cb641..67daea6 100644 --- a/values.yaml +++ b/values.yaml @@ -149,29 +149,31 @@ ansibleVars: # - logbook # - wp-cron-control - ## The directory for mu plugins eg: 'mu-plugins' maps to wp-content/mu-plugins - wordpress_mudir: mu-plugins + ## Detailed list of mu values and plugins with versions + ## mu_plugins_dir 'mu-plugins' maps to wp-content/mu-plugins + ## mu_plugins are installed as hidden and cannot be updated from the UI + ## mu_cron is an externally triggered cron - ## Detailed list of mu plugins and versions eg: 'mu-plugins' maps to wp-content/mu-plugins - wordpress_mu_plugins: - block-bad-queries: - name: Block Bad Queries - version: 20191109 - phpfile: block-bad-queries.php - redis-cache: - name: Redis Cache - version: 1.5.6 - phpfile: redis-cache.php - - wordpress_mu_cron_enabled: true - wordpress_mu_cron: - name: Cron Control + mu_plugins_enabled: true + mu_plugins_dir: mu-plugins + mu_plugins: + block-bad-queries: + name: Block Bad Queries + version: 20191109 + phpfile: block-bad-queries.php + redis-cache: + name: Redis Cache + version: 1.5.6 + phpfile: redis-cache.php + + mu_cron_enabled: false + mu_cron: + name: Cron Control repo: https://github.com/Automattic/Cron-Control.git slug: cron-control version: master phpfile: wp-cron-control.php - wpSalts: {} image: @@ -289,6 +291,8 @@ ansibleSecrets: | WP_URL: {{ .Values.wordpress.site.url }} WP_USER: {{ .Values.wordpress.config.adm.usid }} WP_VERSION: {{ .Values.wordpress.site.version }} + WP_MU_PLUGINS_ENABLED: {{ .Values.wordpress.mu_plugins_enabled }} + WP_MU_CRON_ENABLED: {{ .Values.wordpress.mu_cron_enabled }} WP_WPML_ENABLED: {{ .Values.wordpress.site.wpml }} WP_WPS_PATH: {{ .Values.wordpress.site.alt_path }} WP_OPENID_CONNECT_ENABLED: {{ .Values.openid_connect_settings.enabled }} diff --git a/wp-cli-docker/roles/wordpress-init/tasks/main.yml b/wp-cli-docker/roles/wordpress-init/tasks/main.yml index ec493fd..20d2239 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/main.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/main.yml @@ -116,6 +116,9 @@ shell: wp {{ cli_args }} plugin install "{{ item }}" --force --activate with_items: "{{ wordpress_default_plugins }}" +- import_tasks: mu-plugins-cron.yml + when: WP_MU_PLUGINS_ENABLED + - import_tasks: redis.yml when: WP_REDIS_ENABLED diff --git a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml similarity index 56% rename from wp-cli-docker/roles/wordpress-mu/tasks/main.yml rename to wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 2d9ded9..fea1b21 100644 --- a/wp-cli-docker/roles/wordpress-mu/tasks/main.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -1,19 +1,19 @@ --- -# WP Environment +# WP Configuration for MU - name: Set content directory variable in wp-config shell: wp {{ cli_args }} config set 'WP_CONTENT_DIR' "ABSPATH . 'wp-content'" --raw --type=constant - name: Set MU plugins directory in wp-config - shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "WP_CONTENT_DIR . '/{{ wordpress_mudir }}'" --raw --type=constant + shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "WP_CONTENT_DIR . '/{{ mu_plugins_dir }}'" --raw --type=constant # MU plugins directory and loader -- name: Add a MU plugins directory when wordpress_mudir is set +- name: Add a MU plugins directory when mu_plugins_dir is set file: - path: {{ wordpress_homedir }}/wp-content/{{ wordpress_mudir }} + path: {{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }} mode: 0750 owner: {{ wp_user }} group: {{ wp_group }} @@ -21,54 +21,54 @@ - name: Add MU plugins load.php file file: - path: {{ wordpress_homedir }}/wp-content/{{ wordpress_mudir }}/load.php + path: {{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}/load.php owner: {{ wp_user }} group: {{ wp_group }} mode: 0640 - name: Insert the base code into MU plugins load.php file lineinfile: - dest: "{{ wordpress_homedir }}/wp-content/{{ wordpress_mudir }}/load.php" - line: " Date: Wed, 25 Mar 2020 09:39:35 +0000 Subject: [PATCH 07/28] Yaml typo fixes --- .../wordpress-init/tasks/mu-plugins-cron.yml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index fea1b21..f461e56 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -15,42 +15,42 @@ file: path: {{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }} mode: 0750 - owner: {{ wp_user }} - group: {{ wp_group }} + owner: "{{ wp_user }}" + group: "{{ wp_group }}" state: directory - name: Add MU plugins load.php file file: path: {{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}/load.php - owner: {{ wp_user }} - group: {{ wp_group }} + owner: "{{ wp_user }}" + group: "{{ wp_group }}" mode: 0640 - name: Insert the base code into MU plugins load.php file - lineinfile: - dest: "{{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}/load.php" - line: " Date: Thu, 26 Mar 2020 13:25:57 +0000 Subject: [PATCH 08/28] Removed ownership vars in mu-plugins task Removed install.original --- install.original | 8 -------- .../roles/wordpress-init/tasks/mu-plugins-cron.yml | 4 ---- 2 files changed, 12 deletions(-) delete mode 100755 install.original diff --git a/install.original b/install.original deleted file mode 100755 index 772a607..0000000 --- a/install.original +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -set -v - -. variables.sh - -# Upgrade or install application using the current git branch as docker tag -helm upgrade $releaseName . --install -f values-local.yaml --set initImage.tag=$dockerTag --set image.tag=$dockerTag diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index f461e56..09fa180 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -15,15 +15,11 @@ file: path: {{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }} mode: 0750 - owner: "{{ wp_user }}" - group: "{{ wp_group }}" state: directory - name: Add MU plugins load.php file file: path: {{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}/load.php - owner: "{{ wp_user }}" - group: "{{ wp_group }}" mode: 0640 - name: Insert the base code into MU plugins load.php file -- GitLab From 3f967d7cb4a9d3e68c7a9e611314b94159315e15 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Thu, 26 Mar 2020 16:21:24 +0000 Subject: [PATCH 09/28] Created install.sh.example Added install.sh to .gitignore --- .gitignore | 1 + install.sh => install.sh.example | 0 2 files changed, 1 insertion(+) rename install.sh => install.sh.example (100%) diff --git a/.gitignore b/.gitignore index be2882f..dd86312 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.swp charts values-local.yaml +install.sh /data/ diff --git a/install.sh b/install.sh.example similarity index 100% rename from install.sh rename to install.sh.example -- GitLab From 05bc999478e62c4b0b6660557b01b28d78f8f350 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Fri, 27 Mar 2020 11:02:15 +0000 Subject: [PATCH 10/28] Quoted paths --- wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 09fa180..47c63a6 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -13,13 +13,13 @@ - name: Add a MU plugins directory when mu_plugins_dir is set file: - path: {{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }} + path: "{{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}" mode: 0750 state: directory - name: Add MU plugins load.php file file: - path: {{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}/load.php + path: "{{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}/load.php" mode: 0640 - name: Insert the base code into MU plugins load.php file -- GitLab From e6168a0c61af6432dd3fcd2f6e1961ebab465009 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Fri, 27 Mar 2020 13:37:34 +0000 Subject: [PATCH 11/28] Reincluded vars and import_task --- values.yaml | 2 ++ wp-cli-docker/roles/wordpress-init/tasks/main.yml | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/values.yaml b/values.yaml index 84bc1dc..762aedc 100644 --- a/values.yaml +++ b/values.yaml @@ -289,6 +289,8 @@ ansibleSecrets: | WP_ALT_ENABLED: {{ .Values.wordpress.site.alt_enabled }} WP_ALT_CONFIG: {{ .Values.wordpress.site.alt_config }} WP_ALT_PATH: {{ .Values.wordpress.site.alt_path }} + WP_MU_PLUGINS_ENABLED: {{ .Values.wordpress.mu_plugins_enabled }} + WP_MU_CRON_ENABLED: {{ .Values.wordpress.mu_cron_enable WP_MULTILINGUAL_ENABLED: {{ .Values.wordpress.site.multilingual.enabled }} WP_MULTILINGUAL_PLUGINS: {{ .Values.wordpress.site.multilingual.plugins }} WP_MULTILINGUAL_CONFIG: {{ quote .Values.wordpress.site.multilingual.config }} diff --git a/wp-cli-docker/roles/wordpress-init/tasks/main.yml b/wp-cli-docker/roles/wordpress-init/tasks/main.yml index e7f7121..5922862 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/main.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/main.yml @@ -133,7 +133,10 @@ - name: Set alt path shell: wp {{ cli_args }} option set {{ WP_ALT_CONFIG }} {{ WP_ALT_PATH }} when: WP_ALT_ENABLED - + +- import_tasks: mu-plugins-cron.yml + when: WP_MU_PLUGINS_ENABLED + - import_tasks: redis.yml when: WP_REDIS_ENABLED -- GitLab From c2d53bf4eae51957a1f72fba198a3945abeda3e4 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Fri, 27 Mar 2020 13:38:32 +0000 Subject: [PATCH 12/28] Fixed typo --- values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/values.yaml b/values.yaml index 762aedc..dba6a20 100644 --- a/values.yaml +++ b/values.yaml @@ -290,7 +290,7 @@ ansibleSecrets: | WP_ALT_CONFIG: {{ .Values.wordpress.site.alt_config }} WP_ALT_PATH: {{ .Values.wordpress.site.alt_path }} WP_MU_PLUGINS_ENABLED: {{ .Values.wordpress.mu_plugins_enabled }} - WP_MU_CRON_ENABLED: {{ .Values.wordpress.mu_cron_enable + WP_MU_CRON_ENABLED: {{ .Values.wordpress.mu_cron_enabled }} WP_MULTILINGUAL_ENABLED: {{ .Values.wordpress.site.multilingual.enabled }} WP_MULTILINGUAL_PLUGINS: {{ .Values.wordpress.site.multilingual.plugins }} WP_MULTILINGUAL_CONFIG: {{ quote .Values.wordpress.site.multilingual.config }} -- GitLab From 46f8afa778db7cff5e9bfa3a6d704a1723390955 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Fri, 27 Mar 2020 15:38:58 +0000 Subject: [PATCH 13/28] Set mu-plugins as disabled Example plugin in values.yaml comments --- values.yaml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/values.yaml b/values.yaml index 2d55e0d..89f3a6c 100644 --- a/values.yaml +++ b/values.yaml @@ -151,18 +151,13 @@ ansibleVars: ## mu_plugins_dir 'mu-plugins' maps to wp-content/mu-plugins ## mu_plugins are installed as hidden and cannot be updated from the UI ## mu_cron is an externally triggered cron - - mu_plugins_enabled: true - mu_plugins_dir: mu-plugins - mu_plugins: - block-bad-queries: - name: Block Bad Queries - version: 20191109 - phpfile: block-bad-queries.php - redis-cache: - name: Redis Cache - version: 1.5.6 - phpfile: redis-cache.php + mu_plugins_enabled: false + #mu_plugins_dir: mu-plugins + #mu_plugins: + # example-plugin-slug: + # name: Example PLugin + # version: 0.1 + # phpfile: example-plugin-phpfile.php mu_cron_enabled: false mu_cron: -- GitLab From ee03b3a850c86fe6c47ae76b71ff9f37da3d0c0c Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Mon, 30 Mar 2020 16:08:07 +0200 Subject: [PATCH 14/28] forward all the necessary mu_ variables to Ansible --- values.yaml | 5 +++ .../wordpress-init/tasks/mu-plugins-cron.yml | 32 +++++++++---------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/values.yaml b/values.yaml index 89f3a6c..efd472e 100644 --- a/values.yaml +++ b/values.yaml @@ -159,6 +159,8 @@ ansibleVars: # version: 0.1 # phpfile: example-plugin-phpfile.php + # Enable externally triggered cron. Only possible if mu_plugins_enabled is + # true mu_cron_enabled: false mu_cron: name: Cron Control @@ -289,7 +291,10 @@ ansibleSecrets: | WP_ALT_CONFIG: {{ .Values.wordpress.site.alt_config }} WP_ALT_PATH: {{ .Values.wordpress.site.alt_path }} WP_MU_PLUGINS_ENABLED: {{ .Values.wordpress.mu_plugins_enabled }} + WP_MU_PLUGINS_DIR: {{ .Values.wordpress.mu_plugins_dir }} + WP_MU_PLUGINS: {{ .Values.wordpress.mu_plugins | toJson }} WP_MU_CRON_ENABLED: {{ .Values.wordpress.mu_cron_enabled }} + WP_MU_CRON_SETTINGS: {{ .Values.wordpress.mu_cron | toJson }} WP_MULTILINGUAL_ENABLED: {{ .Values.wordpress.site.multilingual.enabled }} WP_MULTILINGUAL_PLUGINS: {{ .Values.wordpress.site.multilingual.plugins }} WP_MULTILINGUAL_CONFIG: {{ quote .Values.wordpress.site.multilingual.config }} diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 47c63a6..ec69d86 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -6,62 +6,62 @@ shell: wp {{ cli_args }} config set 'WP_CONTENT_DIR' "ABSPATH . 'wp-content'" --raw --type=constant - name: Set MU plugins directory in wp-config - shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "WP_CONTENT_DIR . '/{{ mu_plugins_dir }}'" --raw --type=constant + shell: wp {{ cli_args }} config set 'WPMU_PLUGIN_DIR' "WP_CONTENT_DIR . '/{{ WP_MU_PLUGINS_DIR }}'" --raw --type=constant # MU plugins directory and loader -- name: Add a MU plugins directory when mu_plugins_dir is set +- name: Add a MU plugins directory when WP_MU_PLUGINS_DIR is set file: - path: "{{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}" + path: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}" mode: 0750 state: directory - name: Add MU plugins load.php file file: - path: "{{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}/load.php" + path: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/load.php" mode: 0640 - name: Insert the base code into MU plugins load.php file lineinfile: - dest: "{{ wordpress_homedir }}/wp-content/{{ mu_plugins_dir }}/load.php" - line: " Date: Mon, 30 Mar 2020 16:30:09 +0200 Subject: [PATCH 15/28] add debug prints to ansible playbook --- .../wordpress-init/tasks/mu-plugins-cron.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index ec69d86..c486eba 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -30,9 +30,25 @@ ### Install plugins then move them to the MU plugins folder +- name: debug WP_MU_PLUGINS + debug: + msg: "whole variable" + var: WP_MU_PLUGINS + +- name: debug WP_MU_PLUGINS + debug: + msg: "Loop over items" + var: item + loop: WP_MU_PLUGINS + +- name: debug WP_MU_PLUGINS + debug: + msg: "Item {{ item.key }} with value {{ item.value }}" + loop: WP_MU_PLUGINS + - name: Install plugins before they are MU shell: wp {{ cli_args }} plugin install {{ item.key }} --version={{ item.value.version}} --force - with_items: "{{ WP_MU_PLUGINS }}" + loop: "{{ WP_MU_PLUGINS }}" - name: Move all the plugins to the mu-plugins folder where they are activated by default file: -- GitLab From 4b5251ac0b6c5e687f0864e51af2f0b6074a773d Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Mon, 30 Mar 2020 16:49:43 +0200 Subject: [PATCH 16/28] document install.sh.example, switch to kaniko for building, fix debug messages --- .gitlab-ci.yml | 30 ++++++++----------- install.sh.example | 4 +++ .../wordpress-init/tasks/mu-plugins-cron.yml | 2 -- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32f8761..d6fb9e0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,18 +1,18 @@ --- +include: + - remote: 'https://open.greenhost.net/openappstack/openappstack/-/raw/master/.gitlab/ci_templates/kaniko.yml' + stages: - build +default: + image: "${CI_REGISTRY_IMAGE}/${KANIKO_BUILD_IMAGENAME}:${CI_COMMIT_REF_SLUG}" + build-wp-cli: - image: docker:latest - services: - # FIXME This is an older version of DIND. Update when gitlab-runner fixes - # https://gitlab.com/gitlab-org/gitlab-runner/issues/4501 - - docker:18-dind stage: build - script: - - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} - - docker build -t ${CI_REGISTRY_IMAGE}/wordpress-cli-ansible:${CI_COMMIT_REF_NAME} wp-cli-docker - - docker push ${CI_REGISTRY_IMAGE}/wordpress-cli-ansible:${CI_COMMIT_REF_NAME} + variables: + KANIKO_BUILD_IMAGENAME: wordpress-cli-ansible + extends: .kaniko_build tags: - docker only: @@ -21,16 +21,10 @@ build-wp-cli: - .gitlab-ci.yml build-wp: - image: docker:latest - services: - # FIXME This is an older version of DIND. Update when gitlab-runner fixes - # https://gitlab.com/gitlab-org/gitlab-runner/issues/4501 - - docker:18-dind stage: build - script: - - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY} - - docker build -t ${CI_REGISTRY_IMAGE}/wordpress:${CI_COMMIT_REF_NAME} wp-docker - - docker push ${CI_REGISTRY_IMAGE}/wordpress:${CI_COMMIT_REF_NAME} + variables: + KANIKO_BUILD_IMAGENAME: wordpress + extends: .kaniko_build tags: - docker only: diff --git a/install.sh.example b/install.sh.example index 772a607..e4676e4 100755 --- a/install.sh.example +++ b/install.sh.example @@ -1,7 +1,11 @@ #!/bin/bash +# Use this installation script as an example for easy installation. Copy it to +# `install.sh` and edit the values file names if you need to. + set -v +# Makes sure you use docker image tags for the branch you're working on now . variables.sh # Upgrade or install application using the current git branch as docker tag diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index c486eba..9c7d1cf 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -32,12 +32,10 @@ - name: debug WP_MU_PLUGINS debug: - msg: "whole variable" var: WP_MU_PLUGINS - name: debug WP_MU_PLUGINS debug: - msg: "Loop over items" var: item loop: WP_MU_PLUGINS -- GitLab From 32f746946d39eea3a89225708f26bc46cec590b7 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Mon, 30 Mar 2020 16:51:46 +0200 Subject: [PATCH 17/28] fix kaniko process --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6fb9e0..88c3cb2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,7 @@ build-wp-cli: stage: build variables: KANIKO_BUILD_IMAGENAME: wordpress-cli-ansible + KANIKO_CONTEXT: wp-cli-docker extends: .kaniko_build tags: - docker @@ -24,6 +25,7 @@ build-wp: stage: build variables: KANIKO_BUILD_IMAGENAME: wordpress + KANIKO_CONTEXT: wp-docker extends: .kaniko_build tags: - docker -- GitLab From 6cc650e22d60d0bdd0030398868743c9f535d050 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 14:28:37 +0200 Subject: [PATCH 18/28] add ANSIBLE_CONFIG env variable to fix docker container --- wp-cli-docker/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wp-cli-docker/Dockerfile b/wp-cli-docker/Dockerfile index 51d105d..92c155a 100644 --- a/wp-cli-docker/Dockerfile +++ b/wp-cli-docker/Dockerfile @@ -4,6 +4,8 @@ USER root RUN apk add ansible git rsync ADD . /var/local/ansible +ENV ANSIBLE_CONFIG /var/local/ansible/ansible.cfg + # Chown the files to the Debian www-data user, because that's the only WP # container that runs Apache too. RUN chown -R 33:33 /var/local/ansible; \ -- GitLab From 63fb3b9ba721ed66354513b6848c0dfcaeeda383 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 14:45:08 +0200 Subject: [PATCH 19/28] use different format for mu_plugins --- values-local.yaml.example | 18 +++++++++--------- values.yaml | 8 ++++---- .../wordpress-init/tasks/mu-plugins-cron.yml | 14 +++++++------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/values-local.yaml.example b/values-local.yaml.example index 189dae6..2a49b7f 100644 --- a/values-local.yaml.example +++ b/values-local.yaml.example @@ -65,15 +65,15 @@ wordpress: mu_plugins_enabled: true mu_plugins_dir: mu-plugins mu_plugins: - block-bad-queries: - name: Block Bad Queries - version: 20191109 - phpfile: block-bad-queries.php - redis-cache: - name: Redis Cache - version: 1.5.6 - phpfile: redis-cache.php - + - slug: block-bad-queries + name: Block Bad Queries + version: 20191109 + phpfile: block-bad-queries.php + - slug: redis-cache + name: Redis Cache + version: 1.5.6 + phpfile: redis-cache.php + mu_cron_enabled: true mu_cron: name: Cron Control diff --git a/values.yaml b/values.yaml index efd472e..4fa1f01 100644 --- a/values.yaml +++ b/values.yaml @@ -154,10 +154,10 @@ ansibleVars: mu_plugins_enabled: false #mu_plugins_dir: mu-plugins #mu_plugins: - # example-plugin-slug: - # name: Example PLugin - # version: 0.1 - # phpfile: example-plugin-phpfile.php + # - slug: example-plugin-slug + # name: Example PLugin + # version: 0.1 + # phpfile: example-plugin-phpfile.php # Enable externally triggered cron. Only possible if mu_plugins_enabled is # true diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 9c7d1cf..43698f4 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -41,26 +41,26 @@ - name: debug WP_MU_PLUGINS debug: - msg: "Item {{ item.key }} with value {{ item.value }}" + msg: "Item {{ item.slug }} with version {{ item.version }}" loop: WP_MU_PLUGINS - name: Install plugins before they are MU - shell: wp {{ cli_args }} plugin install {{ item.key }} --version={{ item.value.version}} --force + shell: wp {{ cli_args }} plugin install {{ item.slug }} --version={{ item.value.version }} --force loop: "{{ WP_MU_PLUGINS }}" - name: Move all the plugins to the mu-plugins folder where they are activated by default file: - source: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.key }}" - dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.key }}" + source: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.slug }}" + dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.slug }}" recursive: true - with_items: "{{ WP_MU_PLUGINS }}" + loop: "{{ WP_MU_PLUGINS }}" - name: Echo all the MU plugins filenames into the load.php file lineinfile: dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/load.php" - line: "require(WPMU_PLUGIN_DIR . '/{{ item.key }}/{{ item.value.phpfile }}');" + line: "require(WPMU_PLUGIN_DIR . '/{{ item.slug }}/{{ item.phpfile }}');" insertbefore: EOF - with_items: "{{ WP_MU_PLUGINS }}" + loop: "{{ WP_MU_PLUGINS }}" ### Install wp-cron as mu -- GitLab From 827e1a5c43d5bf721c7038eda57db943f5f0ca73 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 14:55:54 +0200 Subject: [PATCH 20/28] Revert "use different format for mu_plugins" This reverts commit 63fb3b9ba721ed66354513b6848c0dfcaeeda383. --- values-local.yaml.example | 18 +++++++++--------- values.yaml | 8 ++++---- .../wordpress-init/tasks/mu-plugins-cron.yml | 14 +++++++------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/values-local.yaml.example b/values-local.yaml.example index 2a49b7f..189dae6 100644 --- a/values-local.yaml.example +++ b/values-local.yaml.example @@ -65,15 +65,15 @@ wordpress: mu_plugins_enabled: true mu_plugins_dir: mu-plugins mu_plugins: - - slug: block-bad-queries - name: Block Bad Queries - version: 20191109 - phpfile: block-bad-queries.php - - slug: redis-cache - name: Redis Cache - version: 1.5.6 - phpfile: redis-cache.php - + block-bad-queries: + name: Block Bad Queries + version: 20191109 + phpfile: block-bad-queries.php + redis-cache: + name: Redis Cache + version: 1.5.6 + phpfile: redis-cache.php + mu_cron_enabled: true mu_cron: name: Cron Control diff --git a/values.yaml b/values.yaml index 4fa1f01..efd472e 100644 --- a/values.yaml +++ b/values.yaml @@ -154,10 +154,10 @@ ansibleVars: mu_plugins_enabled: false #mu_plugins_dir: mu-plugins #mu_plugins: - # - slug: example-plugin-slug - # name: Example PLugin - # version: 0.1 - # phpfile: example-plugin-phpfile.php + # example-plugin-slug: + # name: Example PLugin + # version: 0.1 + # phpfile: example-plugin-phpfile.php # Enable externally triggered cron. Only possible if mu_plugins_enabled is # true diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 43698f4..9c7d1cf 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -41,26 +41,26 @@ - name: debug WP_MU_PLUGINS debug: - msg: "Item {{ item.slug }} with version {{ item.version }}" + msg: "Item {{ item.key }} with value {{ item.value }}" loop: WP_MU_PLUGINS - name: Install plugins before they are MU - shell: wp {{ cli_args }} plugin install {{ item.slug }} --version={{ item.value.version }} --force + shell: wp {{ cli_args }} plugin install {{ item.key }} --version={{ item.value.version}} --force loop: "{{ WP_MU_PLUGINS }}" - name: Move all the plugins to the mu-plugins folder where they are activated by default file: - source: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.slug }}" - dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.slug }}" + source: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.key }}" + dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.key }}" recursive: true - loop: "{{ WP_MU_PLUGINS }}" + with_items: "{{ WP_MU_PLUGINS }}" - name: Echo all the MU plugins filenames into the load.php file lineinfile: dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/load.php" - line: "require(WPMU_PLUGIN_DIR . '/{{ item.slug }}/{{ item.phpfile }}');" + line: "require(WPMU_PLUGIN_DIR . '/{{ item.key }}/{{ item.value.phpfile }}');" insertbefore: EOF - loop: "{{ WP_MU_PLUGINS }}" + with_items: "{{ WP_MU_PLUGINS }}" ### Install wp-cron as mu -- GitLab From 0c61651bb5dd92f2d85509511707cfeb2855ffdc Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 14:56:58 +0200 Subject: [PATCH 21/28] revert previous change and fix debug prints --- wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 9c7d1cf..2771a28 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -37,12 +37,12 @@ - name: debug WP_MU_PLUGINS debug: var: item - loop: WP_MU_PLUGINS + loop: "{{ WP_MU_PLUGINS }}" - name: debug WP_MU_PLUGINS debug: msg: "Item {{ item.key }} with value {{ item.value }}" - loop: WP_MU_PLUGINS + loop: "{{ WP_MU_PLUGINS }}" - name: Install plugins before they are MU shell: wp {{ cli_args }} plugin install {{ item.key }} --version={{ item.value.version}} --force -- GitLab From 4816ed699b2cbe720a16384634422b0690b2a751 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 15:25:43 +0200 Subject: [PATCH 22/28] use dict2items in loop --- .../roles/wordpress-init/tasks/mu-plugins-cron.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 2771a28..6deea62 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -37,30 +37,30 @@ - name: debug WP_MU_PLUGINS debug: var: item - loop: "{{ WP_MU_PLUGINS }}" + loop: "{{ WP_MU_PLUGINS | dict2items }}" - name: debug WP_MU_PLUGINS debug: msg: "Item {{ item.key }} with value {{ item.value }}" - loop: "{{ WP_MU_PLUGINS }}" + loop: "{{ WP_MU_PLUGINS | dict2items }}" - name: Install plugins before they are MU shell: wp {{ cli_args }} plugin install {{ item.key }} --version={{ item.value.version}} --force - loop: "{{ WP_MU_PLUGINS }}" + loop: "{{ WP_MU_PLUGINS | dict2items }}" - name: Move all the plugins to the mu-plugins folder where they are activated by default file: source: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.key }}" dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.key }}" recursive: true - with_items: "{{ WP_MU_PLUGINS }}" + with_items: "{{ WP_MU_PLUGINS | dict2items }}" - name: Echo all the MU plugins filenames into the load.php file lineinfile: dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/load.php" line: "require(WPMU_PLUGIN_DIR . '/{{ item.key }}/{{ item.value.phpfile }}');" insertbefore: EOF - with_items: "{{ WP_MU_PLUGINS }}" + with_items: "{{ WP_MU_PLUGINS | dict2items }}" ### Install wp-cron as mu -- GitLab From 3c9bd5d8202de949777807fbf262a55271827c70 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 15:35:30 +0200 Subject: [PATCH 23/28] fix file: call --- wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 6deea62..a1cc58b 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -52,7 +52,7 @@ file: source: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.key }}" dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.key }}" - recursive: true + recurse: true with_items: "{{ WP_MU_PLUGINS | dict2items }}" - name: Echo all the MU plugins filenames into the load.php file -- GitLab From b4f83ad130c5dea64a2077679929233777d27e12 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 15:42:45 +0200 Subject: [PATCH 24/28] fix playbook (i hope) --- wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index a1cc58b..40e8c74 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -50,7 +50,7 @@ - name: Move all the plugins to the mu-plugins folder where they are activated by default file: - source: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.key }}" + src: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.key }}" dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.key }}" recurse: true with_items: "{{ WP_MU_PLUGINS | dict2items }}" -- GitLab From 89e01e6db85fcb140a1e8d506c33b3d35abcfe5c Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 15:52:08 +0200 Subject: [PATCH 25/28] use command: mv instead of file module for moving files --- wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 40e8c74..1aff3a0 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -49,10 +49,7 @@ loop: "{{ WP_MU_PLUGINS | dict2items }}" - name: Move all the plugins to the mu-plugins folder where they are activated by default - file: - src: "{{ wordpress_homedir }}/wp-content/plugins/{{ item.key }}" - dest: "{{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.key }}" - recurse: true + command: mv {{ wordpress_homedir }}/wp-content/plugins/{{ item.key }} {{ wordpress_homedir }}/wp-content/{{ WP_MU_PLUGINS_DIR }}/{{ item.key }} with_items: "{{ WP_MU_PLUGINS | dict2items }}" - name: Echo all the MU plugins filenames into the load.php file -- GitLab From 653b6185626f6250ec1307eefedd4d5c3a8779d2 Mon Sep 17 00:00:00 2001 From: Maarten de Waard Date: Tue, 31 Mar 2020 16:37:34 +0200 Subject: [PATCH 26/28] remove debug prints --- values-local.yaml.example | 2 +- .../roles/wordpress-init/tasks/mu-plugins-cron.yml | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/values-local.yaml.example b/values-local.yaml.example index 189dae6..e9528f3 100644 --- a/values-local.yaml.example +++ b/values-local.yaml.example @@ -80,7 +80,7 @@ wordpress: repo: https://github.com/Automattic/Cron-Control.git slug: cron-control version: master - phpfile: wp-cron-control.php + phpfile: cron-control.php # These settings make sense to overwrite if you want to use the OpenID connect # plugin diff --git a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml index 1aff3a0..3f2d256 100644 --- a/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml +++ b/wp-cli-docker/roles/wordpress-init/tasks/mu-plugins-cron.yml @@ -30,20 +30,6 @@ ### Install plugins then move them to the MU plugins folder -- name: debug WP_MU_PLUGINS - debug: - var: WP_MU_PLUGINS - -- name: debug WP_MU_PLUGINS - debug: - var: item - loop: "{{ WP_MU_PLUGINS | dict2items }}" - -- name: debug WP_MU_PLUGINS - debug: - msg: "Item {{ item.key }} with value {{ item.value }}" - loop: "{{ WP_MU_PLUGINS | dict2items }}" - - name: Install plugins before they are MU shell: wp {{ cli_args }} plugin install {{ item.key }} --version={{ item.value.version}} --force loop: "{{ WP_MU_PLUGINS | dict2items }}" -- GitLab From 64d096c1e44c25b4f9e3677b0e913cc4d83f3003 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Thu, 2 Apr 2020 08:07:51 +0100 Subject: [PATCH 27/28] Better comments for _enabled --- values-local.yaml.example | 39 +++++++++++++++++++++------------------ values.yaml | 37 +++++++++++++++++++------------------ {msg: | 0 3 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 {msg: diff --git a/values-local.yaml.example b/values-local.yaml.example index e9528f3..211a3bf 100644 --- a/values-local.yaml.example +++ b/values-local.yaml.example @@ -37,7 +37,8 @@ wordpress: # WordPress database fields that contain the URL. url: "http://localhost" title: "Wordpress Helm" - # If you are including a plugin to alias wp login then set an alt_path set alt_config options and then set alt_enabled to true + # If you are including a plugin to alias wp login then set an alt_path and set alt_config options + # NOTE: A value for alt_enabled must be set. Select either true or false alt_enabled: false # alt_config: PATH-SETTING-IN-OPTIONS-TABLE # alt_path: SOME-LOGIN-PATH @@ -57,30 +58,32 @@ wordpress: Require all granted - ## Detailed list of mu values and plugins with versions - ## mu_dir 'mu-plugins' maps to wp-content/mu-plugins - ## mu_plugins are installed as hidden and cannot be updated from the UI - ## mu_cron is an externally triggered cron + ## mu_plugins are installed as hidden and cannot be updated from the UI + ## mu_dir 'mu-plugins' maps to wp-content/mu-plugins + ## mu_plugins supplies a detailed list of mu values and plugins with versions + # NOTE: A value for mu_plugins_enabled must be set. Select either true or false - mu_plugins_enabled: true + mu_plugins_enabled: false mu_plugins_dir: mu-plugins mu_plugins: block-bad-queries: name: Block Bad Queries version: 20191109 phpfile: block-bad-queries.php - redis-cache: - name: Redis Cache - version: 1.5.6 - phpfile: redis-cache.php - - mu_cron_enabled: true - mu_cron: - name: Cron Control - repo: https://github.com/Automattic/Cron-Control.git - slug: cron-control - version: master - phpfile: cron-control.php + # redis-cache: + # name: Redis Cache + # version: 1.5.6 + # phpfile: redis-cache.php + + ## Enable externally triggered cron if a cron plugin is installed + # NOTE: A value for mu_cron_enabled must be set. Select either true or false + mu_cron_enabled: false + # mu_cron: + # name: Cron Control + # repo: https://github.com/Automattic/Cron-Control.git + # slug: cron-control + # version: master + # phpfile: cron-control.php # These settings make sense to overwrite if you want to use the OpenID connect # plugin diff --git a/values.yaml b/values.yaml index efd472e..aaa2a78 100644 --- a/values.yaml +++ b/values.yaml @@ -90,28 +90,29 @@ wordpress: version: 5.2.3 url: "http://localhost" title: "Wordpress Helm" - # If you are including a plugin to alias wp login then set an alt_path set the alt_config and then set alt_enabled to true + ## If including a plugin to alias wp login then set an alt_path and set the alt_config + # NOTE: A value for alt_enabled must be set. Select either true or false alt_enabled: false # alt_config: PATH-SETTING-IN-OPTIONS-TABLE # alt_path: SOME-LOGIN-PATH wp_content: - # The directory to mount the files placed in wp-content. You shouldn't have to - # change this. + ## The directory to mount the files placed in wp-content. You shouldn't have to + ## change this. mount_path: /var/www/wp-content-mount wp_upload: - # The directory to mount the files placed in wp-content/uploads. You shouldn't - # have to change this. + ## The directory to mount the files placed in wp-content/uploads. You shouldn't + ## have to change this. mount_path: /var/www/wp-uploads-mount - # Contents of the .htaccess file that is mounted in the `wpUploadMnt` directory + ## Contents of the .htaccess file that is mounted in the `wpUploadMnt` directory htaccess: | - # Disable access to all file types except the following + ## Disable access to all file types except the following Require all denied Require all granted persistence: - # Enable the use of a persistent volume + ## Enable the use of a persistent volume enabled: true size: 1Gi accessMode: ReadWriteOnce @@ -123,7 +124,7 @@ service: port: 8080 -## dictionary with variables that are inserted into the wordpress-init default +## Dictionary with variables that are inserted into the wordpress-init default ## task. Feel free to override these if necessary ansibleVars: wordpress_homedir: /var/www/html @@ -150,7 +151,7 @@ ansibleVars: ## Detailed list of mu values and plugins with versions ## mu_plugins_dir 'mu-plugins' maps to wp-content/mu-plugins ## mu_plugins are installed as hidden and cannot be updated from the UI - ## mu_cron is an externally triggered cron + # NOTE: A value for mu_plugins_enabled must be set. Use either true or false mu_plugins_enabled: false #mu_plugins_dir: mu-plugins #mu_plugins: @@ -159,15 +160,15 @@ ansibleVars: # version: 0.1 # phpfile: example-plugin-phpfile.php - # Enable externally triggered cron. Only possible if mu_plugins_enabled is - # true + ## Enable externally triggered cron if a cron plugin is installed + # NOTE: A value for mu_cron_enabled must be set. Use either true or false mu_cron_enabled: false - mu_cron: - name: Cron Control - repo: https://github.com/Automattic/Cron-Control.git - slug: cron-control - version: master - phpfile: wp-cron-control.php + #mu_cron: + # name: Cron Control + # repo: https://github.com/Automattic/Cron-Control.git + # slug: cron-control + # version: master + # phpfile: wp-cron-control.php wpSalts: {} diff --git a/{msg: b/{msg: new file mode 100644 index 0000000..e69de29 -- GitLab From d90cec7b938d4de04e3f0e9b0041bd18c7b2a2d1 Mon Sep 17 00:00:00 2001 From: org <59-rebar@users.noreply.code.greeenhost.net> Date: Thu, 2 Apr 2020 08:13:34 +0100 Subject: [PATCH 28/28] Clean --- {msg: | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 {msg: diff --git a/{msg: b/{msg: deleted file mode 100644 index e69de29..0000000 -- GitLab