From c005f75469c2653da36e7eb7f0d2fd3a2fb7d9aa Mon Sep 17 00:00:00 2001 From: Thomas Quinot Date: Wed, 16 Sep 2015 12:24:06 +0200 Subject: [PATCH] Always create 'all' group Create 'all' even if host_list is empty, as this group needs to exist when creating the implicit 'localhost' host. Fixes #12391 --- lib/ansible/inventory/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 657084c724..69cf6c5c44 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -86,11 +86,16 @@ class Inventory(object): self.parser = None + # Always create the 'all' group, even if host_list is + # empty: in this case we will subsequently an the implicit + # 'localhost' to it. + + all = Group('all') + self.groups = [ all ] + if host_list is None: pass elif isinstance(host_list, list): - all = Group('all') - self.groups = [ all ] for h in host_list: (host, port) = parse_address(h, allow_ranges=False) all.add_host(Host(host, port))