diff options
author | James Tanner <tanner.jc@gmail.com> | 2013-11-27 13:04:10 -0500 |
---|---|---|
committer | James Tanner <tanner.jc@gmail.com> | 2013-11-27 13:04:31 -0500 |
commit | 12ed39ef7b94b427e6125730786eb8a7a9cb0d84 (patch) | |
tree | b293487c1c8c53f7f8d0c0189ff7555307dc1575 | |
parent | 1f80aa768af4d7d80b889b2f92074aeb7f3e00b0 (diff) | |
download | ansible-12ed39ef7b94b427e6125730786eb8a7a9cb0d84.tar.gz |
Fixes #5056 Append new hosts to the groups cache
-rw-r--r-- | lib/ansible/runner/action_plugins/add_host.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/ansible/runner/action_plugins/add_host.py b/lib/ansible/runner/action_plugins/add_host.py index 2df7d3b818..ef27d99275 100644 --- a/lib/ansible/runner/action_plugins/add_host.py +++ b/lib/ansible/runner/action_plugins/add_host.py @@ -85,6 +85,13 @@ class ActionModule(object): inventory.add_group(new_group) grp = inventory.get_group(group_name) grp.add_host(new_host) + + # add this host to the group cache + if inventory._groups_list is not None: + if group_name in inventory._groups_list: + if new_host.name not in inventory._groups_list[group_name]: + inventory._groups_list[group_name].append(new_host.name) + vv("added host to group via add_host module: %s" % group_name) result['new_groups'] = groupnames.split(",") |