diff --git a/lib/ansible/plugins/inventory/advanced_host_list.py b/lib/ansible/plugins/inventory/advanced_host_list.py index 22cc77d67f..751d210f71 100644 --- a/lib/ansible/plugins/inventory/advanced_host_list.py +++ b/lib/ansible/plugins/inventory/advanced_host_list.py @@ -61,6 +61,7 @@ class InventoryModule(BaseInventoryPlugin): try: for h in host_list.split(','): + h = h.strip() if h: try: (hostnames, port) = self._expand_hostpattern(h) diff --git a/lib/ansible/plugins/inventory/host_list.py b/lib/ansible/plugins/inventory/host_list.py index a690149ce9..f89c9011e8 100644 --- a/lib/ansible/plugins/inventory/host_list.py +++ b/lib/ansible/plugins/inventory/host_list.py @@ -64,6 +64,7 @@ class InventoryModule(BaseInventoryPlugin): try: for h in host_list.split(','): + h = h.strip() if h: try: (host, port) = parse_address(h, allow_ranges=False)