I previous tried to define the array at the begining of the playbook in the vars section, but it only accepts key/value pairs, not an array. Maybe my syntax was incorrect. Is there an example of an array being defined in the vars section somewhere?
On Wednesday, December 11, 2013 11:53:44 AM UTC-5, David Karban wrote: > > Hi, > > either define variable on the beggining of the play like here: > > http://www.ansibleworks.com/docs/playbooks_variables.html#variables-defined-in-a-playbook > > or, better use group vars, or host vars: > > http://www.ansibleworks.com/docs/playbooks_best_practices.html#group-and-host-variables > > David > > > > 2013/12/11 Michael Baydoun <[email protected] <javascript:>> > >> Can the following be refactored so the following array only appears once >> in the code? >> >> - [ '/home/youruser/a', '/home/youruser/b', '/home/youruser/c', >> '/home/youruser/d' ] >> >> >> --- >> >> - hosts: yourhost >> >> user: root >> >> gather_facts: no >> >> tasks: >> >> - lineinfile: dest={{ item[0] }}/.gitignore create=yes regexp='{{ >> item[1] }}' line='*.{{ item[1] }}' >> >> with_nested: >> >> - [ '/home/youruser/a', '/home/youruser/b', '/home/youruser/c', >> '/home/youruser/d' ] >> >> - [ 'lck', 'log', 'Log' ] >> >> - shell: /usr/bin/git init chdir={{ item[0] }} >> >> with_items: >> >> - [ '/home/youruser/a', '/home/youruser/b', '/home/youruser/c', >> '/home/youruser/d' ] >> >> - shell: /usr/bin/git add -A ; /usr/bin/git commit -m 'auto'; exit 0 >> chdir={{ item[0] }} >> >> with_items: >> >> - [ '/home/youruser/a', '/home/youruser/b', '/home/youruser/c', >> '/home/youruser/d' ] >> >> -- >> 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 [email protected] <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > David Karban > Specialista na správu linuxových serverů > www.karban.eu > -- 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 [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
