Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6159

Ansible Warning "No inventory was passed, only implicit localhost is available"

$
0
0

When attempting to extract an Ansible var value, Ansbile returns a warning "No inventory was passed, only implicit localhost is available"

The command which produces this is -

ansible localhost -m debug -a var=hostvars[inventory_hostname] --playbook-dir /ansible/ --extra-vars @vars/vars.yml | grep -zPo '(?<=\=>)((.|\n)*)' | jq -r '.[].hostname'

This returns

[WARNING]: No inventory was parsed, only implicit localhost is availablehttps://example.com 

The playbooks are configured to run as

hosts: localhostconnection: local

If an explict entry is created like so, the warning disappears

cat /etc/ansilble/hostslocalhost

Is there any alternative CLI approach which can be used to surpress this warning?

I tried the recommendation seen here - Ansible issuing warning about localhost, but without any joy.

The setup versions are Ansible v2.10.8, Python v3.11.6 are running on Ubuntu v22.

Use ansible-playbook

Apart from updating the existing playbooks with something such as

- name: "List all known variables and facts"  debug:    var: hostvars[inventory_hostname]

Which is not what I'm seeking, I wish output all vars for the current playbooks via the CLI, as per the original command, seen above.


Viewing all articles
Browse latest Browse all 6159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>