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

Fixes Multisite Install #319

Merged
merged 1 commit into from
Aug 29, 2015
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
50 changes: 23 additions & 27 deletions roles/wordpress-install/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,38 @@
with_dict: wordpress_sites
changed_when: "'Nothing to install or update' not in composer_results.stderr"

- name: WP installed?
command: wp core is-installed --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/current/"
register: site_statuses
with_dict: wordpress_sites
changed_when: False
failed_when: site_statuses.stderr != ""

- name: Install WP
command: wp core install
--allow-root
--url="{{ item.item.value.env.wp_home }}"
--title="{{ item.item.value.site_title | default(item.item.key) }}"
--admin_user="{{ item.item.value.admin_user }}"
--admin_password="{{ item.item.value.admin_password }}"
--admin_email="{{ item.item.value.admin_email }}"
--url="{{ item.value.env.wp_home }}"
--title="{{ item.value.site_title | default(item.key) }}"
--admin_user="{{ item.value.admin_user }}"
--admin_password="{{ item.value.admin_password }}"
--admin_email="{{ item.value.admin_email }}"
args:
chdir: "{{ www_root }}/{{ item.item.key }}/current/"
with_items: site_statuses.results
when: item.rc == 1 and item.item.value.site_install == True and (item.item.value.multisite.enabled | default(False) == False)
chdir: "{{ www_root }}/{{ item.key }}/current/"
register: wp_install_results
with_dict: wordpress_sites
when: item.value.site_install == True and (item.value.multisite.enabled | default(False) == 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="{{ item.item.value.env.wp_home }}"
--base="{{ item.item.value.multisite.base_path | default('/') }}"
--subdomains="{{ item.item.value.multisite.subdomains | default('false') }}"
--title="{{ item.item.value.site_title | default(item.item.key) }}"
--admin_user="{{ item.item.value.admin_user }}"
--admin_password="{{ item.item.value.admin_password }}"
--admin_email="{{ item.item.value.admin_email }}"
--url="{{ item.value.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 }}"
--admin_password="{{ item.value.admin_password }}"
--admin_email="{{ item.value.admin_email }}"
args:
chdir: "{{ www_root }}/{{ item.item.key }}/current/"
with_items: site_statuses.results
when: item.rc == 1 and item.item.value.site_install == True and (item.item.value.multisite.enabled | default(False) == True)
chdir: "{{ www_root }}/{{ item.key }}/current/"
register: wp_install_results
with_dict: wordpress_sites
when: item.value.site_install == True and (item.value.multisite.enabled | default(False) == True)
changed_when: "'The network already exists.' not in wp_install_results.stdout"


- name: Restart HHVM
service: name=hhvm state=restarted
Expand Down
4 changes: 2 additions & 2 deletions roles/wordpress-setup/templates/wordpress-site.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ server {
listen 80;
{% endif %}

server_name {{ item.value.site_hosts | join(' ') }};
server_name {% for host in item.value.site_hosts %} {{ host }} {% if item.value.multisite.subdomains %} *.{{ host }} {% endif %} {% endfor %};
access_log {{ www_root }}/{{ item.key }}/logs/access.log;
error_log {{ www_root }}/{{ item.key }}/logs/error.log;

Expand All @@ -24,7 +24,7 @@ server {
{% if item.value.multisite.enabled | default(false) -%}
{% if item.value.multisite.subdomains | default(false) -%}
rewrite ^/(wp-.*.php)$ /wp/$1 last;
rewrite ^/(wp-(content|admin|includes)/.*) /wp/$1 last;
rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last;
{%- else -%}
include wordpress_multisite_subdirectories.conf;
{%- endif %}
Expand Down