diff --git a/roles/cron/cron_drupal7/defaults/main.yml b/roles/cron/cron_drupal7/defaults/main.yml index a09c1036..a6551ab6 100644 --- a/roles/cron/cron_drupal7/defaults/main.yml +++ b/roles/cron/cron_drupal7/defaults/main.yml @@ -8,6 +8,7 @@ drupal: - minute: "*/{{ 10 | random(start=1) }}" # hour: 2 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] diff --git a/roles/cron/cron_drupal7/tasks/cron.yml b/roles/cron/cron_drupal7/tasks/cron.yml index 2bc2c6c7..056d50e0 100644 --- a/roles/cron/cron_drupal7/tasks/cron.yml +++ b/roles/cron/cron_drupal7/tasks/cron.yml @@ -1,6 +1,6 @@ --- - name: Setup Drupal 7 cron tasks. - include_tasks: + ansible.builtin.include_tasks: file: job.yml with_items: "{{ site.cron }}" loop_control: diff --git a/roles/cron/cron_drupal7/tasks/job.yml b/roles/cron/cron_drupal7/tasks/job.yml index 841c4b51..0f1d3203 100644 --- a/roles/cron/cron_drupal7/tasks/job.yml +++ b/roles/cron/cron_drupal7/tasks/job.yml @@ -1,10 +1,10 @@ --- - name: Define cron job command. - set_fact: + ansible.builtin.set_fact: _cron_job_command: "cd {{ deploy_path }}/{{ webroot }}/sites/{{ site.folder }} && {{ drush_bin }} {{ entry.job }}" - name: Define cron job command if deferred (ASG). - set_fact: + ansible.builtin.set_fact: _cron_job_command: "cd {{ _ce_deploy_base_dir }} && {{ _ce_deploy_ansible_location }} {{ drupal.defer_target }} -m shell -a \"{{ _cron_job_command }}\"" when: - drupal.defer is defined @@ -13,7 +13,7 @@ - drupal.defer_target | length > 0 - name: Define cron job command for differing deploy users. - set_fact: + ansible.builtin.set_fact: _cron_job_command: "{{ _cron_job_command }} --extra-vars '{\"become\":true,\"become_user\":\"{{ www_user }}\"}'" when: - www_user != deploy_user @@ -21,9 +21,11 @@ - drupal.defer - name: Setup Drupal cron tasks on app server. - cron: + ansible.builtin.cron: name: "{{ project_name }}_{{ site.folder }}_{{ build_type }}_{{ entry.job }}" minute: "{{ entry.minute }}" hour: "{{ entry.hour | default(omit) }}" job: "{{ _cron_job_command }}" + state: present + disabled: "{{ entry.disabled | default(omit) }}" delegate_to: "{{ 'localhost' if drupal.defer else inventory_hostname }}" diff --git a/roles/cron/cron_drupal7/tasks/main.yml b/roles/cron/cron_drupal7/tasks/main.yml index 75fa05c7..cf0f80f6 100644 --- a/roles/cron/cron_drupal7/tasks/main.yml +++ b/roles/cron/cron_drupal7/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Setup PATH in crontab. - cron: + ansible.builtin.cron: name: PATH env: true job: "/usr/bin:/usr/local/bin:/bin:/home/{{ deploy_user }}/.bin" @@ -10,7 +10,7 @@ - drupal.defer - name: Create site cron entries. - include_tasks: + ansible.builtin.include_tasks: file: cron.yml with_items: "{{ drupal.sites }}" loop_control: