Passing Dictionaries of Dictonaries in Ansible

36 views
Skip to first unread message

Ume

unread,
Nov 28, 2022, 8:07:17 AM11/28/22
to Ansible Project
I wanted to simulate the JINJA  template   bheaviour using set_facts for WIndows Patching using Ansible. I am doing the below however, getting error
Sorry New to Ansible here. Attcahed Screenshots. 

1.PNG

 - name: Sample Dictionary for Windows Update Patches
      set_fact:
        - dict_updates:
              - {'key': 'e0951aaf', 'value': {'title': 'Windows KB5017396', 'kb': ['5017396'], 'categories': ['Security Updates', 'Windows Server 2016'], 'id': 'e0951aaf', 'downloaded': True, 'installed': True},
         {'key': 'e0951aed', 'value': {'title': 'Windows KB5012356', 'kb': ['5012356'], 'categories': ['Security Updates', 'Windows Server 2019'], 'id': 'e0951aed', 'downloaded': True, 'installed': True},
        {'key': 'e0761aag', 'value': {'title': 'Windows KB5016326', 'kb': ['5016326'], 'categories': ['Security Updates', 'Windows Server 2022'], 'id': 'e0761aag', 'downloaded': True, 'installed': True},
        {'key': 'e0911aae', 'value': {'title': 'Windows KB5013397', 'kb': ['5013397'], 'categories': ['Security Updates', 'Windows Server 2016'], 'id': 'e0911aae', 'downloaded': True, 'installed': True},}


Not in situation to run whole playbook for getting these values automatically for testing JINJA template

Todd Lewis

unread,
Nov 28, 2022, 8:16:22 AM11/28/22
to Ansible Project
You don't say what error you are getting, but you have 8 open braces ("{") and 5 close braces ("}"), so errors are not surprising.

Ume

unread,
Nov 28, 2022, 8:23:50 AM11/28/22
to Ansible Project
The error even after fixing braces, ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

Rowe, Walter P. (Fed)

unread,
Nov 28, 2022, 8:33:09 AM11/28/22
to ansible...@googlegroups.com
Also check your indentation. set_fact should align with name.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

-- 
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/dba0d2c0-8089-4634-9eb6-21fdac019d60n%40googlegroups.com.

Ume

unread,
Nov 28, 2022, 8:40:39 AM11/28/22
to Ansible Project
Thanks you walter, however, no errors found, if i am keeping only one dictonary, problems is coming with dictioanry containing multiple dicotnaries. 1.PNG
The above contains only one screenshot. 

Todd Lewis

unread,
Nov 28, 2022, 8:52:47 AM11/28/22
to ansible...@googlegroups.com, Ume, uto...@gmail.com
But you didn't show us — and by "show" I mean copy-n-paste the text, not a picture of — the input. If you're going to show us errors and not what produced them, and then have us ask you to show us your inputs every time, this is going to take hours.

Email is cheap. Please include all relevant input, "relevant" meaning complete enough so we can run it ourselves, not just what you think must contain the problem. Because if you knew what the problem was, you'd fix it yourself and not need to ask. Far better to include more than less.
--
Todd

Ume

unread,
Nov 28, 2022, 9:11:41 AM11/28/22
to Ansible Project
Hello Todd,
Thanks for you reply. Now I have changed this, executing fine. Attached for your references. Only intention is to simulate input values to JINJA template.

Reply all
Reply to author
Forward
0 new messages