Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions roles/cron/cron_drupal7/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion roles/cron/cron_drupal7/tasks/cron.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 6 additions & 4 deletions roles/cron/cron_drupal7/tasks/job.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,17 +13,19 @@
- 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
- drupal.defer is defined
- 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 }}"
4 changes: 2 additions & 2 deletions roles/cron/cron_drupal7/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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:
Expand Down