mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 23:17:32 -02:30
Change to update if already exists
This commit is contained in:
@@ -624,7 +624,7 @@ class Command(NoArgsCommand):
|
||||
if group_name in existing_group_names:
|
||||
continue
|
||||
mem_group = self.all_group.all_groups[group_name]
|
||||
group = self.inventory.groups.get_or_create(name=group_name, defaults={'variables':json.dumps(mem_group.variables), 'description':'imported'})[0]
|
||||
group = self.inventory.groups.update_or_create(name=group_name, defaults={'variables':json.dumps(mem_group.variables), 'description':'imported'})[0]
|
||||
logger.info('Group "%s" added', group.name)
|
||||
self._batch_add_m2m(self.inventory_source.groups, group)
|
||||
self._batch_add_m2m(self.inventory_source.groups, flush=True)
|
||||
@@ -755,7 +755,8 @@ class Command(NoArgsCommand):
|
||||
if self.instance_id_var:
|
||||
instance_id = self._get_instance_id(mem_host.variables)
|
||||
host_attrs['instance_id'] = instance_id
|
||||
db_host = self.inventory.hosts.get_or_create(name=mem_host_name, defaults={'variables':json.dumps(host_attrs)})[0]
|
||||
db_host = self.inventory.hosts.update_or_create(name=mem_host_name,
|
||||
defaults={'variables':host_attrs['variables'], 'description':host_attrs['description']})[0]
|
||||
if enabled is False:
|
||||
logger.info('Host "%s" added (disabled)', mem_host_name)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user