Ansible facts, parse values in dict

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

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.

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.

The documentation for the 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