Answer the question
In order to leave comments, you need to log in
How to create a job in cron using Ansible?
I want to create a playbook with the ability to record jobs in cron with running a script, but only at different times for all hosts.
There is this playbook:
---
- name: Create cron task
hosts: testhost0
tasks:
- name: Add tasks to testhost0
cron:
name: "download tasks"
minute: "0"
hour: "1"
job: "/home/userdir/./download.sh"
- name: Create cron task
hosts: testhost1
tasks:
- name: Add tasks to testhost1
cron:
name: "download tasks"
minute: "0"
hour: "2"
job: "/home/userdir/./download.sh"
etc
ignore_errors: yes
, but it only works if there is an error, not when the host is not available. Answer the question
In order to leave comments, you need to log in
You write the playbook a little incorrectly to solve this problem. Place the necessary servers in the inventory and set different variables for them with the start time. After that, for this group of hosts, run a playbook that adds a task to the cron. You will get a playbook that works on all available hosts and with individual parameters, consisting of only one task
I seem to work out the norms with ignore EU
try to install the latest version
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question