Skip to content

Commit

Permalink
Merge pull request #319 from austinpray/alan-multisite-merge
Browse files Browse the repository at this point in the history
Fixes Multisite Install
  • Loading branch information
swalkinshaw committed Aug 29, 2015
2 parents 7e3ddce + 8e3ae15 commit 0abd3c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
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

0 comments on commit 0abd3c0

Please sign in to comment.