Cron with_items hash + spaces

488 views
Skip to first unread message

BrianAI

unread,
Dec 13, 2013, 2:59:47 PM12/13/13
to ansible...@googlegroups.com
Another question folks.

When I try the following bit of code, it seems to choke:

 10 - name: set cron for any cron-able scripts
 11   cron: name={{ item.name }}  job={{ item.job }} state=present
 12   with_items:
 13         - { name: Gather stuff, job: do stuff }
 14         - { name: "Check Response Codes", job: "sleep 5; /etc/server1/scripts/check_files > /tmp/check_files_results" }


However, if I do the following, it works:


 10 - name: set cron for any cron-able scripts
 11   cron: name={{ item.name }}  job={{ item.job }} state=present
 12   with_items:
 13         - { name: Gather, job: do }
 14         - { name: "Check", job: "sleep" }


Basically, it seems the spaces are throwing things off.  I've tried with single quotes, double quotes, etc. etc.
Below, is the error:

 
failed: [server1] => (item={'job': 'do stuff', 'name': 'Gather stuff'}) => {"failed": true, "item": {"job": "do stuff", "name": "Gather stuff"}}
msg: this module requires key=value arguments (['name=Gather', 'stuff', 'job=do', 'stuff', 'state=present'])
failed: [server1] => (item={'job': 'sleep 5; /etc/server1/scripts/check_files > /tmp/check_files_results', 'name': 'Check Response Codes'}) => {"failed": true, "item": {"job": "sleep 5; /etc/server1/scripts/check_files > /tmp/check_files_results", "name": "Check Response Codes"}}
msg: this module requires key=value arguments (['name=Check', 'Response', 'Codes', 'job=sleep', '5;', '/etc/server1/scripts/check_files', '>', '/tmp/check_files_results', 'state=present'])


Michael DeHaan

unread,
Dec 13, 2013, 6:00:46 PM12/13/13
to ansible...@googlegroups.com
param="{{ var }}"

-- Michael
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

BrianAI

unread,
Dec 13, 2013, 10:21:24 PM12/13/13
to ansible...@googlegroups.com
a lot closer!  i should have thought of / realized that.  Looks like something is still not happy:


  8 - name: set cron for any cron-able scripts
  9   cron: name= "{{ item.name }}"  job= "{{ item.job }}" state=present
 10   with_items:
 11         - { name: 'Check Response Codes', job: 'sleep 5; /etc/server1/scripts/check_files > /tmp/check_files_results' }
 12   tags:
 13        - server1.scripts




failed: [server1] => (item={'job': 'sleep 5; /etc/server1/scripts/check_files > /tmp/check_files_results', 'name': 'Check Response Codes'}) => {"failed": true, "item": {"job": "sleep 5; /etc/server1/scripts/check_files > /tmp/check_files_results", "name": "Check Response Codes"}}
msg: this module requires key=value arguments (['name=', 'Check Response Codes', 'job=', 'sleep 5; /etc/server1/scripts/check_files > /tmp/check_files_results', 'state=present', 'CHECKMODE=True'])

FATAL: all hosts have already failed -- aborting

 

BrianAI

unread,
Dec 13, 2013, 11:12:30 PM12/13/13
to ansible...@googlegroups.com
so it seems the space after name= " was the problem.

The reason I put that space there is because the syntax highlighting in VIM completely got thrown off by having name="....but either way (even with the bad syntax highlighting), it still works properly now that i have name="

Thanks!!!! :)
Reply all
Reply to author
Forward
0 new messages