Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable per-site setup for permalink structure #661

Merged
merged 1 commit into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
33 changes: 10 additions & 23 deletions roles/wordpress-install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down