summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon "The Nice Guy" Spriggs <jon@sprig.gs>2022-04-06 18:41:53 +0200
committerGitHub <noreply@github.com>2022-04-06 18:41:53 +0200
commit5b44035983aba190791df479fa7004ce20872042 (patch)
tree186cc09b2c5a1a0c1ae3405c5f4347a848209c1f
parentFix sanity test crash. (diff)
downloadansible-5b44035983aba190791df479fa7004ce20872042.tar.xz
ansible-5b44035983aba190791df479fa7004ce20872042.zip
Hide "[WARNING]: No inventory was parsed" message (#65499)
* Add config option INVENTORY_UNPARSED_WARNING to hide the warning "No inventory was parsed, only implicit localhost is available"
-rw-r--r--changelogs/fragments/65499-no_inventory_parsed.yml2
-rw-r--r--lib/ansible/config/base.yml12
-rw-r--r--lib/ansible/inventory/manager.py2
3 files changed, 15 insertions, 1 deletions
diff --git a/changelogs/fragments/65499-no_inventory_parsed.yml b/changelogs/fragments/65499-no_inventory_parsed.yml
new file mode 100644
index 0000000000..a2826dafb0
--- /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 5cdb4798d3..73b6dbecba 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 3dbe2bfeb2..c55bbe615d 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():