Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible with_items keeps overwriting last line of loop

This is my playbook. Pretty simple. The problem is with the "with_items". It iterates over all the items, but, it only writes the last item to the crontab file. I think it is overwriting it. Why is this happening?

- name: Create cron jobs to send emails                                       
  cron:                                                                                        
    name="Send emails"                                                          
    state=present                                                                              
    special_time=daily                                                                         
    job="/home/testuser/deployments/{{ item }}/artisan --env={{
item }} send:healthemail"                                                                 
  with_items:
      - london 
      - toronto
      - vancouver    
like image 623
jasonaburton Avatar asked Jan 18 '16 19:01

jasonaburton


1 Answers

The cron module expects the job name to be unique. Change it to:

name="Send emails {{ item }}"

See: cron – Manage cron.d and crontab entries

like image 76
helloV Avatar answered Oct 20 '22 11:10

helloV