From 282f5c0748233b87e5461c1ef4bc7338701c45c1 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 17:07:59 +0100 Subject: [PATCH 01/20] Updating docs. --- docs/_Sidebar.md | 2 + docs/roles/_init.md | 4 +- docs/roles/_meta/deploy-simplesamlphp.md | 9 +++++ docs/roles/api_call.md | 26 +++++++++++++ docs/roles/cli/cachetool.md | 2 +- .../cron_database_backup-mysql.md | 1 + docs/roles/cron/cron_drupal7.md | 6 ++- docs/roles/cron/cron_drupal8.md | 7 +++- docs/roles/database_backup.md | 2 +- .../database_backup/database_backup-mysql.md | 1 + docs/roles/deploy_code.md | 37 ++++++++++++++++++- .../sync/database_sync/database_sync-mysql.md | 10 +++++ roles/_init/README.md | 4 +- roles/api_call/README.md | 17 +++++++++ roles/cli/cachetool/README.md | 2 +- .../cron_database_backup-mysql/README.md | 1 + roles/cron/cron_drupal7/README.md | 6 ++- roles/cron/cron_drupal8/README.md | 7 +++- roles/database_backup/README.md | 2 +- .../database_backup-mysql/README.md | 1 + roles/deploy_code/README.md | 37 ++++++++++++++++++- .../database_sync-mysql/README.md | 10 +++++ 22 files changed, 178 insertions(+), 16 deletions(-) create mode 100644 docs/roles/_meta/deploy-simplesamlphp.md create mode 100644 docs/roles/api_call.md diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md index efa27c64..16139d8f 100644 --- a/docs/_Sidebar.md +++ b/docs/_Sidebar.md @@ -3,6 +3,7 @@ - [Install](/install) - [Usage](/scripts) - [Roles](roles) + - [API call](/roles/api_call) - [Config](/roles/cache_clear) - [Drupal 7](/roles/cache_clear/cache_clear-drupal7) - [Drupal 8](/roles/cache_clear/cache_clear-drupal8) @@ -37,6 +38,7 @@ - [Drupal 8](/roles/_meta/deploy-drupal8) - [Matomo](/roles/_meta/deploy-matomo) - [Mautic](/roles/_meta/deploy-mautic) + - [SimpleSAMLphp](/roles/_meta/deploy-simplesamlphp) - [NPM](/roles/npm) - [Sync roles](/roles/sync) - [Database sync](/roles/sync/database_sync) diff --git a/docs/roles/_init.md b/docs/roles/_init.md index f733d1a3..b0fdd6a7 100644 --- a/docs/roles/_init.md +++ b/docs/roles/_init.md @@ -10,14 +10,16 @@ These variables **must** be set in the `deploy/common.yml` file, at least. --- # Common defaults. Given the "_init" role is mandatory, # this will ensure defaults to other roles too. +# If you are using ce-provision to deploy infrastructure this must match the `user_deploy.username` variable deploy_user: "deploy" +_mysqldump_params: "--max-allowed-packet=128M --single-transaction --skip-opt -e --quick --skip-disable-keys --skip-add-locks -C -a --add-drop-table" drupal: sites: - folder: "default" public_files: "sites/default/files" # Drupal 8 variables config_sync_directory: "config/sync" - config_import_command: "" # i.e. "cim" + config_import_command: "" # i.e. "cim" - set this to "deploy" and cache rebuild and db updates will be skipped # End Drupal 8 variables # Drupal 7 variables revert_features_command: "" # i.e. "fra" diff --git a/docs/roles/_meta/deploy-simplesamlphp.md b/docs/roles/_meta/deploy-simplesamlphp.md new file mode 100644 index 00000000..3d82e671 --- /dev/null +++ b/docs/roles/_meta/deploy-simplesamlphp.md @@ -0,0 +1,9 @@ +# SimpleSAMLphp +Role for deploying single SimpleSAMLphp instances. Do not use if you are deploying SimpleSAMLphp with another application like Drupal via composer. + +This role currently assumes all config is in the repository alongside composer.json and the special `SIMPLESAMLPHP_CONFIG_DIR` variable is passed in via the web server vhost to tell SimpleSAMLphp where the config is on the server. For vhost configuration in Nginx see ce-provision: + +* https://github.com/codeenigma/ce-provision/blob/1.x/roles/nginx + + + diff --git a/docs/roles/api_call.md b/docs/roles/api_call.md new file mode 100644 index 00000000..15ea2788 --- /dev/null +++ b/docs/roles/api_call.md @@ -0,0 +1,26 @@ +# API call + +Making RESTful API calls to other platforms. + + + + + +## Default variables +```yaml +--- +api_call: + type: gitlab + base_url: https://gitlab.example.com/api/v4/ + path: projects # see documentation - https://docs.gitlab.com/ee/api/ + method: GET + token: "" # empty means anonymous action + token_type: trigger # options are 'trigger' or 'personal' + variables: [] + status_codes: + - 200 + - 201 + - 202 +``` + + diff --git a/docs/roles/cli/cachetool.md b/docs/roles/cli/cachetool.md index 833eb8fc..9cba4a32 100644 --- a/docs/roles/cli/cachetool.md +++ b/docs/roles/cli/cachetool.md @@ -5,7 +5,7 @@ Installs the `drush` command-line tool for the deploy user. ```yaml --- cachetool: - version: 8.2.2 + version: latest # # enter three-digit version number, e.g. "7.0.0", to install a specific version ``` diff --git a/docs/roles/cron/cron_database_backup/cron_database_backup-mysql.md b/docs/roles/cron/cron_database_backup/cron_database_backup-mysql.md index ee71e2bf..4d5bdab5 100644 --- a/docs/roles/cron/cron_database_backup/cron_database_backup-mysql.md +++ b/docs/roles/cron/cron_database_backup/cron_database_backup-mysql.md @@ -7,6 +7,7 @@ Ensure regular local backups of MySQL databases. cron_mysql_backup: dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/regular" keep: 10 + mysqldump_params: "{{ _mysqldump_params }}" # set in _init but you can override here ``` diff --git a/docs/roles/cron/cron_drupal7.md b/docs/roles/cron/cron_drupal7.md index 8222ddaf..14356d15 100644 --- a/docs/roles/cron/cron_drupal7.md +++ b/docs/roles/cron/cron_drupal7.md @@ -14,12 +14,16 @@ drupal: cron: # These are the relevant parts for cron. - minute: "*/{{ 10 | random(start=1) }}" # hour: 2 + # day: + # weekday: + # month: job: cron + # disabled: true # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] defer_target: "" - + drush_location: "{{ drush_bin }}" # you might specify another location, e.g. "{{ deploy_path }}/vendor/bin/drush" ``` diff --git a/docs/roles/cron/cron_drupal8.md b/docs/roles/cron/cron_drupal8.md index ae25adc4..bafd49b0 100644 --- a/docs/roles/cron/cron_drupal8.md +++ b/docs/roles/cron/cron_drupal8.md @@ -14,13 +14,16 @@ drupal: cron: # These are the relevant parts for cron. - minute: "*/{{ 10 | random(start=1) }}" # hour: 2 + # day: + # weekday: + # month: job: cron + # disabled: true # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] defer_target: "" - # Drush location when installed with Composer - drush_location: "vendor/drush/drush/drush" + drush_location: "{{ drush_bin }}" # you might specify another location, e.g. "{{ deploy_path }}/vendor/bin/drush" ``` diff --git a/docs/roles/database_backup.md b/docs/roles/database_backup.md index 947c8053..772efa70 100644 --- a/docs/roles/database_backup.md +++ b/docs/roles/database_backup.md @@ -7,7 +7,7 @@ Generate backups for each build. database_backup: engines: - mysql - + revert: true ``` diff --git a/docs/roles/database_backup/database_backup-mysql.md b/docs/roles/database_backup/database_backup-mysql.md index 5b0d7289..b52413bf 100644 --- a/docs/roles/database_backup/database_backup-mysql.md +++ b/docs/roles/database_backup/database_backup-mysql.md @@ -7,6 +7,7 @@ Generate MySQL backups for each build. mysql_backup: handling: rolling dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/build" + mysqldump_params: "{{ _mysqldump_params }}" # set in _init but you can override here # Number of dumps/db to keep. Note this is independant from the build codebases. keep: 10 # This can be one of the following: diff --git a/docs/roles/deploy_code.md b/docs/roles/deploy_code.md index bad0040f..4e371f28 100644 --- a/docs/roles/deploy_code.md +++ b/docs/roles/deploy_code.md @@ -11,7 +11,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' @@ -23,12 +23,45 @@ deploy_code: templates: [] # Number of builds to keep. Note this is independant of databases/dump. keep: 10 - # Wether to sync the local deploy base to a shared destination, after successful build. + # Whether to sync the local deploy base to a shared destination, after successful build. mount_sync: "" # mount_sync: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/deploy" + # Type of file to use for sync - 'squashfs' or 'tarball' + # @see the _init role for SquashFS build dir paths + # @see the squashfs role in ce-provision which installs the special conditions required by the deploy user to use this behaviour + mount_type: "tarball" # Path that you want to make sure has 755 permissions. Make sure to include the webroot WITHOUT the slash. perms_fix_path: "" # perms_fix_path: "www/sites/default" + # List of services to manipulate to free the loop device for 'squashfs' builds, post lazy umount. + # @see the squashfs role in ce-provision where special permissions for deploy user to manipulate services get granted. + services: [] + # services: + # - php8.0-fpm + # What action to take against the services, 'reload' or 'stop'. + # Busy websites will require a hard stop of services to achieve the umount command. + service_action: reload + # Trigger an API call to rebuild infra after a deploy, e.g. if you need to repack an AMI. + rebuild_infra: false + # Details of API call to trigger. See api_call role. + api_call: + type: gitlab + base_url: https://gitlab.example.com/api/v4/ + path: projects/1/ref/main/trigger/pipeline + method: POST + token: asdf-1234 + token_type: trigger + variables: [] + # example build parameters + # - "[ENV]=dev" + # - "[PLAY]=myserver.yml" + # - "[RESOURCE]=myserver-example-com" + # - "[REGION]=eu-west-1" + # - "[EXTRA_PARAMS]=--force" + status_codes: + - 200 + - 201 + - 202 ``` diff --git a/docs/roles/sync/database_sync/database_sync-mysql.md b/docs/roles/sync/database_sync/database_sync-mysql.md index bcb9c6ad..cf7e5311 100644 --- a/docs/roles/sync/database_sync/database_sync-mysql.md +++ b/docs/roles/sync/database_sync/database_sync-mysql.md @@ -5,6 +5,7 @@ Sync MySQL databases between environments. ```yaml --- mysql_sync: + mysqldump_params: "{{ _mysqldump_params }}" # set in _init but you can override here databases: - source: # Name of the database to take a dump from. @@ -20,6 +21,13 @@ mysql_sync: type: fixed # For "rolling builds", so we can compute the database name. build_id: mybuildprod + # Whether or not use to create a fresh database backup or use a nightly one. + fresh_db: true + # Location where nightly backups are kept. This must match the value set for cron_mysql_backup.dumps_directory. Below is the default. + # This var is only used when fresh_db is set to "false". + dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/regular" + # If the source is on an ASG, provide the ASG name here. Otherwise, leave empty. + asg: "" target: database: "{{ project_name }}_dev" credentials_file: "/home/{{ deploy_user }}/.mysql.creds" @@ -30,6 +38,8 @@ mysql_sync: type: fixed # For "rolling builds", so we can compute the database name. build_id: mybuilddev + # If the target is on an ASG, provide the ASG name here. Otherwise, leave empty. + asg: "" ``` diff --git a/roles/_init/README.md b/roles/_init/README.md index f733d1a3..b0fdd6a7 100644 --- a/roles/_init/README.md +++ b/roles/_init/README.md @@ -10,14 +10,16 @@ These variables **must** be set in the `deploy/common.yml` file, at least. --- # Common defaults. Given the "_init" role is mandatory, # this will ensure defaults to other roles too. +# If you are using ce-provision to deploy infrastructure this must match the `user_deploy.username` variable deploy_user: "deploy" +_mysqldump_params: "--max-allowed-packet=128M --single-transaction --skip-opt -e --quick --skip-disable-keys --skip-add-locks -C -a --add-drop-table" drupal: sites: - folder: "default" public_files: "sites/default/files" # Drupal 8 variables config_sync_directory: "config/sync" - config_import_command: "" # i.e. "cim" + config_import_command: "" # i.e. "cim" - set this to "deploy" and cache rebuild and db updates will be skipped # End Drupal 8 variables # Drupal 7 variables revert_features_command: "" # i.e. "fra" diff --git a/roles/api_call/README.md b/roles/api_call/README.md index 83d1ab28..15ea2788 100644 --- a/roles/api_call/README.md +++ b/roles/api_call/README.md @@ -6,4 +6,21 @@ Making RESTful API calls to other platforms. +## Default variables +```yaml +--- +api_call: + type: gitlab + base_url: https://gitlab.example.com/api/v4/ + path: projects # see documentation - https://docs.gitlab.com/ee/api/ + method: GET + token: "" # empty means anonymous action + token_type: trigger # options are 'trigger' or 'personal' + variables: [] + status_codes: + - 200 + - 201 + - 202 +``` + diff --git a/roles/cli/cachetool/README.md b/roles/cli/cachetool/README.md index 833eb8fc..9cba4a32 100644 --- a/roles/cli/cachetool/README.md +++ b/roles/cli/cachetool/README.md @@ -5,7 +5,7 @@ Installs the `drush` command-line tool for the deploy user. ```yaml --- cachetool: - version: 8.2.2 + version: latest # # enter three-digit version number, e.g. "7.0.0", to install a specific version ``` diff --git a/roles/cron/cron_database_backup/cron_database_backup-mysql/README.md b/roles/cron/cron_database_backup/cron_database_backup-mysql/README.md index ee71e2bf..4d5bdab5 100644 --- a/roles/cron/cron_database_backup/cron_database_backup-mysql/README.md +++ b/roles/cron/cron_database_backup/cron_database_backup-mysql/README.md @@ -7,6 +7,7 @@ Ensure regular local backups of MySQL databases. cron_mysql_backup: dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/regular" keep: 10 + mysqldump_params: "{{ _mysqldump_params }}" # set in _init but you can override here ``` diff --git a/roles/cron/cron_drupal7/README.md b/roles/cron/cron_drupal7/README.md index 8222ddaf..14356d15 100644 --- a/roles/cron/cron_drupal7/README.md +++ b/roles/cron/cron_drupal7/README.md @@ -14,12 +14,16 @@ drupal: cron: # These are the relevant parts for cron. - minute: "*/{{ 10 | random(start=1) }}" # hour: 2 + # day: + # weekday: + # month: job: cron + # disabled: true # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] defer_target: "" - + drush_location: "{{ drush_bin }}" # you might specify another location, e.g. "{{ deploy_path }}/vendor/bin/drush" ``` diff --git a/roles/cron/cron_drupal8/README.md b/roles/cron/cron_drupal8/README.md index ae25adc4..bafd49b0 100644 --- a/roles/cron/cron_drupal8/README.md +++ b/roles/cron/cron_drupal8/README.md @@ -14,13 +14,16 @@ drupal: cron: # These are the relevant parts for cron. - minute: "*/{{ 10 | random(start=1) }}" # hour: 2 + # day: + # weekday: + # month: job: cron + # disabled: true # If the sites are being deployed to an ASG, setting defer to true will create the crontab entry on the deploy server rather than all of the app servers. defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] defer_target: "" - # Drush location when installed with Composer - drush_location: "vendor/drush/drush/drush" + drush_location: "{{ drush_bin }}" # you might specify another location, e.g. "{{ deploy_path }}/vendor/bin/drush" ``` diff --git a/roles/database_backup/README.md b/roles/database_backup/README.md index 947c8053..772efa70 100644 --- a/roles/database_backup/README.md +++ b/roles/database_backup/README.md @@ -7,7 +7,7 @@ Generate backups for each build. database_backup: engines: - mysql - + revert: true ``` diff --git a/roles/database_backup/database_backup-mysql/README.md b/roles/database_backup/database_backup-mysql/README.md index 5b0d7289..b52413bf 100644 --- a/roles/database_backup/database_backup-mysql/README.md +++ b/roles/database_backup/database_backup-mysql/README.md @@ -7,6 +7,7 @@ Generate MySQL backups for each build. mysql_backup: handling: rolling dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/build" + mysqldump_params: "{{ _mysqldump_params }}" # set in _init but you can override here # Number of dumps/db to keep. Note this is independant from the build codebases. keep: 10 # This can be one of the following: diff --git a/roles/deploy_code/README.md b/roles/deploy_code/README.md index bad0040f..4e371f28 100644 --- a/roles/deploy_code/README.md +++ b/roles/deploy_code/README.md @@ -11,7 +11,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' @@ -23,12 +23,45 @@ deploy_code: templates: [] # Number of builds to keep. Note this is independant of databases/dump. keep: 10 - # Wether to sync the local deploy base to a shared destination, after successful build. + # Whether to sync the local deploy base to a shared destination, after successful build. mount_sync: "" # mount_sync: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/deploy" + # Type of file to use for sync - 'squashfs' or 'tarball' + # @see the _init role for SquashFS build dir paths + # @see the squashfs role in ce-provision which installs the special conditions required by the deploy user to use this behaviour + mount_type: "tarball" # Path that you want to make sure has 755 permissions. Make sure to include the webroot WITHOUT the slash. perms_fix_path: "" # perms_fix_path: "www/sites/default" + # List of services to manipulate to free the loop device for 'squashfs' builds, post lazy umount. + # @see the squashfs role in ce-provision where special permissions for deploy user to manipulate services get granted. + services: [] + # services: + # - php8.0-fpm + # What action to take against the services, 'reload' or 'stop'. + # Busy websites will require a hard stop of services to achieve the umount command. + service_action: reload + # Trigger an API call to rebuild infra after a deploy, e.g. if you need to repack an AMI. + rebuild_infra: false + # Details of API call to trigger. See api_call role. + api_call: + type: gitlab + base_url: https://gitlab.example.com/api/v4/ + path: projects/1/ref/main/trigger/pipeline + method: POST + token: asdf-1234 + token_type: trigger + variables: [] + # example build parameters + # - "[ENV]=dev" + # - "[PLAY]=myserver.yml" + # - "[RESOURCE]=myserver-example-com" + # - "[REGION]=eu-west-1" + # - "[EXTRA_PARAMS]=--force" + status_codes: + - 200 + - 201 + - 202 ``` diff --git a/roles/sync/database_sync/database_sync-mysql/README.md b/roles/sync/database_sync/database_sync-mysql/README.md index bcb9c6ad..cf7e5311 100644 --- a/roles/sync/database_sync/database_sync-mysql/README.md +++ b/roles/sync/database_sync/database_sync-mysql/README.md @@ -5,6 +5,7 @@ Sync MySQL databases between environments. ```yaml --- mysql_sync: + mysqldump_params: "{{ _mysqldump_params }}" # set in _init but you can override here databases: - source: # Name of the database to take a dump from. @@ -20,6 +21,13 @@ mysql_sync: type: fixed # For "rolling builds", so we can compute the database name. build_id: mybuildprod + # Whether or not use to create a fresh database backup or use a nightly one. + fresh_db: true + # Location where nightly backups are kept. This must match the value set for cron_mysql_backup.dumps_directory. Below is the default. + # This var is only used when fresh_db is set to "false". + dumps_directory: "/home/{{ deploy_user }}/shared/{{ project_name }}_{{ build_type }}/db_backups/mysql/regular" + # If the source is on an ASG, provide the ASG name here. Otherwise, leave empty. + asg: "" target: database: "{{ project_name }}_dev" credentials_file: "/home/{{ deploy_user }}/.mysql.creds" @@ -30,6 +38,8 @@ mysql_sync: type: fixed # For "rolling builds", so we can compute the database name. build_id: mybuilddev + # If the target is on an ASG, provide the ASG name here. Otherwise, leave empty. + asg: "" ``` From 0afd94082d09b177d10428f2da33db9f36c8954b Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 17:08:17 +0100 Subject: [PATCH 02/20] Consistent drush handling in cron. --- roles/cron/cron_drupal7/defaults/main.yml | 1 + roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/defaults/main.yml | 3 +-- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/cron/cron_drupal7/defaults/main.yml b/roles/cron/cron_drupal7/defaults/main.yml index ef3ab79f..419e9c4b 100644 --- a/roles/cron/cron_drupal7/defaults/main.yml +++ b/roles/cron/cron_drupal7/defaults/main.yml @@ -16,3 +16,4 @@ drupal: defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] defer_target: "" + drush_location: "{{ drush_bin }}" # you might specify another location, e.g. "{{ deploy_path }}/vendor/bin/drush" \ No newline at end of file diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index dd18979c..eb88ddad 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} {{ entry.job }}" + _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_location }} {{ entry.job }}" - name: Define cron job command if deferred (ASG). ansible.builtin.set_fact: diff --git a/roles/cron/cron_drupal8/defaults/main.yml b/roles/cron/cron_drupal8/defaults/main.yml index 913eb530..9d4b90f6 100644 --- a/roles/cron/cron_drupal8/defaults/main.yml +++ b/roles/cron/cron_drupal8/defaults/main.yml @@ -16,5 +16,4 @@ drupal: defer: false # If defer is set to true, the Ansible target must be declared with defer_target. If using a group, include the index. For example, _ce_www_dev[0] defer_target: "" - # Drush location when installed with Composer - drush_location: "vendor/drush/drush/drush" + drush_location: "{{ drush_bin }}" # you might specify another location, e.g. "{{ deploy_path }}/vendor/bin/drush" diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index 908abff6..eb88ddad 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ deploy_path }}/{{ drupal.drush_location }} {{ entry.job }}" + _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_location }} {{ entry.job }}" - name: Define cron job command if deferred (ASG). ansible.builtin.set_fact: From 566efe9bd49f6f06dd2985157c6b0e6dfd57d392 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 17:31:08 +0100 Subject: [PATCH 03/20] Linting cruft and removing unimplemented drush.yml handling from D7. --- .../config_generate-drupal7/tasks/drush.yml | 10 ---------- .../config_generate-drupal7/tasks/main.yml | 10 +--------- .../config_generate-drupal8/tasks/drush.yml | 3 +-- .../config_generate-drupal8/tasks/main.yml | 4 ++-- .../config_generate-matomo/tasks/main.yml | 3 +-- .../config_generate-mautic/tasks/main.yml | 11 +++++------ roles/config_generate/tasks/main.yml | 7 +++---- 7 files changed, 13 insertions(+), 35 deletions(-) delete mode 100644 roles/config_generate/config_generate-drupal7/tasks/drush.yml diff --git a/roles/config_generate/config_generate-drupal7/tasks/drush.yml b/roles/config_generate/config_generate-drupal7/tasks/drush.yml deleted file mode 100644 index 9c85eb9d..00000000 --- a/roles/config_generate/config_generate-drupal7/tasks/drush.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- - -- name: Generates drush.yml file. - template: - src: '{{ item }}' - dest: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}/drush.yml" - with_first_found: - - "{{ playbook_dir }}/{{ webroot }}/sites/{{ site.folder }}/{{ build_type }}.drush.yml.j2" - - "{{ _ce_deploy_build_dir }}/{{ webroot }}/sites/{{ site.folder }}/{{ build_type }}.drush.yml" - - "drush.yml.j2" \ No newline at end of file diff --git a/roles/config_generate/config_generate-drupal7/tasks/main.yml b/roles/config_generate/config_generate-drupal7/tasks/main.yml index b984fd58..23781ded 100644 --- a/roles/config_generate/config_generate-drupal7/tasks/main.yml +++ b/roles/config_generate/config_generate-drupal7/tasks/main.yml @@ -1,14 +1,6 @@ --- - name: Generates settings file. - include_tasks: settings.yml + ansible.builtin.include_tasks: settings.yml with_items: "{{ drupal.sites }}" loop_control: loop_var: site - -#- name: Generates Drush settings file. -# include_tasks: drush.yml -# when: -# - site.base_url is defined -# with_items: "{{ drupal.sites }}" -# loop_control: -# loop_var: site diff --git a/roles/config_generate/config_generate-drupal8/tasks/drush.yml b/roles/config_generate/config_generate-drupal8/tasks/drush.yml index 9c85eb9d..f4b7ae7a 100644 --- a/roles/config_generate/config_generate-drupal8/tasks/drush.yml +++ b/roles/config_generate/config_generate-drupal8/tasks/drush.yml @@ -1,7 +1,6 @@ --- - - name: Generates drush.yml file. - template: + ansible.builtin.template: src: '{{ item }}' dest: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}/drush.yml" with_first_found: diff --git a/roles/config_generate/config_generate-drupal8/tasks/main.yml b/roles/config_generate/config_generate-drupal8/tasks/main.yml index cd3c19fd..3db5bf60 100644 --- a/roles/config_generate/config_generate-drupal8/tasks/main.yml +++ b/roles/config_generate/config_generate-drupal8/tasks/main.yml @@ -1,12 +1,12 @@ --- - name: Generates settings file. - include_tasks: settings.yml + ansible.builtin.include_tasks: settings.yml with_items: "{{ drupal.sites }}" loop_control: loop_var: site - name: Generates Drush settings file. - include_tasks: drush.yml + ansible.builtin.include_tasks: drush.yml when: - site.base_url is defined with_items: "{{ drupal.sites }}" diff --git a/roles/config_generate/config_generate-matomo/tasks/main.yml b/roles/config_generate/config_generate-matomo/tasks/main.yml index 505ff3ce..e5482e65 100644 --- a/roles/config_generate/config_generate-matomo/tasks/main.yml +++ b/roles/config_generate/config_generate-matomo/tasks/main.yml @@ -1,7 +1,6 @@ --- - - name: Generates config file. - template: + ansible.builtin.template: src: '{{ item }}' dest: "{{ deploy_path }}/{{ webroot }}/config/config.ini.php" with_first_found: diff --git a/roles/config_generate/config_generate-mautic/tasks/main.yml b/roles/config_generate/config_generate-mautic/tasks/main.yml index d1da20c5..2a9d63d0 100644 --- a/roles/config_generate/config_generate-mautic/tasks/main.yml +++ b/roles/config_generate/config_generate-mautic/tasks/main.yml @@ -1,15 +1,14 @@ --- - -- name: set public files path. - set_fact: +- name: Set public files path. + ansible.builtin.set_fact: build_image_path: "{{ mautic.image_path }}" -- name: set private files path. - set_fact: +- name: Set private files path. + ansible.builtin.set_fact: build_upload_dir: "{{ deploy_assets_base_path }}/{{ project_name }}_{{ build_type }}_private_files" - name: Generates local.php file. - template: + ansible.builtin.template: src: '{{ item }}' dest: "{{ deploy_path }}/{{ webroot }}/app/config/local.php" with_first_found: diff --git a/roles/config_generate/tasks/main.yml b/roles/config_generate/tasks/main.yml index 3bce314b..2af08e87 100644 --- a/roles/config_generate/tasks/main.yml +++ b/roles/config_generate/tasks/main.yml @@ -1,12 +1,11 @@ --- - - name: Generate project specific configuration. - include_role: + ansible.builtin.include_role: name: "config_generate/config_generate-{{ project_type }}" when: deploy_operation == 'deploy' - name: Generate additional templates. - template: + ansible.builtin.template: src: "{{ template.src }}" dest: "{{ deploy_path }}/{{ template.dest }}" with_items: "{{ config_generate.templates }}" @@ -17,7 +16,7 @@ - deploy_operation == 'deploy' - name: Create additional symlinks. - file: + ansible.builtin.file: src: "{{ link.src }}" dest: "{{ deploy_path }}/{{ link.dest }}" state: link From 27b178dec7f478f50dbd627ad3964baffb2a8ae6 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 17:37:44 +0100 Subject: [PATCH 04/20] Refactor drush role to support new GitHub release format. --- docs/roles/cli/drush.md | 7 +++--- roles/_init/tasks/drupal7.yml | 2 +- roles/_init/tasks/drupal8.yml | 2 +- roles/cli/drush/README.md | 7 +++--- roles/cli/drush/defaults/main.yml | 4 ++-- roles/cli/drush/tasks/main.yml | 36 ++++++++++++++++++++++++++----- 6 files changed, 43 insertions(+), 15 deletions(-) diff --git a/docs/roles/cli/drush.md b/docs/roles/cli/drush.md index 30f02549..8dd3b43c 100644 --- a/docs/roles/cli/drush.md +++ b/docs/roles/cli/drush.md @@ -1,13 +1,14 @@ # Drush -Installs the `drush` command-line tool for the deploy user. +Installs the `drush` command-line tool for the deploy user. Note, this role only supports `drush` version 9 and above. + ## Default variables ```yaml --- drush: # Note: This is the "default" version, - # but projects should define theirs in composer.json. - version: 8.2.2 + # but projects should define theirs in composer.json or in their ce-deploy variables files. + version: 11.4.0 use_vendor: false ``` diff --git a/roles/_init/tasks/drupal7.yml b/roles/_init/tasks/drupal7.yml index 6487564c..719c1ecb 100644 --- a/roles/_init/tasks/drupal7.yml +++ b/roles/_init/tasks/drupal7.yml @@ -1,7 +1,7 @@ --- - name: Define Drush path. set_fact: - drush_bin: "{{ drush_bin | default('/home/{{ deploy_user }}/.bin/drush.phar') }}" + drush_bin: "{{ drush_bin | default('/home/{{ deploy_user }}/.bin/drush') }}" - name: Ensure we have Drush binary. import_role: diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index 6487564c..719c1ecb 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -1,7 +1,7 @@ --- - name: Define Drush path. set_fact: - drush_bin: "{{ drush_bin | default('/home/{{ deploy_user }}/.bin/drush.phar') }}" + drush_bin: "{{ drush_bin | default('/home/{{ deploy_user }}/.bin/drush') }}" - name: Ensure we have Drush binary. import_role: diff --git a/roles/cli/drush/README.md b/roles/cli/drush/README.md index 30f02549..8dd3b43c 100644 --- a/roles/cli/drush/README.md +++ b/roles/cli/drush/README.md @@ -1,13 +1,14 @@ # Drush -Installs the `drush` command-line tool for the deploy user. +Installs the `drush` command-line tool for the deploy user. Note, this role only supports `drush` version 9 and above. + ## Default variables ```yaml --- drush: # Note: This is the "default" version, - # but projects should define theirs in composer.json. - version: 8.2.2 + # but projects should define theirs in composer.json or in their ce-deploy variables files. + version: 11.4.0 use_vendor: false ``` diff --git a/roles/cli/drush/defaults/main.yml b/roles/cli/drush/defaults/main.yml index 68ff2c66..58da2a79 100644 --- a/roles/cli/drush/defaults/main.yml +++ b/roles/cli/drush/defaults/main.yml @@ -1,6 +1,6 @@ --- drush: # Note: This is the "default" version, - # but projects should define theirs in composer.json. - version: 8.2.2 + # but projects should define theirs in composer.json or in their ce-deploy variables files. + version: 11.4.0 use_vendor: false \ No newline at end of file diff --git a/roles/cli/drush/tasks/main.yml b/roles/cli/drush/tasks/main.yml index 4d27aa3e..ab5dcac0 100644 --- a/roles/cli/drush/tasks/main.yml +++ b/roles/cli/drush/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Check if we already have a global Drush. - stat: + ansible.builtin.stat: path: "{{ drush_bin }}" register: drush_global when: @@ -16,22 +16,48 @@ register: drush_global_directory - name: Check if installed Drush version match. - shell: "{{ drush_bin }} --version | grep -o '[0-9]\\.[0-9]\\.[0-9]'" + ansible.builtin.shell: "{{ drush_bin }} --version | grep -o '[0-9]\\.[0-9]\\.[0-9]'" register: drush_global_version when: - deploy_operation == 'deploy' - drush_global.stat.exists - not drush.use_vendor -- name: Download Drush installer. - get_url: +# @TODO - we can remove this when Drupal 7 reaches EOL. +- name: Download Drush installer for Drupal 7. + ansible.builtin.get_url: url: "https://github.com/drush-ops/drush/releases/download/{{ drush.version }}/drush.phar" dest: "{{ drush_bin }}" mode: 0755 + force: true when: - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version + - drush.version < 9 + +- name: Download Drush archive. + ansible.builtin.get_url: + url: "https://github.com/drush-ops/drush/archive/refs/tags/{{ drush.version }}.tar.gz" + dest: /tmp/drush.tar.gz + mode: 0755 + force: true + when: + - deploy_operation == 'deploy' + - not drush.use_vendor + - not drush_global.stat.exists or not drush_global_version.stdout == drush.version + - drush.version >= 9 + +- name: "Extract drush.tar.gz into {{ drush_bin | dirname }}" + ansible.builtin.unarchive: + src: /tmp/drush.tar.gz + dest: "{{ drush_bin | dirname }}" + mode: 0755 + when: + - deploy_operation == 'deploy' + - not drush.use_vendor + - not drush_global.stat.exists or not drush_global_version.stdout == drush.version + - drush.version >= 9 - name: Create .bashrc file if it does not exist ansible.builtin.file: @@ -49,7 +75,7 @@ - deploy_operation == 'deploy' - name: Trigger Drush init tasks. - command: "{{ drush_bin }} init -y" + ansible.builtin.command: "{{ drush_bin }} init -y" when: - deploy_operation == 'deploy' - not drush.use_vendor From 1f6fae40cb7a7413a14722f7adc323108b004d94 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 17:40:29 +0100 Subject: [PATCH 05/20] Updating drush README. --- docs/roles/cli/drush.md | 2 +- roles/cli/drush/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/roles/cli/drush.md b/docs/roles/cli/drush.md index 8dd3b43c..ca7301c0 100644 --- a/docs/roles/cli/drush.md +++ b/docs/roles/cli/drush.md @@ -1,5 +1,5 @@ # Drush -Installs the `drush` command-line tool for the deploy user. Note, this role only supports `drush` version 9 and above. +Installs the `drush` command-line tool for the deploy user. Note, support for `drush` version 8 and below will be withdrawn with [Drupal 7 EOL](https://www.drupal.org/psa-2022-02-23). ## Default variables diff --git a/roles/cli/drush/README.md b/roles/cli/drush/README.md index 8dd3b43c..ca7301c0 100644 --- a/roles/cli/drush/README.md +++ b/roles/cli/drush/README.md @@ -1,5 +1,5 @@ # Drush -Installs the `drush` command-line tool for the deploy user. Note, this role only supports `drush` version 9 and above. +Installs the `drush` command-line tool for the deploy user. Note, support for `drush` version 8 and below will be withdrawn with [Drupal 7 EOL](https://www.drupal.org/psa-2022-02-23). ## Default variables From 064278b4e3c7e227102818a721215d5facbd8e53 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 18:32:15 +0100 Subject: [PATCH 06/20] Casting the first part of the drush version string as an integer. --- roles/cli/drush/tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/cli/drush/tasks/main.yml b/roles/cli/drush/tasks/main.yml index ab5dcac0..cf353b4f 100644 --- a/roles/cli/drush/tasks/main.yml +++ b/roles/cli/drush/tasks/main.yml @@ -34,7 +34,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - drush.version < 9 + - drush.version[0] | int < 9 - name: Download Drush archive. ansible.builtin.get_url: @@ -46,7 +46,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - drush.version >= 9 + - drush.version[0] | int >= 9 - name: "Extract drush.tar.gz into {{ drush_bin | dirname }}" ansible.builtin.unarchive: @@ -57,7 +57,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - drush.version >= 9 + - drush.version[0] | int >= 9 - name: Create .bashrc file if it does not exist ansible.builtin.file: From 2717f1008b94ba85579619185fbe1f2b2fd07fb2 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 18:38:04 +0100 Subject: [PATCH 07/20] Refactoring integer handling. --- roles/cli/drush/tasks/main.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/roles/cli/drush/tasks/main.yml b/roles/cli/drush/tasks/main.yml index cf353b4f..d1677571 100644 --- a/roles/cli/drush/tasks/main.yml +++ b/roles/cli/drush/tasks/main.yml @@ -1,4 +1,8 @@ --- +- name: Set Drush major version integer. + ansible.builtin.set_fact: + _drush_major_version: "{{ drush.version[0] | int }}" + - name: Check if we already have a global Drush. ansible.builtin.stat: path: "{{ drush_bin }}" @@ -34,7 +38,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - drush.version[0] | int < 9 + - _drush_major_version < 9 - name: Download Drush archive. ansible.builtin.get_url: @@ -46,7 +50,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - drush.version[0] | int >= 9 + - _drush_major_version >= 9 - name: "Extract drush.tar.gz into {{ drush_bin | dirname }}" ansible.builtin.unarchive: @@ -57,7 +61,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - drush.version[0] | int >= 9 + - _drush_major_version >= 9 - name: Create .bashrc file if it does not exist ansible.builtin.file: From 7d874c255b343d00e9924f87da6a1f8098f40f0a Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 18:51:43 +0100 Subject: [PATCH 08/20] Major version string will always be a string, assuming below 8 will never exist. --- roles/cli/drush/tasks/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/cli/drush/tasks/main.yml b/roles/cli/drush/tasks/main.yml index d1677571..a1e2f499 100644 --- a/roles/cli/drush/tasks/main.yml +++ b/roles/cli/drush/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Set Drush major version integer. ansible.builtin.set_fact: - _drush_major_version: "{{ drush.version[0] | int }}" + _drush_major_version: "{{ drush.version[0] }}" - name: Check if we already have a global Drush. ansible.builtin.stat: @@ -38,7 +38,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - _drush_major_version < 9 + - _drush_major_version == '8' - name: Download Drush archive. ansible.builtin.get_url: @@ -50,7 +50,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - _drush_major_version >= 9 + - _drush_major_version != '8' - name: "Extract drush.tar.gz into {{ drush_bin | dirname }}" ansible.builtin.unarchive: @@ -61,7 +61,7 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - _drush_major_version >= 9 + - _drush_major_version != '8' - name: Create .bashrc file if it does not exist ansible.builtin.file: From 3a12d1db246f3e02c1b56af26b32feff2ebca715 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 18:56:22 +0100 Subject: [PATCH 09/20] Downloaded drush archive is remote, not local. --- roles/cli/drush/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/cli/drush/tasks/main.yml b/roles/cli/drush/tasks/main.yml index a1e2f499..6e653f69 100644 --- a/roles/cli/drush/tasks/main.yml +++ b/roles/cli/drush/tasks/main.yml @@ -57,6 +57,7 @@ src: /tmp/drush.tar.gz dest: "{{ drush_bin | dirname }}" mode: 0755 + remote_src: true when: - deploy_operation == 'deploy' - not drush.use_vendor From 8bf50964156239badfe7a099d2ec7df5de4a91a1 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Tue, 24 Jan 2023 19:08:11 +0100 Subject: [PATCH 10/20] Refactoring handling of .bin directory. --- roles/_init/defaults/main.yml | 1 + roles/_init/tasks/drupal7.yml | 2 +- roles/_init/tasks/drupal8.yml | 2 +- roles/cli/drush/tasks/main.yml | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/roles/_init/defaults/main.yml b/roles/_init/defaults/main.yml index 432485d9..b38c1e59 100644 --- a/roles/_init/defaults/main.yml +++ b/roles/_init/defaults/main.yml @@ -25,3 +25,4 @@ drupal: mautic: image_path: "media/images" force_install: false +bin_directory: "/home/{{ deploy_user }}/.bin" \ No newline at end of file diff --git a/roles/_init/tasks/drupal7.yml b/roles/_init/tasks/drupal7.yml index 719c1ecb..c84bb0be 100644 --- a/roles/_init/tasks/drupal7.yml +++ b/roles/_init/tasks/drupal7.yml @@ -1,7 +1,7 @@ --- - name: Define Drush path. set_fact: - drush_bin: "{{ drush_bin | default('/home/{{ deploy_user }}/.bin/drush') }}" + drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush-{{ drush.version }}/drush') }}" - name: Ensure we have Drush binary. import_role: diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index 719c1ecb..c84bb0be 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -1,7 +1,7 @@ --- - name: Define Drush path. set_fact: - drush_bin: "{{ drush_bin | default('/home/{{ deploy_user }}/.bin/drush') }}" + drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush-{{ drush.version }}/drush') }}" - name: Ensure we have Drush binary. import_role: diff --git a/roles/cli/drush/tasks/main.yml b/roles/cli/drush/tasks/main.yml index 6e653f69..e9212209 100644 --- a/roles/cli/drush/tasks/main.yml +++ b/roles/cli/drush/tasks/main.yml @@ -17,6 +17,7 @@ when: - deploy_operation == 'deploy' - not drush.use_vendor + - _drush_major_version == '8' register: drush_global_directory - name: Check if installed Drush version match. @@ -52,10 +53,10 @@ - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - _drush_major_version != '8' -- name: "Extract drush.tar.gz into {{ drush_bin | dirname }}" +- name: "Extract drush.tar.gz into {{ bin_directory }}" ansible.builtin.unarchive: src: /tmp/drush.tar.gz - dest: "{{ drush_bin | dirname }}" + dest: "{{ bin_directory }}" mode: 0755 remote_src: true when: From af3fc4642a24d7908c01879614392170c321f36f Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 10:14:31 +0100 Subject: [PATCH 11/20] Supporting drush-launcher. --- roles/_init/tasks/drupal7.yml | 2 +- roles/_init/tasks/drupal8.yml | 2 +- roles/cli/drush/tasks/main.yml | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/roles/_init/tasks/drupal7.yml b/roles/_init/tasks/drupal7.yml index c84bb0be..f6a2abbd 100644 --- a/roles/_init/tasks/drupal7.yml +++ b/roles/_init/tasks/drupal7.yml @@ -1,7 +1,7 @@ --- - name: Define Drush path. set_fact: - drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush-{{ drush.version }}/drush') }}" + drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush') }}" - name: Ensure we have Drush binary. import_role: diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index c84bb0be..f6a2abbd 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -1,7 +1,7 @@ --- - name: Define Drush path. set_fact: - drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush-{{ drush.version }}/drush') }}" + drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush') }}" - name: Ensure we have Drush binary. import_role: diff --git a/roles/cli/drush/tasks/main.yml b/roles/cli/drush/tasks/main.yml index e9212209..a5c8eee9 100644 --- a/roles/cli/drush/tasks/main.yml +++ b/roles/cli/drush/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Set Drush major version integer. +- name: Set Drush major version. ansible.builtin.set_fact: _drush_major_version: "{{ drush.version[0] }}" @@ -41,6 +41,19 @@ - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - _drush_major_version == '8' +# Standalone drush requires the drush-launcher from version 9.x onwards. +- name: Download Drush Launcher for standalone Drush. + ansible.builtin.get_url: + url: https://github.com/drush-ops/drush-launcher/releases/latest/download/drush.phar + dest: "{{ drush_bin }}" + mode: 0755 + force: true + when: + - deploy_operation == 'deploy' + - not drush.use_vendor + - not drush_global.stat.exists or not drush_global_version.stdout == drush.version + - _drush_major_version != '8' + - name: Download Drush archive. ansible.builtin.get_url: url: "https://github.com/drush-ops/drush/archive/refs/tags/{{ drush.version }}.tar.gz" From 4a16a5d197d4b5b342aea9b1bbf785558cc8c349 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 10:48:24 +0100 Subject: [PATCH 12/20] Removing drush installation support for Drupal 8 and above. --- docs/roles/_init.md | 2 +- docs/roles/cli/drush.md | 9 ++++--- roles/_init/README.md | 2 +- roles/_init/tasks/drupal8.yml | 6 +---- roles/cli/drush/README.md | 9 ++++--- roles/cli/drush/defaults/main.yml | 5 ++-- roles/cli/drush/tasks/main.yml | 44 ------------------------------- 7 files changed, 15 insertions(+), 62 deletions(-) diff --git a/docs/roles/_init.md b/docs/roles/_init.md index b0fdd6a7..1c7e835e 100644 --- a/docs/roles/_init.md +++ b/docs/roles/_init.md @@ -34,7 +34,7 @@ drupal: mautic: image_path: "media/images" force_install: false - +bin_directory: "/home/{{ deploy_user }}/.bin" ``` diff --git a/docs/roles/cli/drush.md b/docs/roles/cli/drush.md index ca7301c0..41b673c2 100644 --- a/docs/roles/cli/drush.md +++ b/docs/roles/cli/drush.md @@ -1,14 +1,15 @@ # Drush -Installs the `drush` command-line tool for the deploy user. Note, support for `drush` version 8 and below will be withdrawn with [Drupal 7 EOL](https://www.drupal.org/psa-2022-02-23). +Installs the `drush` command-line tool for the deploy user. **This only works with Drupal 7** and will be withdrawn with [Drupal 7 EOL](https://www.drupal.org/psa-2022-02-23). + +For Drupal 8 and above you must install `drush` with `composer` [as described in the `drush` documentation](https://www.drush.org/latest/install/). ## Default variables ```yaml --- drush: - # Note: This is the "default" version, - # but projects should define theirs in composer.json or in their ce-deploy variables files. - version: 11.4.0 + # Where possible always load drush in your Drupal website with composer. + version: 8.4.11 use_vendor: false ``` diff --git a/roles/_init/README.md b/roles/_init/README.md index b0fdd6a7..1c7e835e 100644 --- a/roles/_init/README.md +++ b/roles/_init/README.md @@ -34,7 +34,7 @@ drupal: mautic: image_path: "media/images" force_install: false - +bin_directory: "/home/{{ deploy_user }}/.bin" ``` diff --git a/roles/_init/tasks/drupal8.yml b/roles/_init/tasks/drupal8.yml index f6a2abbd..ebe63b82 100644 --- a/roles/_init/tasks/drupal8.yml +++ b/roles/_init/tasks/drupal8.yml @@ -1,8 +1,4 @@ --- - name: Define Drush path. set_fact: - drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush') }}" - -- name: Ensure we have Drush binary. - import_role: - name: cli/drush + drush_bin: "{{ drush_bin | default('{{ deploy_path }}/vendor/bin/drush') }}" diff --git a/roles/cli/drush/README.md b/roles/cli/drush/README.md index ca7301c0..41b673c2 100644 --- a/roles/cli/drush/README.md +++ b/roles/cli/drush/README.md @@ -1,14 +1,15 @@ # Drush -Installs the `drush` command-line tool for the deploy user. Note, support for `drush` version 8 and below will be withdrawn with [Drupal 7 EOL](https://www.drupal.org/psa-2022-02-23). +Installs the `drush` command-line tool for the deploy user. **This only works with Drupal 7** and will be withdrawn with [Drupal 7 EOL](https://www.drupal.org/psa-2022-02-23). + +For Drupal 8 and above you must install `drush` with `composer` [as described in the `drush` documentation](https://www.drush.org/latest/install/). ## Default variables ```yaml --- drush: - # Note: This is the "default" version, - # but projects should define theirs in composer.json or in their ce-deploy variables files. - version: 11.4.0 + # Where possible always load drush in your Drupal website with composer. + version: 8.4.11 use_vendor: false ``` diff --git a/roles/cli/drush/defaults/main.yml b/roles/cli/drush/defaults/main.yml index 58da2a79..746fce44 100644 --- a/roles/cli/drush/defaults/main.yml +++ b/roles/cli/drush/defaults/main.yml @@ -1,6 +1,5 @@ --- drush: - # Note: This is the "default" version, - # but projects should define theirs in composer.json or in their ce-deploy variables files. - version: 11.4.0 + # Where possible always load drush in your Drupal website with composer. + version: 8.4.11 use_vendor: false \ No newline at end of file diff --git a/roles/cli/drush/tasks/main.yml b/roles/cli/drush/tasks/main.yml index a5c8eee9..5c73be51 100644 --- a/roles/cli/drush/tasks/main.yml +++ b/roles/cli/drush/tasks/main.yml @@ -1,8 +1,4 @@ --- -- name: Set Drush major version. - ansible.builtin.set_fact: - _drush_major_version: "{{ drush.version[0] }}" - - name: Check if we already have a global Drush. ansible.builtin.stat: path: "{{ drush_bin }}" @@ -17,7 +13,6 @@ when: - deploy_operation == 'deploy' - not drush.use_vendor - - _drush_major_version == '8' register: drush_global_directory - name: Check if installed Drush version match. @@ -28,7 +23,6 @@ - drush_global.stat.exists - not drush.use_vendor -# @TODO - we can remove this when Drupal 7 reaches EOL. - name: Download Drush installer for Drupal 7. ansible.builtin.get_url: url: "https://github.com/drush-ops/drush/releases/download/{{ drush.version }}/drush.phar" @@ -39,44 +33,6 @@ - deploy_operation == 'deploy' - not drush.use_vendor - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - _drush_major_version == '8' - -# Standalone drush requires the drush-launcher from version 9.x onwards. -- name: Download Drush Launcher for standalone Drush. - ansible.builtin.get_url: - url: https://github.com/drush-ops/drush-launcher/releases/latest/download/drush.phar - dest: "{{ drush_bin }}" - mode: 0755 - force: true - when: - - deploy_operation == 'deploy' - - not drush.use_vendor - - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - _drush_major_version != '8' - -- name: Download Drush archive. - ansible.builtin.get_url: - url: "https://github.com/drush-ops/drush/archive/refs/tags/{{ drush.version }}.tar.gz" - dest: /tmp/drush.tar.gz - mode: 0755 - force: true - when: - - deploy_operation == 'deploy' - - not drush.use_vendor - - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - _drush_major_version != '8' - -- name: "Extract drush.tar.gz into {{ bin_directory }}" - ansible.builtin.unarchive: - src: /tmp/drush.tar.gz - dest: "{{ bin_directory }}" - mode: 0755 - remote_src: true - when: - - deploy_operation == 'deploy' - - not drush.use_vendor - - not drush_global.stat.exists or not drush_global_version.stdout == drush.version - - _drush_major_version != '8' - name: Create .bashrc file if it does not exist ansible.builtin.file: From 0a78b6b28cb3e525db08eb7d821e8ef6d06cf881 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 11:02:29 +0100 Subject: [PATCH 13/20] Bad variable name in Drupal cron jobs. --- roles/cron/cron_drupal7/tasks/job.yml | 2 +- roles/cron/cron_drupal8/tasks/job.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index eb88ddad..b89a0b05 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_location }} {{ entry.job }}" + _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }}" - name: Define cron job command if deferred (ASG). ansible.builtin.set_fact: diff --git a/roles/cron/cron_drupal8/tasks/job.yml b/roles/cron/cron_drupal8/tasks/job.yml index eb88ddad..b89a0b05 100644 --- a/roles/cron/cron_drupal8/tasks/job.yml +++ b/roles/cron/cron_drupal8/tasks/job.yml @@ -1,7 +1,7 @@ --- - name: Define cron job command. ansible.builtin.set_fact: - _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_location }} {{ entry.job }}" + _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drupal.drush_location }} {{ entry.job }}" - name: Define cron job command if deferred (ASG). ansible.builtin.set_fact: From d171218af4f8e3369a9be62f7824073029f89504 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 11:40:15 +0100 Subject: [PATCH 14/20] Fixing maintenance mode command linting and consistency. --- roles/_init/tasks/drupal7.yml | 2 +- .../maintenance_mode-drupal-core/tasks/main.yml | 2 +- .../maintenance_mode-drupal-core/tasks/offline.yml | 4 ++-- .../maintenance_mode-drupal-core/tasks/online.yml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/_init/tasks/drupal7.yml b/roles/_init/tasks/drupal7.yml index f6a2abbd..133b3d73 100644 --- a/roles/_init/tasks/drupal7.yml +++ b/roles/_init/tasks/drupal7.yml @@ -1,7 +1,7 @@ --- - name: Define Drush path. set_fact: - drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush') }}" + drush_bin: "{{ drush_bin | default('{{ bin_directory }}/drush.phar') }}" - name: Ensure we have Drush binary. import_role: diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/main.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/main.yml index 0633bc75..ccc2c2cf 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/main.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/main.yml @@ -1,5 +1,5 @@ --- -- include_tasks: "{{ maintenance_mode.operation }}.yml" +- ansible.builtin.include_tasks: "{{ maintenance_mode.operation }}.yml" with_items: "{{ drupal.sites }}" loop_control: loop_var: site diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml index cbe65b07..0bc742f7 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml @@ -1,7 +1,7 @@ --- # @todo this needs refactoring for multisite. - name: Enable maintenance mode. - command: + ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer" chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" @@ -11,7 +11,7 @@ - project_type == 'drupal8' - name: Enable maintenance mode D7. - shell: + ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 1" chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml index e6a9cbf5..4f733933 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml @@ -1,6 +1,6 @@ --- - name: Disable maintenance mode. - command: + ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer" chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" @@ -9,7 +9,7 @@ - project_type == 'drupal8' - name: Disable maintenance mode D7. - shell: + ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 0" chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" From 148152fccb86f51156f40a968224472395ab8dfa Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 12:18:37 +0100 Subject: [PATCH 15/20] Moving chdir to args to see if it helps. --- .../maintenance_mode-drupal-core/tasks/offline.yml | 3 ++- .../maintenance_mode-drupal-core/tasks/online.yml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml index 0bc742f7..fdac0dd6 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml @@ -1,8 +1,8 @@ --- -# @todo this needs refactoring for multisite. - name: Enable maintenance mode. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer" + args: chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" @@ -13,6 +13,7 @@ - name: Enable maintenance mode D7. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 1" + args: chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml index 4f733933..9159bbb8 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml @@ -2,6 +2,7 @@ - name: Disable maintenance mode. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer" + args: chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" @@ -11,6 +12,7 @@ - name: Disable maintenance mode D7. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 0" + args: chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" From 4b1c4d013930fcf12e433b8d4651b6721ced9f89 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 12:24:02 +0100 Subject: [PATCH 16/20] Trying an actual 'cd' command inline. --- .../maintenance_mode-drupal-core/tasks/offline.yml | 2 +- .../maintenance_mode-drupal-core/tasks/online.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml index fdac0dd6..a6fb9687 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml @@ -1,7 +1,7 @@ --- - name: Enable maintenance mode. ansible.builtin.command: - cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer" + cmd: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer" args: chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml index 9159bbb8..4e489332 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml @@ -1,7 +1,7 @@ --- - name: Disable maintenance mode. ansible.builtin.command: - cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer" + cmd: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer" args: chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" From fb0510fff6769a5d8705bbb5247a12dd75b3161b Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 12:30:25 +0100 Subject: [PATCH 17/20] Cannot '&&' in a cmd. --- .../maintenance_mode-drupal-core/tasks/offline.yml | 2 +- .../maintenance_mode-drupal-core/tasks/online.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml index a6fb9687..fdac0dd6 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml @@ -1,7 +1,7 @@ --- - name: Enable maintenance mode. ansible.builtin.command: - cmd: "cd {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer" + cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer" args: chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml index 4e489332..9159bbb8 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml @@ -1,7 +1,7 @@ --- - name: Disable maintenance mode. ansible.builtin.command: - cmd: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer" + cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer" args: chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" From 1351508beb6232db4b404aa549b116b044cfcf35 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 14:32:38 +0100 Subject: [PATCH 18/20] Trying drush's --root flag to set Drupal path. --- .../maintenance_mode-drupal-core/tasks/offline.yml | 4 ++-- .../maintenance_mode-drupal-core/tasks/online.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml index fdac0dd6..5fd4ddd0 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml @@ -1,7 +1,7 @@ --- - name: Enable maintenance mode. ansible.builtin.command: - cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer" + cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer --root {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" args: chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" @@ -12,7 +12,7 @@ - name: Enable maintenance mode D7. ansible.builtin.command: - cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 1" + cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 1 --root {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" args: chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml index 9159bbb8..8337c968 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml @@ -1,7 +1,7 @@ --- - name: Disable maintenance mode. ansible.builtin.command: - cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer" + cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer --root {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" args: chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" @@ -11,7 +11,7 @@ - name: Disable maintenance mode D7. ansible.builtin.command: - cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 0" + cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 0 --root {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" args: chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" From d07aaf798a8f5699ed669f9411db2810e2bcd9d8 Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 14:39:44 +0100 Subject: [PATCH 19/20] With --root we do not need chdir for drush. --- .../maintenance_mode-drupal-core/tasks/offline.yml | 4 ---- .../maintenance_mode-drupal-core/tasks/online.yml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml index 5fd4ddd0..52bdd2d2 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml @@ -2,8 +2,6 @@ - name: Enable maintenance mode. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer --root {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" - args: - chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" when: @@ -13,8 +11,6 @@ - name: Enable maintenance mode D7. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 1 --root {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" - args: - chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" when: diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml index 8337c968..9d3ed62d 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml @@ -2,8 +2,6 @@ - name: Disable maintenance mode. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer --root {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" - args: - chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" when: @@ -12,8 +10,6 @@ - name: Disable maintenance mode D7. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 0 --root {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" - args: - chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" when: From a4435817694c07117170d2dc0c605fb7d2796e7c Mon Sep 17 00:00:00 2001 From: gregharvey Date: Wed, 25 Jan 2023 14:45:16 +0100 Subject: [PATCH 20/20] Revert "With --root we do not need chdir for drush." This reverts commit d07aaf798a8f5699ed669f9411db2810e2bcd9d8. --- .../maintenance_mode-drupal-core/tasks/offline.yml | 4 ++++ .../maintenance_mode-drupal-core/tasks/online.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml index 52bdd2d2..5fd4ddd0 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/offline.yml @@ -2,6 +2,8 @@ - name: Enable maintenance mode. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 1 --input-format=integer --root {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" + args: + chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" when: @@ -11,6 +13,8 @@ - name: Enable maintenance mode D7. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 1 --root {{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" + args: + chdir: "{{ live_symlink_dest }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" when: diff --git a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml index 9d3ed62d..8337c968 100644 --- a/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml +++ b/roles/maintenance_mode/maintenance_mode-drupal-core/tasks/online.yml @@ -2,6 +2,8 @@ - name: Disable maintenance mode. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} state:set system.maintenance_mode 0 --input-format=integer --root {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" + args: + chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" when: @@ -10,6 +12,8 @@ - name: Disable maintenance mode D7. ansible.builtin.command: cmd: "{{ drush_bin }} -l {{ site.folder }} vset maintenance_mode 0 --root {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" + args: + chdir: "{{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }}" become: "{{ 'no' if www_user == deploy_user else 'yes' }}" become_user: "{{ www_user }}" when: