Skip to content

Commit 9c8574f

Browse files
authored
Updating 'default()' filter paths in _init as an initial test. (#766)
* Updating 'default()' filter paths in _init as an initial test. * Explicitly casting integers as strings for path creation. * Over refactored the variable setting! * Fixing Drupal 7 include in _init.
1 parent 92cd722 commit 9c8574f

File tree

4 files changed

+22
-32
lines changed

4 files changed

+22
-32
lines changed

roles/_init/tasks/custom.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
---
2-
3-
# Nothing to do here.
2+
# Nothing to do here.

roles/_init/tasks/drupal7.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
---
2-
- name: Define path to drush for this build.
3-
set_fact:
4-
drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush.phar') }}"
5-
6-
- name: Define path to drush for currently live build. # usually the same as drush_bin for Drupal 7
7-
set_fact:
8-
drush_live_bin: "{{ drush_live_bin | default('{{ bin_directory }}/drush.phar') }}"
2+
- name: Define paths to drush for this build.
3+
ansible.builtin.set_fact:
4+
drush_bin: "{{ drush_bin | default(bin_directory + '/drush.phar') }}"
5+
drush_live_bin: "{{ drush_live_bin | default(bin_directory + '/drush.phar') }}" # usually the same as drush_bin for Drupal 7
96

107
- name: Ensure we have a drush binary.
11-
import_role:
8+
ansible.builtin.import_role:
129
name: cli/drush
1310

1411
- name: Ensure we have a cachetool binary and configuration.

roles/_init/tasks/drupal8.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
- name: Define path to drush for this build.
33
ansible.builtin.set_fact:
4-
drush_bin: "{{ drush_bin | default('{{ deploy_path }}/vendor/bin/drush') }}"
4+
drush_bin: "{{ drush_bin | default(deploy_path + '/vendor/bin/drush') }}"
55

66
- name: Define path to drush for previous build.
77
ansible.builtin.set_fact:
8-
previous_drush_bin: "{{ previous_drush_bin | default('{{ previous_deploy_path }}/vendor/bin/drush') }}"
8+
previous_drush_bin: "{{ previous_drush_bin | default(previous_deploy_path + '/vendor/bin/drush') }}"
99

1010
- name: Define path to drush for currently live build.
1111
ansible.builtin.set_fact:
12-
drush_live_bin: "{{ drush_live_bin | default('{{ live_symlink_dest }}/vendor/bin/drush') }}"
12+
drush_live_bin: "{{ drush_live_bin | default(live_symlink_dest + '/vendor/bin/drush') }}"
1313

1414
- name: Ensure we have a cachetool binary and configuration.
1515
ansible.builtin.import_role:

roles/_init/tasks/main.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,28 @@
3030
ansible.builtin.set_fact:
3131
deploy_user: "{{ deploy_user | default('deploy') }}"
3232

33-
- name: Define deploy base path.
33+
- name: Define initial deploy paths.
3434
ansible.builtin.set_fact:
35-
deploy_base_path: "{{ deploy_base_path | default('/home/{{ deploy_user }}/deploy/{{ project_name }}_{{ build_type }}') }}"
35+
deploy_base_path: "{{ deploy_base_path | default('/home/' + deploy_user + '/deploy/' + project_name + '_' + build_type) }}"
36+
deploy_assets_base_path: "{{ deploy_assets_base_path | default('/home/' + deploy_user + '/shared/' + project_name + '_' + build_type + '/assets') }}"
37+
webroot: "{{ webroot | default('web') }}"
3638

37-
- name: Define mounted directory for assets.
39+
- name: Define deploy_path_prefix variable.
3840
ansible.builtin.set_fact:
39-
deploy_assets_base_path: "{{ deploy_assets_base_path | default('/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/assets') }}"
41+
deploy_path_prefix: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_"
4042

41-
- name: Define webroot.
43+
- name: Define final deploy_path variable.
4244
ansible.builtin.set_fact:
43-
webroot: "{{ webroot | default('web') }}"
45+
deploy_path: "{{ deploy_path | default(deploy_path_prefix + build_number|string) }}"
4446

4547
# This is passed from caller.
4648
- name: Gather last known good build number.
4749
ansible.builtin.set_fact:
4850
previous_build_number: "{{ previous_known_build_number }}"
4951

50-
- name: Define build deploy path prefix.
51-
ansible.builtin.set_fact:
52-
deploy_path_prefix: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_"
53-
54-
- name: Define build deploy path.
55-
ansible.builtin.set_fact:
56-
deploy_path: "{{ deploy_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}"
57-
5852
- name: Define live_symlink dest.
5953
ansible.builtin.set_fact:
60-
live_symlink_dest: "{{ live_symlink_dest | default('{{ deploy_base_path }}/live.{{ project_name }}_{{ build_type }}') }}"
54+
live_symlink_dest: "{{ live_symlink_dest | default(deploy_base_path + '/live.' + project_name + '_' + build_type) }}"
6155

6256
- name: Read the live symlink to get the path to the current build.
6357
ansible.builtin.stat:
@@ -85,7 +79,7 @@
8579
msg: "Track file ID: {{ previous_build_number }}. Build path ID: {{ _current_build_id }}. These should match, something is wrong, failing the build."
8680
when:
8781
- _current_build_path.stat.islnk
88-
- _current_build_id | int != previous_build_number | int
82+
- _current_build_id|int != previous_build_number|int
8983
- not skip_build_path_check
9084

9185
- name: Define opcache cachetool path.
@@ -114,11 +108,11 @@
114108

115109
- name: Define live_symlink dest for image builds.
116110
ansible.builtin.set_fact:
117-
live_symlink_build_dest: "{{ live_symlink_build_dest | default('{{ build_base_path }}/live.{{ project_name }}_{{ build_type }}') }}"
111+
live_symlink_build_dest: "{{ live_symlink_build_dest | default(build_base_path + '/live.' + project_name + '_' + build_type) }}"
118112

119113
- name: Overwrite deploy and live_symlink paths if SquashFS deploy.
120114
ansible.builtin.set_fact:
121-
deploy_path: "{{ build_path | default('{{ build_path_prefix }}{{ build_number }}') }}"
115+
deploy_path: "{{ build_path | default(build_path_prefix + build_number|string) }}"
122116

123117
- name: Overwrite cachetool path if SquashFS deploy and path not provided.
124118
ansible.builtin.set_fact:
@@ -206,7 +200,7 @@
206200

207201
- name: Set the previous deploy's path for later use where we need to manipulate the live site.
208202
ansible.builtin.set_fact:
209-
previous_deploy_path: "{{ previous_deploy_path | default('{{ deploy_path_prefix }}{{ previous_build_number }}') }}"
203+
previous_deploy_path: "{{ previous_deploy_path | default(deploy_path_prefix + previous_build_number|string) }}"
210204

211205
# Make sure the deploy target exists.
212206
- name: Ensure deploy target directory exists.

0 commit comments

Comments
 (0)