On Wed, 30 Nov 2016 09:02:45 -0800 (PST) Mumshad Mannambeth
<[email protected]> wrote:
MM> with_dict:
MM> "{'{{var1}}': '{{value1}}'}"
MM> But item is in key:value format {key: var1, value: value1} , instead I need
MM> it in format - { var1 : value1 }
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
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/87mvggop8a.fsf%40lifelogs.com.
For more options, visit https://groups.google.com/d/optout.