I have a large Ansible playbook where Docker images are built when running it. I am using an increasing number as the tag to version them. Currently, I have to specify this in e
I know this might not answer OP's query exactly, but for people googling to set global variables(lists/arrays) so that they don't have to set them in each task this might be pretty handy.
Its surprisingly simple, Say you have a list of domains that you need to pass, I named the variable goofy just to signify that it could be anything.
- hosts: [yourhostlistgoeshere]
remote_user: root
vars:
domainslisto:
- site1.com
- website2.xyz
....
tasks:
- name: copy vhosts
template: src=virtualhost.conf dest=/etc/apache2/sites-available/{{ item }}.conf
with_items: "{{ domainslisto }}"
- name: a2ensite {{ item }}
command: a2ensite {{ item }}
with_items: "{{ domainslisto }}"