From 9280396e1991f2365c1df79cff83f323b0908c7a Mon Sep 17 00:00:00 2001 From: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> Date: Tue, 19 Apr 2022 11:06:59 -0400 Subject: [PATCH] Fix error message for non-str hosts in yaml inventory (#77544) --- lib/ansible/plugins/inventory/yaml.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/inventory/yaml.py b/lib/ansible/plugins/inventory/yaml.py index 409970cf3d0..9d5812f68a6 100644 --- a/lib/ansible/plugins/inventory/yaml.py +++ b/lib/ansible/plugins/inventory/yaml.py @@ -174,6 +174,10 @@ class InventoryModule(BaseFileInventoryPlugin): ''' Each host key can be a pattern, try to process it and add variables as needed ''' - (hostnames, port) = self._expand_hostpattern(host_pattern) - + try: + (hostnames, port) = self._expand_hostpattern(host_pattern) + except TypeError: + raise AnsibleParserError( + f"Host pattern {host_pattern} must be a string. Enclose integers/floats in quotation marks." + ) return hostnames, port