Change lookup to include organization

This commit is contained in:
John Westcott IV
2020-03-31 12:50:34 -04:00
committed by beeankha
parent 5c9ff51248
commit 8b881d195d
2 changed files with 13 additions and 13 deletions

View File

@@ -45,7 +45,7 @@ options:
credential_type: credential_type:
description: description:
- Name of credential type. - Name of credential type.
- Will be prefered over kind - Will be preferred over kind
required: False required: False
version_added: "2.10" version_added: "2.10"
type: str type: str
@@ -340,13 +340,14 @@ def main():
cred_type_id = module.resolve_name_to_id('credential_types', credential_type if credential_type else KIND_CHOICES[kind]) cred_type_id = module.resolve_name_to_id('credential_types', credential_type if credential_type else KIND_CHOICES[kind])
# Attempt to look up the object based on the provided name and inventory ID # Attempt to look up the object based on the provided name, credential type and optional organization
credential = module.get_one('credentials', **{ lookup_data = {
'data': { 'name': name,
'name': name, 'credential_type': cred_type_id,
'credential_type': cred_type_id, }
} if organization:
}) lookup_data['organization'] = org_id
credential = module.get_one('credentials', **{'data': lookup_data})
# Create credential input from legacy inputs # Create credential input from legacy inputs
credential_inputs = {} credential_inputs = {}

View File

@@ -42,7 +42,7 @@
organization: Default organization: Default
user: admin user: admin
kind: ssh kind: ssh
authorize: False authorize: false
authorize_password: 'test' authorize_password: 'test'
client: 'test' client: 'test'
security_token: 'test' security_token: 'test'
@@ -62,7 +62,7 @@
vault_id: 'test' vault_id: 'test'
ssh_key_unlock: 'test' ssh_key_unlock: 'test'
state: absent state: absent
ignore_errors: True ignore_errors: true
register: result register: result
- assert: - assert:
@@ -125,7 +125,6 @@
- name: Delete a User-specific credential - name: Delete a User-specific credential
tower_credential: tower_credential:
name: "{{ ssh_cred_name1 }}" name: "{{ ssh_cred_name1 }}"
organization: Default
user: admin user: admin
state: absent state: absent
kind: ssh kind: ssh
@@ -253,7 +252,7 @@
ssh_key_data: "{{ tempdir.stdout }}/id_rsa" ssh_key_data: "{{ tempdir.stdout }}/id_rsa"
ssh_key_unlock: "passphrase" ssh_key_unlock: "passphrase"
register: result register: result
ignore_errors: True ignore_errors: true
- assert: - assert:
that: that:
@@ -353,7 +352,7 @@
description: An example Vault credential description: An example Vault credential
vault_password: secret-vault vault_password: secret-vault
register: result register: result
ignore_errors: True ignore_errors: true
- assert: - assert:
that: that: