I've got the following list of dictionaries inside my variables file:
apache_vhosts:
- servername: "example.com"
serveralias: "www.example.com"
username: example
crons:
- minute: "*/15 * * * *"
command: "curl example.com"
- servername: "foobarr.com"
serveralias: "www.foobar.com"
username: foobar
crons:
- minute: "*/15 * * * *"
command: "curl example.com"
I want to loop over the crons so I can set them via the Ansible built-in cron module.
For example:
- name: Setup the required crons
cron:
name: Set a cron to cURL site
minute: "{{ item.minute }}"
job: "{{ item.command }}"
loop: "{{ apache_vhosts['crons]' }}"
Debugging this I know I'm not getting out the right data. Any pointers for what the correct loop should be here?