diff --git a/changelogs/fragments/65499-no_inventory_parsed.yml b/changelogs/fragments/65499-no_inventory_parsed.yml new file mode 100644 index 00000000000..a2826dafb0c --- /dev/null +++ b/changelogs/fragments/65499-no_inventory_parsed.yml @@ -0,0 +1,2 @@ +minor_changes: +- Add a new "INVENTORY_UNPARSED_WARNING" flag add to hide the "No inventory was parsed, only implicit localhost is available" warning diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml index 5cdb4798d37..73b6dbecbad 100644 --- a/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml @@ -394,6 +394,18 @@ LOCALHOST_WARNING: - {key: localhost_warning, section: defaults} type: boolean version_added: "2.6" +INVENTORY_UNPARSED_WARNING: + name: Warning when no inventory files can be parsed, resulting in an implicit inventory with only localhost + default: True + description: + - By default Ansible will issue a warning when no inventory was loaded and notes that + it will use an implicit localhost-only inventory. + - These warnings can be silenced by adjusting this setting to False. + env: [{name: ANSIBLE_INVENTORY_UNPARSED_WARNING}] + ini: + - {key: inventory_unparsed_warning, section: defaults} + type: boolean + version_added: "2.14" DOC_FRAGMENT_PLUGIN_PATH: name: documentation fragment plugins path default: ~/.ansible/plugins/doc_fragments:/usr/share/ansible/plugins/doc_fragments diff --git a/lib/ansible/inventory/manager.py b/lib/ansible/inventory/manager.py index 3dbe2bfeb2a..c55bbe615d7 100644 --- a/lib/ansible/inventory/manager.py +++ b/lib/ansible/inventory/manager.py @@ -232,7 +232,7 @@ class InventoryManager(object): else: if C.INVENTORY_UNPARSED_IS_FAILED: raise AnsibleError("No inventory was parsed, please check your configuration and options.") - else: + elif C.INVENTORY_UNPARSED_WARNING: display.warning("No inventory was parsed, only implicit localhost is available") for group in self.groups.values():