opoplawski
(Orion Poplawski)
1
I find myself writing this over and over again:
- template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: radiusd
mode: "0640"
loop:
- { src: clients.conf.j2, dest: /etc/raddb/clients.conf }
- { src: proxy.conf.j2, dest: /etc/raddb/proxy.conf }
What about being able to do something like:
- template:
args_var: item
owner: root
group: radiusd
mode: "0640"
loop:
- { src: clients.conf.j2, dest: /etc/raddb/clients.conf }
- { src: proxy.conf.j2, dest: /etc/raddb/proxy.conf }
Not so dramatic with only two parameters, but I have some with 5 or moe.
opoplawski
(Orion Poplawski)
3
I'm not sure what you are trying to say. This doesn't work because what I'm
proposing doesn't exist.
But I'm wondering if it is worth proposing it as an enhancement.
You could use module_defaults https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_module_defaults.html
- template:
owner: root
group: radiusd
mode: “0640”
module_defaults:
template: “{{ item }}”
loop:
- { src: clients.conf.j2, dest: /etc/raddb/clients.conf }
- { src: proxy.conf.j2, dest: /etc/raddb/proxy.conf }
Or/additionally arg splatting (which can be unsafe in some cases if https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars is True):
- template: “{{ item }}”
module_defaults:
template:
owner: root
group: radiusd
mode: “0640”
loop:
- { src: clients.conf.j2, dest: /etc/raddb/clients.conf }
- { src: proxy.conf.j2, dest: /etc/raddb/proxy.conf }