From 7461ba99989d8ab2c45199158deb21837112537c Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Tue, 29 Sep 2015 17:19:31 +0200 Subject: [PATCH] Inject existing groups at InventoryDir initialization This fixes a corner case where ini files live in a subdir of the main inventory directory. Reproducing the original error: mkdir -p inventory/ini cat > inventory/ini/hosts << EOF [www] www1 EOF $ ansible -i inventory/ all -m ping ERROR! 'all' (or without the [www] group, it would complain about 'ungrouped') --- lib/ansible/inventory/dir.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/inventory/dir.py b/lib/ansible/inventory/dir.py index 9394696d7fb..7ae9611ddf1 100644 --- a/lib/ansible/inventory/dir.py +++ b/lib/ansible/inventory/dir.py @@ -107,7 +107,7 @@ class InventoryDirectory(object): continue fullpath = os.path.join(self.directory, i) if os.path.isdir(fullpath): - parser = InventoryDirectory(loader=loader, filename=fullpath) + parser = InventoryDirectory(loader=loader, groups=groups, filename=fullpath) else: parser = get_file_parser(fullpath, self.groups, loader) if parser is None: