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’ ]
Can the following be refactored so the following array only appears once in the code?
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
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?
There are (at least) two ways to do it that both seem to work as expected:
[will@tangerine test]$ cat var_array.yml