Skip to content

Instantly share code, notes, and snippets.

@jrbing
Created October 16, 2017 20:58
Show Gist options
  • Save jrbing/4ca5469a2776e89e0d7010c44a5155fc to your computer and use it in GitHub Desktop.
Save jrbing/4ca5469a2776e89e0d7010c44a5155fc to your computer and use it in GitHub Desktop.
Examples of using the Ansible setup module with jq
# List all keys
ansible -m setup hostname | sed '1 s/^.*$/{/' | jq '.ansible_facts | keys'
# Get the contents of a specific key
ansible -m setup hostname | sed '1 s/^.*$/{/' | jq '.ansible_facts.ansible_default_ipv4'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment