|
|
@ -60,7 +60,7 @@ class ActionModule(object):
|
|
|
|
|
|
|
|
|
|
|
|
# Add any variables to the new_host
|
|
|
|
# Add any variables to the new_host
|
|
|
|
for k in args.keys():
|
|
|
|
for k in args.keys():
|
|
|
|
if k != 'hostname' and k != 'groupname':
|
|
|
|
if not k in [ 'hostname', 'groupname', 'groups' ]:
|
|
|
|
new_host.set_variable(k, args[k])
|
|
|
|
new_host.set_variable(k, args[k])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,16 +69,17 @@ class ActionModule(object):
|
|
|
|
allgroup.add_host(new_host)
|
|
|
|
allgroup.add_host(new_host)
|
|
|
|
result['changed'] = True
|
|
|
|
result['changed'] = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
groupnames = args.get('groupname', args.get('groups', ''))
|
|
|
|
# add it to the group if that was specified
|
|
|
|
# add it to the group if that was specified
|
|
|
|
if 'groupname' in args:
|
|
|
|
if groupnames != '':
|
|
|
|
if not inventory.get_group(args['groupname']):
|
|
|
|
for group_name in groupnames.split(","):
|
|
|
|
new_group = Group(args['groupname'])
|
|
|
|
if not inventory.get_group(group_name):
|
|
|
|
inventory.add_group(new_group)
|
|
|
|
new_group = Group(group_name)
|
|
|
|
|
|
|
|
inventory.add_group(new_group)
|
|
|
|
ngobj = inventory.get_group(args['groupname'])
|
|
|
|
grp = inventory.get_group(group_name)
|
|
|
|
ngobj.add_host(new_host)
|
|
|
|
grp.add_host(new_host)
|
|
|
|
vv("created 'add_host' ActionModule: groupname=%s"%(args['groupname']))
|
|
|
|
vv("added host to group via add_host module: %s" % group_name)
|
|
|
|
result['new_group'] = args['groupname']
|
|
|
|
result['new_groups'] = groupnames.split(",")
|
|
|
|
|
|
|
|
|
|
|
|
result['new_host'] = args['hostname']
|
|
|
|
result['new_host'] = args['hostname']
|
|
|
|
|
|
|
|
|
|
|
|