Question:
I am running the following ansible
playbook
1 2 3 4 5 6 7 8 9 10 11 |
- hosts: localhost connection: local vars_files: - vars/config_values.yaml gather_facts: no tasks: - name: Set correct project in gcloud config shell: "gcloud config set project {{ google_project_name }}" |
Which yields the following warning:
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’
Given that I am explicitly stating that it will be run against host: localhost
, why is it complaining about no inventory being parsed and that the “provided host list is empty”?
How to remove these warnings? (without just suppressing them if possible)
Answer:
This is just a warning telling you that you did not provide any inventory file (with -i
), that the default one (usually /etc/ansible/hosts
) could not be found and therefore your inventory is empty, only containing the implicit localhost.
hosts: localhost
is the target for your play. It can be a host or a group (or a more complicated pattern). The targeted hosts must exist in the inventory to be managed. localhost
always exists as the implicit local machine.
See https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html
If your default inventory will stay empty and you basically only run playbooks targeted to localhost, you can suppress this warning by setting a config option in your environment or in ansible cfg