update logic

This commit is contained in:
sean-m-ssullivan
2021-03-03 12:20:13 -06:00
parent a0090c7c52
commit 6d88a81cbd
6 changed files with 10 additions and 6 deletions

View File

@@ -413,7 +413,10 @@ class TowerAPIModule(TowerModule):
def copy_item(self, existing_item, copy_from_name_or_id, new_item_name, endpoint=None, item_type='unknown', copy_lookup_data={}): def copy_item(self, existing_item, copy_from_name_or_id, new_item_name, endpoint=None, item_type='unknown', copy_lookup_data={}):
if existing_item is not None: if existing_item is not None:
self.fail_json(msg="A {0} with the name {1} already exists.".format(item_type, new_item_name)) self.warn(msg="A {0} with the name {1} already exists.".format(item_type, new_item_name))
self.json_output['changed'] = False
self.json_output['copied'] = False
return existing_item
# Lookup existing item to copy from # Lookup existing item to copy from
copy_from_lookup = self.get_one(endpoint, name_or_id=copy_from_name_or_id, **{'data': copy_lookup_data}) copy_from_lookup = self.get_one(endpoint, name_or_id=copy_from_name_or_id, **{'data': copy_lookup_data})
@@ -441,6 +444,7 @@ class TowerAPIModule(TowerModule):
if response['status_code'] in [201]: if response['status_code'] in [201]:
self.json_output['id'] = response['json']['id'] self.json_output['id'] = response['json']['id']
self.json_output['changed'] = True self.json_output['changed'] = True
self.json_output['copied'] = True
new_existing_item = response['json'] new_existing_item = response['json']
else: else:
if 'json' in response and '__all__' in response['json']: if 'json' in response and '__all__' in response['json']:

View File

@@ -212,7 +212,7 @@
- assert: - assert:
that: that:
- result is changed - result.copied
- name: Delete an SSH credential - name: Delete an SSH credential
tower_credential: tower_credential:

View File

@@ -59,7 +59,7 @@
- assert: - assert:
that: that:
- "result is changed" - result.copied
- name: Delete an Inventory - name: Delete an Inventory
tower_inventory: tower_inventory:

View File

@@ -142,7 +142,7 @@
- assert: - assert:
that: that:
- result is changed - result.copied
- name: Delete copied email notification - name: Delete copied email notification
tower_notification_template: tower_notification_template:

View File

@@ -89,7 +89,7 @@
# the project, or it could be because the module actually failed somehow # the project, or it could be because the module actually failed somehow
- assert: - assert:
that: that:
- "result is changed" - result.copied
- name: Check module fails with correct msg when given non-existing org as param - name: Check module fails with correct msg when given non-existing org as param
tower_project: tower_project:

View File

@@ -253,7 +253,7 @@
- assert: - assert:
that: that:
- "result is changed" - result.copied
- name: Fail Remove "on start" webhook notification from copied workflow job template - name: Fail Remove "on start" webhook notification from copied workflow job template
tower_workflow_job_template: tower_workflow_job_template: