diff --git a/CHANGELOG.md b/CHANGELOG.md index 163d818847..fcb868317a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### HEAD +* Enable per-site setup for permalink structure ([#661](https://github.com/roots/trellis/pull/661)) * WP 4.6 Compat: set WP_HOME/SITEURL directly ([#647](https://github.com/roots/trellis/pull/647)) * Create WordPress php-fpm conf after web_root exists ([#642](https://github.com/roots/trellis/pull/642)) * Fix #637 - Fix condition for permalink structure task ([#643](https://github.com/roots/trellis/pull/643)) diff --git a/roles/wordpress-install/tasks/main.yml b/roles/wordpress-install/tasks/main.yml index 91e89d3529..934d232416 100644 --- a/roles/wordpress-install/tasks/main.yml +++ b/roles/wordpress-install/tasks/main.yml @@ -25,43 +25,30 @@ 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 + command: wp core {{ item.value.multisite.enabled | default(false) | ternary('multisite-install', 'install') }} --allow-root --url="{{ site_env.wp_home }}" + {% if item.value.multisite.enabled | default(false) %} --base="{{ item.value.multisite.base_path | default('/') }}" --subdomains="{{ item.value.multisite.subdomains | default('false') }}" + {% endif %} --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_multisite_install_results + register: wp_install 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_multisite_install_results.stdout" + when: item.value.site_install | default(true) + changed_when: "'WordPress is already installed.' not in wp_install.stdout and 'The network already exists.' not in wp_install.stdout" - name: Setup Permalink Structure - command: wp rewrite structure {{ item.value.initial_permalink_structure | default("/%postname%/") }} --allow-root + command: wp rewrite structure {{ item.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 or wp_multisite_install_results | changed + chdir: "{{ www_root }}/{{ item.item.key }}/{{ item.item.value.current_path | default('current') }}/" + with_items: "{{ wp_install.results }}" + when: item | changed - name: Update WP Multisite Home URL command: wp option update home {{ site_env.wp_home }} --allow-root