How can I create and pass a dynamic dictionary as a module parameter. I have a custom module that accepts parameters:
`
How can I create and pass a dynamic dictionary as a module parameter. I have a custom module that accepts parameters:
`
Just make the constructed parameters a list of maps:
#+begin_src ansible
#!/usr/bin/ansible-playbook
- hosts: localhost
tasks:
- set_fact:
var1: x
value1: 100
var2: y
value2: 200
- debug: var=item
with_items: "{{ [ { var1: value1 }, { var2: value2 } ] }}"
#+end_src
Output:
#+begin_src text
TASK [debug] *******************************************************************
ok: [localhost] => (item={u'x': 100}) => {
"item": {
"x": 100
}
}
ok: [localhost] => (item={u'y': 200}) => {
"item": {
"y": 200
}
}
#+end_src
Thank you very much!!