diff --git a/roles/_init/tasks/custom.yml b/roles/_init/tasks/custom.yml index 6f34c92f..0ce85358 100644 --- a/roles/_init/tasks/custom.yml +++ b/roles/_init/tasks/custom.yml @@ -1,3 +1,2 @@ --- - -# Nothing to do here. \ No newline at end of file +# Nothing to do here. diff --git a/roles/_init/tasks/drupal7.yml b/roles/_init/tasks/drupal7.yml index f6919125..08df1c76 100644 --- a/roles/_init/tasks/drupal7.yml +++ b/roles/_init/tasks/drupal7.yml @@ -1,14 +1,11 @@ --- -- name: Define path to drush for this build. - set_fact: - drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush.phar') }}" - -- name: Define path to drush for currently live build. # usually the same as drush_bin for Drupal 7 - set_fact: - drush_live_bin: "{{ drush_live_bin | default('{{ bin_directory }}/drush.phar') }}" +- name: Define paths to drush for this build. + ansible.builtin.set_fact: + drush_bin: "{{ drush_bin | default(bin_directory + '/drush.phar') }}" + drush_live_bin: "{{ drush_live_bin | default(bin_directory + '/drush.phar') }}" # usually the same as drush_bin for Drupal 7 - name: Ensure we have a drush binary. - import_role: + ansible.builtin.import_role: name: cli/drush - name: Ensure we have a cachetool binary and configuration. diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index afd1217b..a0501259 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -1,15 +1,15 @@ --- - name: Define path to drush for this build. ansible.builtin.set_fact: - drush_bin: "{{ drush_bin | default('{{ deploy_path }}/vendor/bin/drush') }}" + drush_bin: "{{ drush_bin | default(deploy_path + '/vendor/bin/drush') }}" - name: Define path to drush for previous build. ansible.builtin.set_fact: - previous_drush_bin: "{{ previous_drush_bin | default('{{ previous_deploy_path }}/vendor/bin/drush') }}" + previous_drush_bin: "{{ previous_drush_bin | default(previous_deploy_path + '/vendor/bin/drush') }}" - name: Define path to drush for currently live build. ansible.builtin.set_fact: - drush_live_bin: "{{ drush_live_bin | default('{{ live_symlink_dest }}/vendor/bin/drush') }}" + drush_live_bin: "{{ drush_live_bin | default(live_symlink_dest + '/vendor/bin/drush') }}" - name: Ensure we have a cachetool binary and configuration. ansible.builtin.import_role: diff --git a/roles/_init/tasks/main.yml b/roles/_init/tasks/main.yml index b2be45d8..00b0553d 100644 --- a/roles/_init/tasks/main.yml +++ b/roles/_init/tasks/main.yml @@ -30,34 +30,28 @@ ansible.builtin.set_fact: deploy_user: "{{ deploy_user | default('deploy') }}" -- name: Define deploy base path. +- name: Define initial deploy paths. ansible.builtin.set_fact: - deploy_base_path: "{{ deploy_base_path | default('/home/{{ deploy_user }}/deploy/{{ project_name }}_{{ build_type }}') }}" + deploy_base_path: "{{ deploy_base_path | default('/home/' + deploy_user + '/deploy/' + project_name + '_' + build_type) }}" + deploy_assets_base_path: "{{ deploy_assets_base_path | default('/home/' + deploy_user + '/shared/' + project_name + '_' + build_type + '/assets') }}" + webroot: "{{ webroot | default('web') }}" -- name: Define mounted directory for assets. +- name: Define deploy_path_prefix variable. ansible.builtin.set_fact: - deploy_assets_base_path: "{{ deploy_assets_base_path | default('/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/assets') }}" + deploy_path_prefix: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_" -- name: Define webroot. +- name: Define final deploy_path variable. ansible.builtin.set_fact: - webroot: "{{ webroot | default('web') }}" + deploy_path: "{{ deploy_path | default(deploy_path_prefix + build_number|string) }}" # This is passed from caller. - name: Gather last known good build number. ansible.builtin.set_fact: previous_build_number: "{{ previous_known_build_number }}" -- name: Define build deploy path prefix. - ansible.builtin.set_fact: - deploy_path_prefix: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_" - -- name: Define build deploy path. - ansible.builtin.set_fact: - deploy_path: "{{ deploy_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}" - - name: Define live_symlink dest. ansible.builtin.set_fact: - live_symlink_dest: "{{ live_symlink_dest | default('{{ deploy_base_path }}/live.{{ project_name }}_{{ build_type }}') }}" + live_symlink_dest: "{{ live_symlink_dest | default(deploy_base_path + '/live.' + project_name + '_' + build_type) }}" - name: Read the live symlink to get the path to the current build. ansible.builtin.stat: @@ -85,7 +79,7 @@ msg: "Track file ID: {{ previous_build_number }}. Build path ID: {{ _current_build_id }}. These should match, something is wrong, failing the build." when: - _current_build_path.stat.islnk - - _current_build_id | int != previous_build_number | int + - _current_build_id|int != previous_build_number|int - not skip_build_path_check - name: Define opcache cachetool path. @@ -114,11 +108,11 @@ - name: Define live_symlink dest for image builds. ansible.builtin.set_fact: - live_symlink_build_dest: "{{ live_symlink_build_dest | default('{{ build_base_path }}/live.{{ project_name }}_{{ build_type }}') }}" + live_symlink_build_dest: "{{ live_symlink_build_dest | default(build_base_path + '/live.' + project_name + '_' + build_type) }}" - name: Overwrite deploy and live_symlink paths if SquashFS deploy. ansible.builtin.set_fact: - deploy_path: "{{ build_path | default('{{ build_path_prefix }}{{ build_number }}') }}" + deploy_path: "{{ build_path | default(build_path_prefix + build_number|string) }}" - name: Overwrite cachetool path if SquashFS deploy and path not provided. ansible.builtin.set_fact: @@ -206,7 +200,7 @@ - name: Set the previous deploy's path for later use where we need to manipulate the live site. ansible.builtin.set_fact: - previous_deploy_path: "{{ previous_deploy_path | default('{{ deploy_path_prefix }}{{ previous_build_number }}') }}" + previous_deploy_path: "{{ previous_deploy_path | default(deploy_path_prefix + previous_build_number|string) }}" # Make sure the deploy target exists. - name: Ensure deploy target directory exists.