Make add_host clear the inventory pattern cache, add some more aliases. Fixes #4442.
This commit is contained in:
parent
9c9ec52b04
commit
41aaad69aa
3 changed files with 12 additions and 4 deletions
|
@ -266,6 +266,10 @@ class Inventory(object):
|
||||||
self._pattern_hosts[pattern] = results
|
self._pattern_hosts[pattern] = results
|
||||||
return self._pattern_hosts[pattern]
|
return self._pattern_hosts[pattern]
|
||||||
|
|
||||||
|
def clear_pattern_cache(self):
|
||||||
|
''' called exclusively by the add_host plugin to allow patterns to be recalculated '''
|
||||||
|
self._pattern_hosts = {}
|
||||||
|
|
||||||
def groups_for_host(self, host):
|
def groups_for_host(self, host):
|
||||||
results = []
|
results = []
|
||||||
groups = self.get_groups()
|
groups = self.get_groups()
|
||||||
|
|
|
@ -75,7 +75,7 @@ class ActionModule(object):
|
||||||
new_host.set_variable(k, args[k])
|
new_host.set_variable(k, args[k])
|
||||||
|
|
||||||
|
|
||||||
groupnames = args.get('groupname', args.get('groups', ''))
|
groupnames = args.get('groupname', args.get('groups', args.get('group', '')))
|
||||||
# add it to the group if that was specified
|
# add it to the group if that was specified
|
||||||
if groupnames != '':
|
if groupnames != '':
|
||||||
for group_name in groupnames.split(","):
|
for group_name in groupnames.split(","):
|
||||||
|
@ -89,6 +89,10 @@ class ActionModule(object):
|
||||||
|
|
||||||
result['new_host'] = new_name
|
result['new_host'] = new_name
|
||||||
|
|
||||||
|
# clear pattern caching completely since it's unpredictable what
|
||||||
|
# patterns may have referenced the group
|
||||||
|
inventory.clear_pattern_cache()
|
||||||
|
|
||||||
return ReturnData(conn=conn, comm_ok=True, result=result)
|
return ReturnData(conn=conn, comm_ok=True, result=result)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@ description:
|
||||||
version_added: "0.9"
|
version_added: "0.9"
|
||||||
options:
|
options:
|
||||||
name:
|
name:
|
||||||
aliases: [ 'hostname' ]
|
aliases: [ 'hostname', 'host' ]
|
||||||
description:
|
description:
|
||||||
- The hostname/ip of the host to add to the inventory, can include a colon and a port number.
|
- The hostname/ip of the host to add to the inventory, can include a colon and a port number.
|
||||||
required: true
|
required: true
|
||||||
groups:
|
groups:
|
||||||
aliases: [ 'groupname' ]
|
aliases: [ 'groupname', 'group' ]
|
||||||
description:
|
description:
|
||||||
- The groups to add the hostname to, comma separated.
|
- The groups to add the hostname to, comma separated.
|
||||||
required: false
|
required: false
|
||||||
|
|
Loading…
Reference in a new issue