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