{"id":18593279,"url":"https://github.com/acromedia/ansible-role-drupal-cron","last_synced_at":"2026-02-28T13:32:43.826Z","repository":{"id":37847347,"uuid":"152339960","full_name":"AcroMedia/ansible-role-drupal-cron","owner":"AcroMedia","description":"Set up the linux job to trigger Cron on a locally installed Drupal site","archived":false,"fork":false,"pushed_at":"2024-07-31T21:20:01.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-07T17:51:27.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AcroMedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-10T00:39:39.000Z","updated_at":"2024-07-31T21:20:05.000Z","dependencies_parsed_at":"2024-08-01T01:42:33.195Z","dependency_job_id":null,"html_url":"https://github.com/AcroMedia/ansible-role-drupal-cron","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AcroMedia/ansible-role-drupal-cron","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AcroMedia%2Fansible-role-drupal-cron","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AcroMedia%2Fansible-role-drupal-cron/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AcroMedia%2Fansible-role-drupal-cron/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AcroMedia%2Fansible-role-drupal-cron/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AcroMedia","download_url":"https://codeload.github.com/AcroMedia/ansible-role-drupal-cron/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AcroMedia%2Fansible-role-drupal-cron/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29935368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T13:16:57.922Z","status":"ssl_error","status_checked_at":"2026-02-28T13:11:15.149Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T01:11:54.341Z","updated_at":"2026-02-28T13:32:43.793Z","avatar_url":"https://github.com/AcroMedia.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# ansible-role-drupal-cron\n\n![.github/workflows/molecule.yml](https://github.com/AcroMedia/ansible-role-drupal-cron/workflows/.github/workflows/molecule.yml/badge.svg)\n\nSet up a linux cron job to trigger Drupal Cron on a locally installed site.\n\nThis role isn't usually added after a site is up and running, since it requires the cron URL, which won't exist until after the site has been configured.\n\n## Dependencies / Requirements\nIf specifying `drupal_cron_url`, cURL already needs to be installed on the server.\n\nIf specifying `drupal_cron_doc_root` + `drupal_cron_drush_path`, Drush needs to already be installed on the server.\n\n## Role Variables\n\n### **drupal_cron_job_name** - required\n\nTechnically, this is optional for backwards compatibility, but this really needs to be **carefully defined, and then never changed again**. It simply needs to be unique string per environment, since ansible uses it as an anchor to find and edit the correct job on the server.\n\nThe original default for this was based on the value of `server_name` to avoid creating duplicate jobs on servers with multiple vhosts. The problem with that approach is that `server_name` may change across the lifespan of a website, which ends up creeating duplicate jobs. (see issue [#1](https://github.com/AcroMedia/ansible-role-drupal-cron/issues/1)).\n\n### **linux_owner** - required\nThe name of the linux account to create the cron job under.\n\nBe aware of permissions implications:\n\n- For curl mode (see below), the linux owner only needs to be able to execute curl commands.\n\n- For drush or custom modes (see below), **linux_owner** must be able to modify the files that PHP created. E.g. if you run PHP FPM, and your PHP process runs as its own user, that's who you need create the job under. If your PHP files are created by the www-data or apache user, that's who you need to create the cron job under.\n\n### **server_name** - required\nThe fully qualified domain name part of your drupal cron URL (e.g. 'www.example.com', without any protocol or slashes). This should match the \"server_name\" variable of your Apache or NGINX virtual host.\n\n## Cron modes:\n\nThe role suppports 3 different modes for setting up a cron job. The variables you set automatically determine the mode.\n\n- **cURL mode** (best for Drupal \u003c= 7)\n\n  ```yaml\n  drupal_cron_job_name: Drupal cron for bigcorp production\n  drupal_cron_url: 'https://www.example.com/cron/abcdefgh12345678'\n  ```\n  - When cron url is specified, the role creates a cURL command cron job.\n  - The command includes cURL's `--resolve` switch, which maps `{{ server_name }}` to `127.0.0.1`. This is so cURL doens't try and hit a server's public interface from behind a firewall, which would normally time out.\n\n\n- **Drush CLI mode** (best for Drupal \u003e= 8)\n\n  ```yaml\n  drupal_cron_job_name: Drupal cron for bigcorp production\n  drupal_cron_doc_root: '/var/bigcorp/www/ecomsite/web'\n  linux_owner: ecom-srv\n  drupal_cron_drush_path: '../vendor/drush/drush/drush'\n  ```\n\n  - When doc root + drush path are specified, the role constructs a drush CLI command cron job. The value for `drupal_cron_doc_root` must be the absolute path to directory you'd normally execute Drush commands from the command line. The value for `drupal_cron_drush_path` can either be relative to the doc root, or an absolute path.\n\n\n- **Custom mode**\n\n  If neither of the above two constructors provide what you need, you can specify your own arbitrary shell command to execute in the cron job:\n\n  ```yaml\n  drupal_cron_job_name: Drupal cron for bigcorp production\n  linux_owner: someuser\n  drupal_cron_command: \u003e\n    cd /path/to/someplace \u0026\u0026 /usr/local/bin/custom-stuff.sh --foo-bar\n  ```\n\n## Changing the value of `server_name`\n\nIf your playbook already uses `drupal_cron_job_name`, you're free to change `server_name` without any impact.\n\nIf you haven't yet defined `drupal_cron_job_name`, then simply look up the current value of the job's name (`sudo crontab -l -u \u003clinux_user\u003e`), which will look something like this:\n```\n#Ansible: Drupal cron trigger for www.example.com\n          \\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/ this is the job name\n```\nand add `drupal_cron_job_name: \u003ccurrent job name\u003e` to your playbook.\n\nEven though the job name will be 'wrong' after your `server_name` changes, the job will not be duplicated.\n\nObviously, you can also just delete the current job and let the playbook create a new one, but if your app is spread across a lot of servers, that could be tedious.\n\n## Removing a cron job\n\nTo remove a cron job, append \n```\ndrupal_cron_job_state: absent\n```\nto your variables and run your playbook. You must leave the existing ones you have in place, so that Ansible can find and target the job to remove. \n\nOnce you've run your playbook to remove the cron job, you can then remove the rest of the drupal cron variables.\n\n## Role defaults\n\n\n### `every_x_minutes` (integer) = 15\nHow often you want your cron job to run.\n\nFor more granularity, you can specify `drupal_cron_hour` and `drupal_cron_minute` instead.\n\n**See also**: defaults/main.yml for undocumented defaults.\n\n\n\n## Example\n\n* **Pro tip no. 1:** Avoid running the role against more than one node of a multi-server application.\n\n* **Pro tip no. 2:** Don't ever re-use any ansible role twice in the same play. Split up role instances into individual plays to avoid variable bleed.\n\n```yaml\n---\n- name: Gather facts as its own play. Subsequent plays against\n        the same server don't need to gather facts.\n  hosts: my-primary-app-node   \n  become: true\n  gather_facts: true\n  roles: []\n  tasks: []\n\n- hosts: my-primary-app-node   \n  become: true\n  gather_facts: false\n  roles:\n   - name: Set up Drupal cron for site no. 1 - cURL mode\n     role: acromedia.drupal-cron\n     vars:\n       linux_owner: blog1\n       server_name: blog.bigcorp.com\n       drupal_cron_job_name: Drupal cron for bigcorp blog production\n       drupal_cron_url: 'https://{{ server_name }}/cron.php?cron_key=abcdefgh12345678'\n       every_x_minutes: 5\n     tags:\n       - cron\n  tasks: []\n\n- hosts: my-primary-app-node   \n  become: true\n  gather_facts: false\n  roles:\n   - name: Set up Drupal cron for site no. 2 - Drush mode\n     role: acromedia.drupal-cron\n     vars:\n       linux_owner: www-data\n       drupal_cron_job_name: Drupal cron for bigcorp shop production\n       server_name: shop.bigcorp.com\n       drupal_cron_doc_root: /var/www/vhosts/shop1/web\n       drupal_cron_drush_path: ../vendor/drush/drush/drush\n     tags:\n       - cron\n  tasks: []\n```\n\n## License\nGPL3\n\n## Author Information\nAcro Media Inc., https://www.acromedia.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facromedia%2Fansible-role-drupal-cron","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facromedia%2Fansible-role-drupal-cron","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facromedia%2Fansible-role-drupal-cron/lists"}