How To Filter Ansible Facts In Template And Playbook

31 views
Skip to first unread message

Isaiah Banks

unread,
Jul 28, 2021, 2:22:44 PM7/28/21
to Ansible Project
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.

Dick Visser

unread,
Jul 28, 2021, 11:51:49 PM7/28/21
to ansible...@googlegroups.com
What are you looking for exactly?

--
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/81cf407d-2f3a-439b-9875-d5e8b53776e5n%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

rajthecomputerguy

unread,
Jul 29, 2021, 9:19:49 AM7/29/21
to Ansible Project
You can call them directly in your playbook
Reply all
Reply to author
Forward
0 new messages