How To Filter Ansible Facts In Template And Playbook

Hello. I am new to Ansible. I am trying to figure out how I can filter a list of ansible_facts in a template and playbook and get the information I directly need. I am trying to do this with json_query() plugin.

However, when I pass the ansible facts to the json_query() plugin in the playbook, it automatically strips out the keys. I am doing it like this:

  • name: Filter ansible facts
    debug:
    msg: “{{ ansible_facts | json_query(‘*’) }}”

This example is just so I can see what the plugin would return. I want to be able to query against the keys, then after that return the value of that key.

Thanks in advance.

What are you looking for exactly?

You can call them directly in your playbook