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
27 commits
Select commit Hold shift + click to select a range
3ccfe51
Defer nightly backups, disable ASG processes during syncs and run syn…
EmlynK Jan 20, 2022
a54c09c
Added deploy.yml examples for Drupal 9 and Localgov. Updated tests (#97)
DionisioFG Mar 10, 2022
223a3b5
Adding a new SimpleSAMLphp meta role. (#100)
gregharvey Mar 31, 2022
32843d5
Allowing users to set cachetool version properly. (#102)
gregharvey Apr 13, 2022
91ea64e
Deploy ami pr 1.x (#106)
gregharvey Apr 14, 2022
371b6b9
Making the MySQL dump command for routine back-ups less aggressive. (…
gregharvey Apr 20, 2022
a9cc7ad
Fix database backups pr 1.x (#109)
gregharvey Apr 20, 2022
4c4c3ad
Fix MySQL backup deferral. (#110)
EmlynK Apr 22, 2022
029848d
Files recurse fix pr 1.x (#112)
EmlynK Apr 26, 2022
b71fa83
Improve multisite support (#115)
EmlynK Apr 29, 2022
c933dc8
Static credentials handling fix pr 1.x (#119)
EmlynK May 23, 2022
b6ea020
Making contents of deploy tar 'ownerless'. (#117)
gregharvey May 31, 2022
1c2b206
Implement file syncing (#124)
EmlynK Jun 7, 2022
1cd0ed0
Create Drupal-specific sync roles (#128)
EmlynK Jun 8, 2022
904033f
Fixing GRANT query for MySQL > 8.0. (#131)
gregharvey Jun 10, 2022
94715d8
Use IF NOT EXISTS when creating database user as that command fails i…
EmlynK Jun 13, 2022
20774f6
Adding SquashFS option to syncing.
gregharvey Jun 13, 2022
a684f74
Merge branch 'devel' into squashfs-PR-devel
gregharvey Jun 13, 2022
53e6443
Merge branch 'squashfs' into squashfs-PR-devel
gregharvey Jun 13, 2022
7f3e750
Make 'tarball' the default mount type so nothing existing breaks.
gregharvey Jun 13, 2022
f857383
Merge branch 'devel' into squashfs-PR-devel
gregharvey Jun 13, 2022
2ec37f2
Merge branch 'squashfs' into squashfs-PR-devel
gregharvey Jun 13, 2022
0b17bb5
Altering deploy_path so we can build in another location for SquashFS…
gregharvey Jun 14, 2022
eb54cb9
Merge branch 'devel' into squashfs-PR-devel
gregharvey Jun 14, 2022
dcdf35f
Merge branch 'squashfs' into squashfs-PR-devel
gregharvey Jun 14, 2022
0b380de
Ensuring the build dir exists if doing a SquashFS build.
gregharvey Jun 14, 2022
57f41a2
Merge branch 'squashfs' into squashfs-PR-devel
gregharvey Jun 14, 2022
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
51 changes: 38 additions & 13 deletions roles/_init/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
---
# Ensure default values for common variables.
- name: Define deploy user.
set_fact:
ansible.builtin.set_fact:
deploy_user: "{{ deploy_user | default('deploy') }}"
- name: Define deploy base path.
set_fact:
ansible.builtin.set_fact:
deploy_base_path: "{{ deploy_base_path | default('/home/{{ deploy_user }}/deploy/{{ project_name }}_{{ build_type }}') }}"
- name: Define mounted directory for assets.
set_fact:
ansible.builtin.set_fact:
deploy_assets_base_path: "{{ deploy_assets_base_path | default('/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/assets') }}"
- name: Define webroot.
set_fact:
ansible.builtin.set_fact:
webroot: "{{ webroot | default('web') }}"
- name: Define build deploy path prefix.
set_fact:
ansible.builtin.set_fact:
deploy_path_prefix: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_"
- name: Define build deploy path.
set_fact:
ansible.builtin.set_fact:
deploy_path: "{{ deploy_path | default('{{ deploy_path_prefix }}{{ build_number }}') }}"
- name: Define live_symlink dest.
set_fact:
ansible.builtin.set_fact:
live_symlink_dest: "{{ live_symlink_dest | default('{{ deploy_base_path }}/live.{{ project_name }}_{{ build_type }}') }}"

# Manipulate variables for SquashFS builds.
- name: Define image builds base path.
ansible.builtin.set_fact:
build_base_path: "/home/{{ deploy_user }}/builds/{{ project_name }}_{{ build_type }}"
- name: Define image builds build path prefix.
ansible.builtin.set_fact:
build_path_prefix: "{{ build_base_path }}/{{ project_name }}_{{ build_type }}_build_"
- name: Overwrite deploy path if SquashFS deploy.
ansible.builtin.set_fact:
deploy_path: "{{ build_path | default('{{ build_path_prefix }}{{ build_number }}') }}"
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type == "squashfs"

# Gather last known good build directly from symlink.
# This can happen:
# - when the first builds failed,
Expand All @@ -42,7 +57,7 @@

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

# - set_fact:
Expand All @@ -53,27 +68,37 @@

# Make sure the deploy target exists.
- name: Ensure deploy target directory exists.
file:
ansible.builtin.file:
path: "{{ deploy_base_path }}"
state: directory

# Make sure the build target exists.
- name: Ensure build target directory exists.
ansible.builtin.file:
path: "{{ build_base_path }}"
state: directory
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type == "squashfs"

# Check for project specific init tasks.
- name: Check that {{ project_type }}.yml exists.
stat:
ansible.builtin.stat:
path: "{{ role_path }}/tasks/{{ project_type }}.yml"
register: _project_type_task_result
delegate_to: "localhost"

# Project specific init tasks.
- name: Include project init tasks.
include_tasks: "{{ project_type }}.yml"
ansible.builtin.include_tasks: "{{ project_type }}.yml"
when:
- _project_type_task_result.stat.exists

- name: Define opcache cachetool path.
set_fact:
ansible.builtin.set_fact:
cachetool_bin: "{{ cachetool_bin | default('/home/{{ deploy_user }}/.bin/cachetool.phar') }}"

- name: Ensure we have a cachetool binary.
import_role:
ansible.builtin.import_role:
name: cli/cachetool
3 changes: 2 additions & 1 deletion roles/deploy_code/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ deploy_code:
# Specify any additional symlink to create, with src (target) and dest (link).
# src: can be either absolute or relative to the dest (eg. '/var/my_data', '/home/deploy/simplesaml', '../../../myconfig')
# dest: can only be relative to the root of your repository (eg. 'www/themes/myassets', 'var/cache')
# create: wether to create the target if it does not exists.
# create: whether to create the target if it does not exists.
# - src: '/home/{{ deploy_user }}//{{ project_name }}_{{ build_type }}/simplesaml'
# dest: 'vendor/simplesamlphp/simplesamlphp/config'
# - src: '/var/simplesaml/etc'
Expand All @@ -18,6 +18,7 @@ deploy_code:
# Whether to sync the local deploy base to a shared destination, after successful build.
mount_sync: ""
# Type of file to use for sync - 'squashfs' or 'tarball'
# @see the _init role for SquashFS build dir paths
mount_type: "tarball"
# mount_sync: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/deploy"
# Path that you want to make sure has 755 permissions. Make sure to include the webroot WITHOUT the slash.
Expand Down
30 changes: 25 additions & 5 deletions roles/deploy_code/tasks/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type is defined
- deploy_code.mount_type == "tarball"
run_once: true

- name: Create a SquashFS image of the deployed codebases.
ansible.builtin.command:
cmd: "mksquashfs {{ deploy_base_path }} /tmp/{{ project_name }}_{{ build_type }}.sqsh"
cmd: "mksquashfs {{ build_base_path }} /tmp/{{ project_name }}_{{ build_type }}.sqsh"
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type is defined
- deploy_code.mount_type == "squashfs"
run_once: true

Expand All @@ -56,7 +54,6 @@
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type is defined
- deploy_code.mount_type == "tarball"
run_once: true

Expand All @@ -66,10 +63,33 @@
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type is defined
- deploy_code.mount_type == "squashfs"
run_once: true

- name: Copy SquashFS image to local server.
ansible.builtin.command:
cmd: "cp {{ deploy_code.mount_sync }}/{{ project_name }}_{{ build_type }}.sqsh {{ build_base_path }}/deploy.sqsh"
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type == "squashfs"

- name: Unmount existing SquashFS image.
ansible.builtin.command:
cmd: "umount --force {{ deploy_base_path }}"
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type == "squashfs"

- name: Mount new SquashFS image.
ansible.builtin.command:
cmd: "mount {{ build_base_path }}/deploy.sqsh {{ deploy_base_path }} -t squashfs -o loop"
when:
- deploy_code.mount_sync is defined
- deploy_code.mount_sync | length > 1
- deploy_code.mount_type == "squashfs"

- name: Trigger an infrastructure rebuild.
ansible.builtin.include_role:
name: api_call
Expand Down