# Ansible facts, parse values in dict

**URL:** <https://forum.ansible.com/t/ansible-facts-parse-values-in-dict/28192>\
**Category:** Ansible Project\
**Created:** [July 30, 2018, 12:32pm UTC](https://forum.ansible.com/t/ansible-facts-parse-values-in-dict/28192 "2018-07-30T12:32:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![D11](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@D11](https://forum.ansible.com/u/D11)\
**Post date:** [July 30, 2018, 12:32pm UTC](https://forum.ansible.com/t/ansible-facts-parse-values-in-dict/28192/1 "2018-07-30T12:32:34Z")

</div>

Hello,

I am using setup module to generate some facts and register it to "ansible\_facts" variable,

Now i want to parse "ansible\_facts" variable and remove some key value pairs, how can i parse it ?

I tried different filters but none of them worked for me, any guidance on this please ?

Thanks,  
DJ

---

<div class="post-metadata">

**Author:** ![Patrick\_Hunt](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Patrick\_Hunt](https://forum.ansible.com/u/Patrick_Hunt)\
**Post date:** [July 30, 2018, 3:31pm UTC](https://forum.ansible.com/t/ansible-facts-parse-values-in-dict/28192/2 "2018-07-30T15:31:26Z")

</div>

When I encounter issues when using a variable I will use the _debug_ module. By adding something like

`

- debug:  
var: somevar  
`  
into the playbook during execution it will output all of the fields and values associated with the variable.

You can also specify fields to call out, i.e.

`

- debug:  
var: somevar.field1  
`

or

`

- debug:  
var: somevar[‘field1’]  
`

With some trial and error I am usually able to determine the best way to reference a variable/field combo.

---

<div class="post-metadata">

**Author:** ![D11](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@D11](https://forum.ansible.com/u/D11)\
**Post date:** [July 31, 2018, 1:49am UTC](https://forum.ansible.com/t/ansible-facts-parse-values-in-dict/28192/3 "2018-07-31T01:49:00Z")

</div>

Ok,i do use variable and i am able to find out which one is causing issue, now question is from ansible-facts output how can i remove some key, value pairs.

---

<div class="post-metadata">

**Author:** ![Patrick\_Hunt](https://avatars.discourse-cdn.com/v4/letter/p/c68b51/32.png) [@Patrick\_Hunt](https://forum.ansible.com/u/Patrick_Hunt)\
**Post date:** [July 31, 2018, 4:13pm UTC](https://forum.ansible.com/t/ansible-facts-parse-values-in-dict/28192/4 "2018-07-31T16:13:57Z")

</div>

The documentation for the setup module ( [https://docs.ansible.com/ansible/latest/modules/setup\_module.html#setup-module](https://docs.ansible.com/ansible/latest/modules/setup_module.html#setup-module) ) has a few options for this. you can use “gather\_subset” or the “filter” arguments to gather specific pieces of information. I’m not sure, from just your description, what elements you are trying to access. Do you want just 1 value? When you say you want to remove some values, do you mean that you want to remove these values and display all of the other values? Or are you trying to only use the values you want to remove? If you have a playbook snippet to post along with the question it may go a long way towards being able to help.

Thanks
