mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 05:59:28 -02:30
Merge pull request #7840 from beeankha/credential_input_idempotency
Make 'inputs' Unchanged When Blank in Credentials Module Reviewed-by: Bianca Henderson <beeankha@gmail.com> https://github.com/beeankha
This commit is contained in:
@@ -384,19 +384,25 @@ def main():
|
|||||||
team_id = module.resolve_name_to_id('teams', team)
|
team_id = module.resolve_name_to_id('teams', team)
|
||||||
|
|
||||||
# Create credential input from legacy inputs
|
# Create credential input from legacy inputs
|
||||||
|
has_inputs = False
|
||||||
credential_inputs = {}
|
credential_inputs = {}
|
||||||
for legacy_input in OLD_INPUT_NAMES:
|
for legacy_input in OLD_INPUT_NAMES:
|
||||||
if module.params.get(legacy_input) is not None:
|
if module.params.get(legacy_input) is not None:
|
||||||
|
has_inputs = True
|
||||||
credential_inputs[legacy_input] = module.params.get(legacy_input)
|
credential_inputs[legacy_input] = module.params.get(legacy_input)
|
||||||
|
|
||||||
if inputs:
|
if inputs:
|
||||||
|
has_inputs = True
|
||||||
credential_inputs.update(inputs)
|
credential_inputs.update(inputs)
|
||||||
|
|
||||||
# Create the data that gets sent for create and update
|
# Create the data that gets sent for create and update
|
||||||
credential_fields = {
|
credential_fields = {
|
||||||
'name': new_name if new_name else name,
|
'name': new_name if new_name else name,
|
||||||
'credential_type': cred_type_id,
|
'credential_type': cred_type_id,
|
||||||
'inputs': credential_inputs,
|
|
||||||
}
|
}
|
||||||
|
if has_inputs:
|
||||||
|
credential_fields['inputs'] = credential_inputs
|
||||||
|
|
||||||
if description:
|
if description:
|
||||||
credential_fields['description'] = description
|
credential_fields['description'] = description
|
||||||
if organization:
|
if organization:
|
||||||
|
|||||||
@@ -191,6 +191,19 @@
|
|||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
|
||||||
|
- name: Check for inputs idempotency (when "inputs" is blank)
|
||||||
|
tower_credential:
|
||||||
|
name: "{{ ssh_cred_name2 }}"
|
||||||
|
organization: Default
|
||||||
|
state: present
|
||||||
|
credential_type: Machine
|
||||||
|
description: An example SSH credential
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result is not changed
|
||||||
|
|
||||||
- name: Create a valid SSH credential from lookup source (old school)
|
- name: Create a valid SSH credential from lookup source (old school)
|
||||||
tower_credential:
|
tower_credential:
|
||||||
name: "{{ ssh_cred_name3 }}"
|
name: "{{ ssh_cred_name3 }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user