Skip to content

Commit

Permalink
Merge pull request #607 from cfxd/allow-custom-current-path
Browse files Browse the repository at this point in the history
Allow custom current_path
swalkinshaw authored Jul 19, 2016
2 parents 03dd92a + 13d6841 commit 263eb22
Showing 12 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### HEAD
* Fix `wp_home` option in Multisite after install in development ([#616](https://github.com/roots/trellis/pull/616))
* Add `current_path` var and default to enable custom current release path ([#607](https://github.com/roots/trellis/pull/607))
* Add Vagrant post up message ([#602](https://github.com/roots/trellis/pull/602))
* Fix #468 - Use curl to install wp-cli tab completions ([#593](https://github.com/roots/trellis/pull/593))
* Require Ansible 2.0.2 and remove deploy_helper ([#579](https://github.com/roots/trellis/pull/579))
8 changes: 4 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ Vagrant.configure('2') do |config|

if Vagrant::Util::Platform.windows? and !Vagrant.has_plugin? 'vagrant-winnfsd'
wordpress_sites.each_pair do |name, site|
config.vm.synced_folder local_site_path(site), remote_site_path(name), owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']
config.vm.synced_folder local_site_path(site), remote_site_path(name, site), owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']
end
config.vm.synced_folder File.join(ANSIBLE_PATH, 'hosts'), File.join(ANSIBLE_PATH.sub(__dir__, '/vagrant'), 'hosts'), mount_options: ['dmode=755', 'fmode=644']
else
@@ -72,7 +72,7 @@ Vagrant.configure('2') do |config|
else
wordpress_sites.each_pair do |name, site|
config.vm.synced_folder local_site_path(site), nfs_path(name), type: 'nfs'
config.bindfs.bind_folder nfs_path(name), remote_site_path(name), u: 'vagrant', g: 'www-data', o: 'nonempty'
config.bindfs.bind_folder nfs_path(name), remote_site_path(name, site), u: 'vagrant', g: 'www-data', o: 'nonempty'
end
end
end
@@ -147,6 +147,6 @@ def post_up_message
msg
end

def remote_site_path(site_name)
"/srv/www/#{site_name}/current"
def remote_site_path(site_name, site)
"/srv/www/#{site_name}/#{site['current_path'] || 'current'}"
end
4 changes: 4 additions & 0 deletions roles/deploy/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -40,3 +40,7 @@ project_shared_children:
# WP_ENV: "production"
project_environment:
WP_ENV: "{{ env }}"

# The project_current_path is the symlink used for the latest or active deployment
# - default is 'current'
project_current_path: "{{ project.current_path | default('current') }}"
1 change: 1 addition & 0 deletions roles/deploy/tasks/finalize.yml
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

- name: Finalize the deploy
deploy_helper:
current_path: "{{ project_current_path }}"
path: "{{ project_root }}"
release: "{{ deploy_helper.new_release }}"
state: finalize
1 change: 1 addition & 0 deletions roles/deploy/tasks/initialize.yml
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

- name: Initialize
deploy_helper:
current_path: "{{ project_current_path }}"
path: "{{ project_root }}"
state: present

2 changes: 1 addition & 1 deletion roles/rollback/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -17,6 +17,6 @@

- name: Link 'current' directory to target release
file:
path: "{{ project_root }}/current"
path: "{{ project_root }}/{{ project_current_path }}"
src: "{{ new_release_path }}"
state: link
2 changes: 1 addition & 1 deletion roles/rollback/tasks/prior-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Get list position of current symlinked release
shell: "ls releases | grep -n $(basename $(readlink current)) | cut -f1 -d:"
shell: "ls releases | grep -n $(basename $(readlink {{ project_current_path }})) | cut -f1 -d:"
args:
chdir: "{{ project_root }}"
register: current_release_position
2 changes: 1 addition & 1 deletion roles/rollback/tasks/user-release.yml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
register: specified

- name: Get name of current symlinked release
shell: "basename $(readlink current)"
shell: "basename $(readlink {{ project_current_path }})"
args:
chdir: "{{ project_root }}"
register: current_release
2 changes: 1 addition & 1 deletion roles/wordpress-install/tasks/directories.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Create web root of sites
file:
path: "{{ www_root }}/{{ item.key }}/current/web"
path: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/web"
owner: "{{ web_user }}"
group: "{{ web_group }}"
mode: 0755
12 changes: 6 additions & 6 deletions roles/wordpress-install/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -11,15 +11,15 @@
with_dict: "{{ wordpress_sites }}"

- name: Copy .env file into web root
command: rsync -ac --info=NAME /tmp/{{ item.key }}.env {{ www_root }}/{{ item.key }}/current/.env
command: rsync -ac --info=NAME /tmp/{{ item.key }}.env {{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/.env
with_dict: "{{ wordpress_sites }}"
register: env_file
changed_when: env_file.stdout == "{{ item.key }}.env"

- name: Install Dependencies with Composer
command: composer install
args:
chdir: "{{ www_root }}/{{ item.key }}/current/"
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
register: composer_results
with_dict: "{{ wordpress_sites }}"
changed_when: "'Nothing to install or update' not in composer_results.stderr"
@@ -33,7 +33,7 @@
--admin_password="{{ vault_wordpress_sites[item.key].admin_password }}"
--admin_email="{{ item.value.admin_email }}"
args:
chdir: "{{ www_root }}/{{ item.key }}/current/"
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)
@@ -42,7 +42,7 @@
- name: Setup Permalink Structure
command: wp rewrite structure {{ item.value.initial_permalink_structure | default("/%postname%/") }} --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/current/"
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
when: wp_install_results | changed and not item.value.multisite.enabled | default(false)

@@ -57,7 +57,7 @@
--admin_password="{{ vault_wordpress_sites[item.key].admin_password }}"
--admin_email="{{ item.value.admin_email }}"
args:
chdir: "{{ www_root }}/{{ item.key }}/current/"
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 item.value.multisite.enabled | default(false)
@@ -66,6 +66,6 @@
- name: Update WP Multisite Home URL
command: wp option update home {{ site_env.wp_home }} --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/current/"
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
when: item.value.site_install | default(true) and item.value.multisite.enabled | default(false)
2 changes: 1 addition & 1 deletion roles/wordpress-setup/templates/wordpress-site.conf.j2
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ server {
access_log {{ www_root }}/{{ item.key }}/logs/access.log;
error_log {{ www_root }}/{{ item.key }}/logs/error.log;

root {{ www_root }}/{{ item.key }}/current/web;
root {{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/web;
index index.php index.htm index.html;

charset utf-8;
1 change: 1 addition & 0 deletions rollback.yml
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@

vars:
project_root: "{{ www_root }}/{{ site }}"
project_current_path: "{{ wordpress_sites[site].current_path | default('current') }}"

roles:
- rollback

0 comments on commit 263eb22

Please sign in to comment.