mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-05 16:51:30 -07:00
fix 'ungrouped' issue with some inventory formats
This commit is contained in:
parent
20bf02f6b9
commit
c4cff44e77
3 changed files with 15 additions and 0 deletions
|
@ -170,6 +170,11 @@ class Inventory(object):
|
||||||
host.vars = combine_vars(host.vars, self.get_host_variables(host.name))
|
host.vars = combine_vars(host.vars, self.get_host_variables(host.name))
|
||||||
self.get_host_vars(host)
|
self.get_host_vars(host)
|
||||||
|
|
||||||
|
# clear ungrouped of any incorrectly stored by parser
|
||||||
|
mygroups = host.get_groups()
|
||||||
|
if len(mygroups) > 2 and ungrouped in mygroups:
|
||||||
|
host.remove_group(ungrouped)
|
||||||
|
|
||||||
def _match(self, str, pattern_str):
|
def _match(self, str, pattern_str):
|
||||||
try:
|
try:
|
||||||
if pattern_str.startswith('~'):
|
if pattern_str.startswith('~'):
|
||||||
|
|
|
@ -114,6 +114,12 @@ class Group:
|
||||||
host.add_group(self)
|
host.add_group(self)
|
||||||
self.clear_hosts_cache()
|
self.clear_hosts_cache()
|
||||||
|
|
||||||
|
def remove_host(self, host):
|
||||||
|
|
||||||
|
self.hosts.remove(host)
|
||||||
|
host.remove_group(self)
|
||||||
|
self.clear_hosts_cache()
|
||||||
|
|
||||||
def set_variable(self, key, value):
|
def set_variable(self, key, value):
|
||||||
|
|
||||||
self.vars[key] = value
|
self.vars[key] = value
|
||||||
|
|
|
@ -110,6 +110,10 @@ class Host:
|
||||||
|
|
||||||
self.groups.append(group)
|
self.groups.append(group)
|
||||||
|
|
||||||
|
def remove_group(self, group):
|
||||||
|
|
||||||
|
self.groups.remove(group)
|
||||||
|
|
||||||
def set_variable(self, key, value):
|
def set_variable(self, key, value):
|
||||||
|
|
||||||
self.vars[key]=value
|
self.vars[key]=value
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue