Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
114e951
New StatusCake check handling role.
gregharvey Apr 4, 2024
e98127a
Updating maintenance mode defaults and options.
gregharvey Apr 4, 2024
5bc2a97
Following StatusCake task naming conventions.
gregharvey Apr 4, 2024
d2df826
Missed the body_format param in StatusCake URI call.
gregharvey Apr 4, 2024
9b75ed5
Merging apply.
gregharvey Apr 4, 2024
beba36c
Merge branch '1.x' into statuscake_maintenance_role-PR-1.x
gregharvey Apr 4, 2024
7a06c1a
Merge branch 'statuscake_maintenance_role' into statuscake_maintenanc…
gregharvey Apr 4, 2024
469645d
Ensuring we pass the test ID as a string to the StatusCake URI call.
gregharvey Apr 5, 2024
a677c2c
Fixing namespaces.
gregharvey Apr 5, 2024
6296bef
Stashing the original deploy_path in initial_deploy_path for squashfs…
gregharvey Apr 5, 2024
e6505a6
Adding a double online step for Drupal builds using SquashFS so both …
gregharvey Apr 5, 2024
8a24ac9
Merge branch '1.x' into statuscake_maintenance_role-PR-1.x
gregharvey Apr 5, 2024
fc70bab
Merge branch 'statuscake_maintenance_role' into statuscake_maintenanc…
gregharvey Apr 5, 2024
dd19332
We need the path to the previous build for maintenance mode online.
gregharvey Apr 5, 2024
18c983b
Merge branch 'statuscake_maintenance_role' into statuscake_maintenanc…
gregharvey Apr 5, 2024
f2b757c
Changing order of tasks so previous_build_number is set earlier.
gregharvey Apr 5, 2024
95455ad
Merge branch 'statuscake_maintenance_role' into statuscake_maintenanc…
gregharvey Apr 5, 2024
ecab2fa
We also need a previous_drush_bin.
gregharvey Apr 5, 2024
9a6eb7c
Merge branch 'statuscake_maintenance_role' into statuscake_maintenanc…
gregharvey Apr 5, 2024
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
4 changes: 4 additions & 0 deletions roles/_init/tasks/drupal8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
set_fact:
drush_bin: "{{ drush_bin | default('{{ deploy_path }}/vendor/bin/drush') }}"

- name: Define path to drush for previous build.
set_fact:
previous_drush_bin: "{{ previous_drush_bin | default('{{ previous_deploy_path }}/vendor/bin/drush') }}"

- name: Define path to drush for currently live build.
set_fact:
drush_live_bin: "{{ drush_live_bin | default('{{ live_symlink_dest }}/vendor/bin/drush') }}"
Expand Down
14 changes: 9 additions & 5 deletions roles/_init/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
ansible.builtin.set_fact:
webroot: "{{ webroot | default('web') }}"

# 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_"
Expand Down Expand Up @@ -53,6 +58,10 @@
ansible.builtin.set_fact:
live_symlink_build_dest: "{{ live_symlink_build_dest | default('{{ build_base_path }}/live.{{ project_name }}_{{ build_type }}') }}"

- 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 }}') }}"

- name: Overwrite deploy and live_symlink paths if SquashFS deploy.
ansible.builtin.set_fact:
deploy_path: "{{ build_path | default('{{ build_path_prefix }}{{ build_number }}') }}"
Expand Down Expand Up @@ -89,11 +98,6 @@
# register: last_build
# when: last_build_symlink.stat.exists

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

# - set_fact:
# previous_build_number: "{{ last_build.stdout }}"
# when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@
become: "{{ 'no' if www_user == deploy_user else 'yes' }}"
become_user: "{{ www_user }}"
when:
- project_type == 'drupal8'
- project_type == "drupal8"

# We want to also bring up the 'current' site with squashfs builds
- name: Disable live site maintenance mode if this is a squashfs build.
ansible.builtin.command:
cmd: "{{ previous_drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer --root {{ previous_deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
args:
chdir: "{{ previous_deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
become: "{{ 'no' if www_user == deploy_user else 'yes' }}"
become_user: "{{ www_user }}"
when:
- project_type == "drupal8"
- deploy_code.mount_type is defined
- deploy_code.mount_type == "squashfs"

# For some reason D7 drush doesn't respect 'chdir' with command, using shell instead.
- name: Disable maintenance mode D7.
Expand All @@ -17,4 +30,16 @@
become: "{{ 'no' if www_user == deploy_user else 'yes' }}"
become_user: "{{ www_user }}"
when:
- project_type == 'drupal7'
- project_type == "drupal7"

# We want to also bring up the 'current' site with squashfs builds
- name: Disable maintenance mode D7 if this is a squashfs build.
ansible.builtin.shell:
cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 0"
chdir: "{{ previous_deploy_path }}/{{ webroot }}/sites/{{ site.folder }}"
become: "{{ 'no' if www_user == deploy_user else 'yes' }}"
become_user: "{{ www_user }}"
when:
- project_type == "drupal7"
- deploy_code.mount_type is defined
- deploy_code.mount_type == "squashfs"
4 changes: 2 additions & 2 deletions roles/maintenance_mode/maintenance_mode-nginx/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- include_tasks: "{{ maintenance_mode.operation }}.yml"
- ansible.builtin.include_tasks: "{{ maintenance_mode.operation }}.yml"

- name: Reload Nginx.
service:
ansible.builtin.service:
name: nginx
state: reloaded
become: true
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Disable active vhost.
file:
ansible.builtin.file:
path: "/etc/nginx/sites-enabled/{{ domain.server_name }}.conf"
state: absent
with_items: "{{ maintenance_mode_nginx.domains }}"
Expand All @@ -9,7 +9,7 @@
become: true

- name: Enable maintenance vhost.
file:
ansible.builtin.file:
src: "/etc/nginx/sites-available/{{ domain.server_name }}-maintenance.conf"
dest: "/etc/nginx/sites-enabled/{{ domain.server_name }}-maintenance.conf"
state: link
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Disable maintenance vhost.
file:
ansible.builtin.file:
path: "/etc/nginx/sites-enabled/{{ domain.server_name }}-maintenance.conf"
state: absent
with_items: "{{ maintenance_mode_nginx.domains }}"
Expand All @@ -9,7 +9,7 @@
become: true

- name: Enable active vhost.
file:
ansible.builtin.file:
src: "/etc/nginx/sites-available/{{ domain.server_name }}.conf"
dest: "/etc/nginx/sites-enabled/{{ domain.server_name }}.conf"
state: link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
loop_var: domain
run_once: true
when:
- maintenance_mode_statuscake.domains | length > 0
- maintenance_mode_statuscake.domains | length > 0
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Pause StatusCake check.
ansible.builtin.uri:
url: "https://api.statuscake.com/v1/uptime/{{ domain.statuscake_check_id }}"
url: "https://api.statuscake.com/v1/uptime/{{ domain.statuscake_check_id | string }}"
method: PUT
body_format: form-urlencoded
body:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Resume StatusCake check.
ansible.builtin.uri:
url: "https://api.statuscake.com/v1/uptime/{{ domain.statuscake_check_id }}"
url: "https://api.statuscake.com/v1/uptime/{{ domain.statuscake_check_id | string }}"
method: PUT
body_format: form-urlencoded
body:
Expand Down
2 changes: 1 addition & 1 deletion roles/maintenance_mode/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- include_role:
- ansible.builtin.include_role:
name: "maintenance_mode/maintenance_mode-{{ maintenance_mode.mode }}"
when:
- deploy_operation != 'cleanup'
Expand Down