Get ansible facts as csv
adhoc aproach with ansible
Simple aproach without any callback plugins, just ansible, perl and jq
|
|
I do not like the perl in here, that looks fragile to me. I think there should be an "output" plugin, ansible calls them Callback plugins
with the callback plugin enable for ansible commands
There is an callback json plugin, which makes the output computer readable with jq, you can eather configure it in the ansible.cfg file, but for ad hoc commands its easier to just specifiy some environment variables
Here i use the json callback plugin, and enable it for ansible, i.e. the adhoc commands:
|
|
then I run ansible and pipe the output through jq to get what I want:
|
|
The filter is described in the documentaion of the setup module
what is the name of the ansible fact i am looking for?
gron, again the json callback plugin and grep are helpful: Pipe the output of ansible to gron , grep for whatever comes to mind:
|
|
TODO playbook aproach with ansible-playbook
delegating facts
|
|
accessible as hostvars[‘dbhost1’][‘ansible_default_ipv4’][‘address’]