Skip to content

Commit

Permalink
aci_aaa_user_certificate: Rename user parameter to aaa_user (ansible#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dagwieers authored Jan 23, 2018
1 parent f94fe61 commit 64df1a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
44 changes: 22 additions & 22 deletions lib/ansible/modules/network/aci/aci_aaa_user_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@
- Dag Wieers (@dagwieers)
version_added: '2.5'
notes:
- The C(user) must exist before using this module in your playbook.
The M(aci_user) module can be used for this.
- The C(aaa_user) must exist before using this module in your playbook.
The M(aci_aaa_user) module can be used for this.
options:
user:
aaa_user:
description:
- The name of the user to add a certificate to.
aaa_user_type:
description:
- Whether this is a normal user or an appuser.
choices: [ user, userapp ]
default: user
certificate:
description:
- The PEM format public key extracted from the X.509 certificate.
Expand All @@ -37,11 +42,6 @@
description:
- The name of the user certificate entry in ACI.
aliases: [ cert_name ]
user_type:
description:
- Whether this is a normal user or an appuser.
choices: [ user, userapp ]
default: user
state:
description:
- Use C(present) or C(absent) for adding or removing.
Expand All @@ -57,7 +57,7 @@
host: apic
username: admin
password: SomeSecretPassword
user: admin
aaa_user: admin
certificate_name: admin
certificate_data: '{{ lookup("file", "pki/admin.crt") }}'
state: present
Expand All @@ -67,7 +67,7 @@
host: apic
username: admin
password: SomeSecretPassword
user: admin
aaa_user: admin
certificate_name: admin
state: absent
Expand All @@ -76,7 +76,7 @@
host: apic
username: admin
password: SomeSecretPassword
user: admin
aaa_user: admin
certificate_name: admin
state: query
Expand All @@ -85,7 +85,7 @@
host: apic
username: admin
password: SomeSecretPassword
user: admin
aaa_user: admin
state: query
'''

Expand All @@ -109,35 +109,35 @@
def main():
argument_spec = aci_argument_spec()
argument_spec.update(
aaa_user=dict(type='str', required=True),
aaa_user_type=dict(type='str', default='user', choices=['appuser', 'user']),
certificate=dict(type='str', aliases=['cert_data', 'certificate_data']),
certificate_name=dict(type='str', aliases=['cert_name']),
state=dict(type='str', default='present', choices=['absent', 'present', 'query']),
user=dict(type='str', required=True),
user_type=dict(type='str', default='user', choices=['appuser', 'user']),
)

module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
required_if=[
['state', 'absent', ['user', 'certificate_name']],
['state', 'present', ['user', 'certificate', 'certificate_name']],
['state', 'absent', ['aaa_user', 'certificate_name']],
['state', 'present', ['aaa_user', 'certificate', 'certificate_name']],
],
)

aaa_user = module.params['aaa_user']
aaa_user_type = module.params['aaa_user_type']
certificate = module.params['certificate']
certificate_name = module.params['certificate_name']
state = module.params['state']
user = module.params['user']
user_type = module.params['user_type']

aci = ACIModule(module)
aci.construct_url(
root_class=dict(
aci_class=ACI_MAPPING[user_type]['aci_class'],
aci_rn=ACI_MAPPING[user_type]['aci_mo'] + user,
filter_target='eq({0}.name, "{1}")'.format(ACI_MAPPING[user_type]['aci_class'], user),
module_object=user,
aci_class=ACI_MAPPING[aaa_user_type]['aci_class'],
aci_rn=ACI_MAPPING[aaa_user_type]['aci_mo'] + aaa_user,
filter_target='eq({0}.name, "{1}")'.format(ACI_MAPPING[aaa_user_type]['aci_class'], aaa_user),
module_object=aaa_user,
),
subclass_1=dict(
aci_class='aaaUserCert',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
validate_certs: '{{ aci_validate_certs | default(false) }}'
use_ssl: '{{ aci_use_ssl | default(true) }}'
use_proxy: '{{ aci_use_proxy | default(true) }}'
user: admin
aaa_user: admin
certificate_name: admin
state: absent

Expand All @@ -32,7 +32,7 @@
validate_certs: '{{ aci_validate_certs | default(false) }}'
use_ssl: '{{ aci_use_ssl | default(true) }}'
use_proxy: '{{ aci_use_proxy | default(true) }}'
user: admin
aaa_user: admin
certificate_name: admin
certificate: "{{ lookup('file', 'pki/admin.crt') }}"
state: present
Expand Down Expand Up @@ -69,7 +69,7 @@
validate_certs: '{{ aci_validate_certs | default(false) }}'
use_ssl: '{{ aci_use_ssl | default(true) }}'
use_proxy: '{{ aci_use_proxy | default(true) }}'
user: admin
aaa_user: admin
state: query
check_mode: yes
register: cm_query_all_certs
Expand Down

0 comments on commit 64df1a7

Please sign in to comment.