|
|
@ -161,6 +161,7 @@ class InventoryData(object):
|
|
|
|
def add_group(self, group):
|
|
|
|
def add_group(self, group):
|
|
|
|
''' adds a group to inventory if not there already '''
|
|
|
|
''' adds a group to inventory if not there already '''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if group:
|
|
|
|
if group not in self.groups:
|
|
|
|
if group not in self.groups:
|
|
|
|
g = Group(group)
|
|
|
|
g = Group(group)
|
|
|
|
self.groups[group] = g
|
|
|
|
self.groups[group] = g
|
|
|
@ -168,6 +169,8 @@ class InventoryData(object):
|
|
|
|
display.debug("Added group %s to inventory" % group)
|
|
|
|
display.debug("Added group %s to inventory" % group)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
display.debug("group %s already in inventory" % group)
|
|
|
|
display.debug("group %s already in inventory" % group)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise AnsibleError("Invalid empty/false group name provided: %s" % group)
|
|
|
|
|
|
|
|
|
|
|
|
def remove_group(self, group):
|
|
|
|
def remove_group(self, group):
|
|
|
|
|
|
|
|
|
|
|
@ -183,6 +186,7 @@ class InventoryData(object):
|
|
|
|
def add_host(self, host, group=None, port=None):
|
|
|
|
def add_host(self, host, group=None, port=None):
|
|
|
|
''' adds a host to inventory and possibly a group if not there already '''
|
|
|
|
''' adds a host to inventory and possibly a group if not there already '''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if host:
|
|
|
|
g = None
|
|
|
|
g = None
|
|
|
|
if group:
|
|
|
|
if group:
|
|
|
|
if group in self.groups:
|
|
|
|
if group in self.groups:
|
|
|
@ -215,6 +219,8 @@ class InventoryData(object):
|
|
|
|
g.add_host(h)
|
|
|
|
g.add_host(h)
|
|
|
|
self._groups_dict_cache = {}
|
|
|
|
self._groups_dict_cache = {}
|
|
|
|
display.debug("Added host %s to group %s" % (host, group))
|
|
|
|
display.debug("Added host %s to group %s" % (host, group))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
raise AnsibleError("Invalid empty host name provided: %s" % host)
|
|
|
|
|
|
|
|
|
|
|
|
def remove_host(self, host):
|
|
|
|
def remove_host(self, host):
|
|
|
|
|
|
|
|
|
|
|
|