I want to run a task where the parameters are filled using with_items, rather than having to manually write parameter:{{item.key}}
. For example, I have this host var:
HtpasswdsToSet:
- path: /etc/nginx/passwdfile
name: janedoe
password: 'abc123'
- path: /etc/nginx/passwdfile
name: bob
password: '123abc'
Note that the dictionary list keys are actual htpasswd task parameters.
In the playbook, instead of doing this:
- name: add htpasswd users
htpasswd:
path: {{item.path}}
name: {{item.name}}
password: '{{item.password}}'
with_items: "{{HtpasswdsToSet}}"
Is there some way to simply do this?
- name: add htpasswd users
htpasswd: "{{HtpasswdsToSet}}"
This would really help me reduce playbook verbosity. Thank you.