loops - Run playbook file on particular days -


i new ansible, need execute 1 playbook file 7 days alone , 8th day need run playbook file. how can set using ansible? have tried @ module it's not applicable that. how can set conditions per requirement?

i have created sample job using ansible. in need run job every day once , 7 days alone, specify 24 hrs once in hour filed , in day field 01-07. here code:

- - cron:         name: "play mail"         hour: "24"         day: "01-07"         job: "sh script.sh" 

i able run code without error , job created have seen using crontab -l. executes once. not every 24 hrs of 7 days. whether it's correct per requirement?

i'm not sure understand need.

if have start playbook on control machine x days, don't think need cron module. make crontab entry crontab -e on control machine scheduled 7 days, , second 1 8th. crontab entries on control machine run like:

# every day @ midnight 0 0 * * * /usr/bin/ansible-playbook -i inventory playbook1_7.yml  # every 8 days 0 0 */8 * * /usr/bin/ansible-playbook -i inventory playbook8.yml 

you can refine timing testing on http://www.cronsandbox.com/

ansible cron module useful if playbook has manage crontab entries on target hosts, control machine run playbook create, update, remove or check crontab entries on remote hosts. of course run playbook on localhost too.

in ansible cron module "days" means "day of month". 01-07 should schedule job run 1st 7th day of months.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -