mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Rename MSC modules to MSO nomenclature (#50959)
* msc_tenant: improve docs * Rename MSC modules to MSO * Rename MSC-related objects to MSO nomenclature * Add missing doc fragments
This commit is contained in:
parent
7a1ceb6988
commit
a79441ca30
21 changed files with 493 additions and 491 deletions
4
.github/BOTMETA.yml
vendored
4
.github/BOTMETA.yml
vendored
|
@ -1169,12 +1169,14 @@ files:
|
||||||
- jinja2
|
- jinja2
|
||||||
lib/ansible/utils/module_docs_fragments/:
|
lib/ansible/utils/module_docs_fragments/:
|
||||||
support: community
|
support: community
|
||||||
|
lib/ansible/utils/module_docs_fragments/aci.py: *aci
|
||||||
lib/ansible/utils/module_docs_fragments/acme.py:
|
lib/ansible/utils/module_docs_fragments/acme.py:
|
||||||
maintainers: resmo felixfontein
|
maintainers: resmo felixfontein
|
||||||
lib/ansible/utils/module_docs_fragments/docker.py:
|
lib/ansible/utils/module_docs_fragments/docker.py:
|
||||||
support: community
|
support: community
|
||||||
maintainers: $team_docker
|
maintainers: $team_docker
|
||||||
supershipit: felixfontein
|
supershipit: felixfontein
|
||||||
|
lib/ansible/utils/module_docs_fragments/mso.py: *aci
|
||||||
lib/ansible/utils/module_docs_fragments/xenserver.py:
|
lib/ansible/utils/module_docs_fragments/xenserver.py:
|
||||||
maintainers: bvitnik
|
maintainers: bvitnik
|
||||||
lib/ansible/utils/module_docs_fragments/cloudstack.py:
|
lib/ansible/utils/module_docs_fragments/cloudstack.py:
|
||||||
|
@ -1230,7 +1232,7 @@ files:
|
||||||
maintainers: $team_google
|
maintainers: $team_google
|
||||||
supershipit: $team_google
|
supershipit: $team_google
|
||||||
test/integration/targets/meraki: *meraki
|
test/integration/targets/meraki: *meraki
|
||||||
test/integration/targets/msc: *aci
|
test/integration/targets/mso: *aci
|
||||||
test/integration/targets/nxos:
|
test/integration/targets/nxos:
|
||||||
maintainers: $team_nxos
|
maintainers: $team_nxos
|
||||||
labels:
|
labels:
|
||||||
|
|
|
@ -73,7 +73,7 @@ def update_qs(params):
|
||||||
return '?' + urlencode(accepted_params)
|
return '?' + urlencode(accepted_params)
|
||||||
|
|
||||||
|
|
||||||
def msc_argument_spec():
|
def mso_argument_spec():
|
||||||
return dict(
|
return dict(
|
||||||
host=dict(type='str', required=True, aliases=['hostname']),
|
host=dict(type='str', required=True, aliases=['hostname']),
|
||||||
port=dict(type='int', required=False),
|
port=dict(type='int', required=False),
|
||||||
|
@ -87,7 +87,7 @@ def msc_argument_spec():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MSCModule(object):
|
class MSOModule(object):
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
self.module = module
|
self.module = module
|
||||||
|
@ -131,7 +131,7 @@ class MSCModule(object):
|
||||||
self.module.fail_json(msg="Parameter 'password' is required for authentication")
|
self.module.fail_json(msg="Parameter 'password' is required for authentication")
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
''' Log in to MSC '''
|
''' Log in to MSO '''
|
||||||
|
|
||||||
# Perform login request
|
# Perform login request
|
||||||
self.url = urljoin(self.baseuri, 'auth/login')
|
self.url = urljoin(self.baseuri, 'auth/login')
|
||||||
|
@ -144,7 +144,7 @@ class MSCModule(object):
|
||||||
timeout=self.params['timeout'],
|
timeout=self.params['timeout'],
|
||||||
use_proxy=self.params['use_proxy'])
|
use_proxy=self.params['use_proxy'])
|
||||||
|
|
||||||
# Handle MSC response
|
# Handle MSO response
|
||||||
if auth['status'] != 201:
|
if auth['status'] != 201:
|
||||||
self.response = auth['msg']
|
self.response = auth['msg']
|
||||||
self.status = auth['status']
|
self.status = auth['status']
|
||||||
|
@ -155,7 +155,7 @@ class MSCModule(object):
|
||||||
self.headers['Authorization'] = 'Bearer {token}'.format(**payload)
|
self.headers['Authorization'] = 'Bearer {token}'.format(**payload)
|
||||||
|
|
||||||
def request(self, path, method=None, data=None, qs=None):
|
def request(self, path, method=None, data=None, qs=None):
|
||||||
''' Generic HTTP method for MSC requests. '''
|
''' Generic HTTP method for MSO requests. '''
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
if method is not None:
|
if method is not None:
|
||||||
|
@ -198,14 +198,14 @@ class MSCModule(object):
|
||||||
except Exception:
|
except Exception:
|
||||||
payload = json.loads(info['body'])
|
payload = json.loads(info['body'])
|
||||||
if 'code' in payload:
|
if 'code' in payload:
|
||||||
self.fail_json(msg='MSC Error {code}: {message}'.format(**payload), data=data, info=info, payload=payload)
|
self.fail_json(msg='MSO Error {code}: {message}'.format(**payload), data=data, info=info, payload=payload)
|
||||||
else:
|
else:
|
||||||
self.fail_json(msg='MSC Error:'.format(**payload), data=data, info=info, payload=payload)
|
self.fail_json(msg='MSO Error:'.format(**payload), data=data, info=info, payload=payload)
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def query_objs(self, path, key=None, **kwargs):
|
def query_objs(self, path, key=None, **kwargs):
|
||||||
''' Query the MSC REST API for objects in a path '''
|
''' Query the MSO REST API for objects in a path '''
|
||||||
found = []
|
found = []
|
||||||
objs = self.request(path, method='GET')
|
objs = self.request(path, method='GET')
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ class MSCModule(object):
|
||||||
return found
|
return found
|
||||||
|
|
||||||
def get_obj(self, path, **kwargs):
|
def get_obj(self, path, **kwargs):
|
||||||
''' Get a specific object from a set of MSC REST objects '''
|
''' Get a specific object from a set of MSO REST objects '''
|
||||||
objs = self.query_objs(path, **kwargs)
|
objs = self.query_objs(path, **kwargs)
|
||||||
if len(objs) == 0:
|
if len(objs) == 0:
|
||||||
return {}
|
return {}
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
|
|
||||||
DOCUMENTATION = r'''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: msc_label
|
module: mso_label
|
||||||
short_description: Manage labels
|
short_description: Manage labels
|
||||||
description:
|
description:
|
||||||
- Manage labels on Cisco ACI Multi-Site.
|
- Manage labels on Cisco ACI Multi-Site.
|
||||||
|
@ -45,13 +45,13 @@ options:
|
||||||
type: str
|
type: str
|
||||||
choices: [ absent, present, query ]
|
choices: [ absent, present, query ]
|
||||||
default: present
|
default: present
|
||||||
extends_documentation_fragment: msc
|
extends_documentation_fragment: mso
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
- name: Add a new label
|
- name: Add a new label
|
||||||
msc_label:
|
mso_label:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
label: Belgium
|
label: Belgium
|
||||||
|
@ -60,8 +60,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Remove a label
|
- name: Remove a label
|
||||||
msc_label:
|
mso_label:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
label: Belgium
|
label: Belgium
|
||||||
|
@ -69,8 +69,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Query a label
|
- name: Query a label
|
||||||
msc_label:
|
mso_label:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
label: Belgium
|
label: Belgium
|
||||||
|
@ -79,8 +79,8 @@ EXAMPLES = r'''
|
||||||
register: query_result
|
register: query_result
|
||||||
|
|
||||||
- name: Query all labels
|
- name: Query all labels
|
||||||
msc_label:
|
mso_label:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
state: query
|
state: query
|
||||||
|
@ -92,11 +92,11 @@ RETURN = r'''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = msc_argument_spec()
|
argument_spec = mso_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
label=dict(type='str', required=False, aliases=['name', 'label_name']),
|
label=dict(type='str', required=False, aliases=['name', 'label_name']),
|
||||||
label_id=dict(type='str', required=False),
|
label_id=dict(type='str', required=False),
|
||||||
|
@ -118,24 +118,24 @@ def main():
|
||||||
label_type = module.params['type']
|
label_type = module.params['type']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
msc = MSCModule(module)
|
mso = MSOModule(module)
|
||||||
|
|
||||||
path = 'labels'
|
path = 'labels'
|
||||||
|
|
||||||
# Query for existing object(s)
|
# Query for existing object(s)
|
||||||
if label_id is None and label is None:
|
if label_id is None and label is None:
|
||||||
msc.existing = msc.query_objs(path)
|
mso.existing = mso.query_objs(path)
|
||||||
elif label_id is None:
|
elif label_id is None:
|
||||||
msc.existing = msc.get_obj(path, displayName=label)
|
mso.existing = mso.get_obj(path, displayName=label)
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
label_id = msc.existing['id']
|
label_id = mso.existing['id']
|
||||||
elif label is None:
|
elif label is None:
|
||||||
msc.existing = msc.get_obj(path, id=label_id)
|
mso.existing = mso.get_obj(path, id=label_id)
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.get_obj(path, id=label_id)
|
mso.existing = mso.get_obj(path, id=label_id)
|
||||||
existing_by_name = msc.get_obj(path, displayName=label)
|
existing_by_name = mso.get_obj(path, displayName=label)
|
||||||
if existing_by_name and label_id != existing_by_name['id']:
|
if existing_by_name and label_id != existing_by_name['id']:
|
||||||
msc.fail_json(msg="Provided label '{0}' with id '{1}' does not match existing id '{2}'.".format(label, label_id, existing_by_name['id']))
|
mso.fail_json(msg="Provided label '{0}' with id '{1}' does not match existing id '{2}'.".format(label, label_id, existing_by_name['id']))
|
||||||
|
|
||||||
# If we found an existing object, continue with it
|
# If we found an existing object, continue with it
|
||||||
if label_id:
|
if label_id:
|
||||||
|
@ -145,15 +145,15 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = {}
|
mso.existing = {}
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='DELETE')
|
mso.existing = mso.request(path, method='DELETE')
|
||||||
|
|
||||||
elif state == 'present':
|
elif state == 'present':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
|
|
||||||
payload = dict(
|
payload = dict(
|
||||||
id=label_id,
|
id=label_id,
|
||||||
|
@ -161,21 +161,21 @@ def main():
|
||||||
type=label_type,
|
type=label_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
msc.sanitize(payload, collate=True)
|
mso.sanitize(payload, collate=True)
|
||||||
|
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if not issubset(msc.sent, msc.existing):
|
if not issubset(mso.sent, mso.existing):
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||||
else:
|
else:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||||
|
|
||||||
msc.exit_json()
|
mso.exit_json()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
|
|
||||||
DOCUMENTATION = r'''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: msc_role
|
module: mso_role
|
||||||
short_description: Manage roles
|
short_description: Manage roles
|
||||||
description:
|
description:
|
||||||
- Manage roles on Cisco ACI Multi-Site.
|
- Manage roles on Cisco ACI Multi-Site.
|
||||||
|
@ -70,13 +70,13 @@ options:
|
||||||
type: str
|
type: str
|
||||||
choices: [ absent, present, query ]
|
choices: [ absent, present, query ]
|
||||||
default: present
|
default: present
|
||||||
extends_documentation_fragment: msc
|
extends_documentation_fragment: mso
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
- name: Add a new role
|
- name: Add a new role
|
||||||
msc_role:
|
mso_role:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
role: readOnly
|
role: readOnly
|
||||||
|
@ -93,8 +93,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Remove a role
|
- name: Remove a role
|
||||||
msc_role:
|
mso_role:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
role: readOnly
|
role: readOnly
|
||||||
|
@ -102,8 +102,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Query a role
|
- name: Query a role
|
||||||
msc_role:
|
mso_role:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
role: readOnly
|
role: readOnly
|
||||||
|
@ -112,8 +112,8 @@ EXAMPLES = r'''
|
||||||
register: query_result
|
register: query_result
|
||||||
|
|
||||||
- name: Query all roles
|
- name: Query all roles
|
||||||
msc_role:
|
mso_role:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
state: query
|
state: query
|
||||||
|
@ -125,11 +125,11 @@ RETURN = r'''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = msc_argument_spec()
|
argument_spec = mso_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
role=dict(type='str', required=False, aliases=['name', 'role_name']),
|
role=dict(type='str', required=False, aliases=['name', 'role_name']),
|
||||||
role_id=dict(type='str', required=False),
|
role_id=dict(type='str', required=False),
|
||||||
|
@ -173,24 +173,24 @@ def main():
|
||||||
permissions = module.params['permissions']
|
permissions = module.params['permissions']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
msc = MSCModule(module)
|
mso = MSOModule(module)
|
||||||
|
|
||||||
path = 'roles'
|
path = 'roles'
|
||||||
|
|
||||||
# Query for existing object(s)
|
# Query for existing object(s)
|
||||||
if role_id is None and role is None:
|
if role_id is None and role is None:
|
||||||
msc.existing = msc.query_objs(path)
|
mso.existing = mso.query_objs(path)
|
||||||
elif role_id is None:
|
elif role_id is None:
|
||||||
msc.existing = msc.get_obj(path, name=role)
|
mso.existing = mso.get_obj(path, name=role)
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
role_id = msc.existing['id']
|
role_id = mso.existing['id']
|
||||||
elif role is None:
|
elif role is None:
|
||||||
msc.existing = msc.get_obj(path, id=role_id)
|
mso.existing = mso.get_obj(path, id=role_id)
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.get_obj(path, id=role_id)
|
mso.existing = mso.get_obj(path, id=role_id)
|
||||||
existing_by_name = msc.get_obj(path, name=role)
|
existing_by_name = mso.get_obj(path, name=role)
|
||||||
if existing_by_name and role_id != existing_by_name['id']:
|
if existing_by_name and role_id != existing_by_name['id']:
|
||||||
msc.fail_json(msg="Provided role '{0}' with id '{1}' does not match existing id '{2}'.".format(role, role_id, existing_by_name['id']))
|
mso.fail_json(msg="Provided role '{0}' with id '{1}' does not match existing id '{2}'.".format(role, role_id, existing_by_name['id']))
|
||||||
|
|
||||||
# If we found an existing object, continue with it
|
# If we found an existing object, continue with it
|
||||||
if role_id:
|
if role_id:
|
||||||
|
@ -200,15 +200,15 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = {}
|
mso.existing = {}
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='DELETE')
|
mso.existing = mso.request(path, method='DELETE')
|
||||||
|
|
||||||
elif state == 'present':
|
elif state == 'present':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
|
|
||||||
payload = dict(
|
payload = dict(
|
||||||
id=role_id,
|
id=role_id,
|
||||||
|
@ -218,21 +218,21 @@ def main():
|
||||||
permissions=permissions,
|
permissions=permissions,
|
||||||
)
|
)
|
||||||
|
|
||||||
msc.sanitize(payload, collate=True)
|
mso.sanitize(payload, collate=True)
|
||||||
|
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if not issubset(msc.sent, msc.existing):
|
if not issubset(mso.sent, mso.existing):
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||||
else:
|
else:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||||
|
|
||||||
msc.exit_json()
|
mso.exit_json()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
|
@ -12,7 +12,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
|
|
||||||
DOCUMENTATION = r'''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: msc_schema
|
module: mso_schema
|
||||||
short_description: Manage schemas
|
short_description: Manage schemas
|
||||||
description:
|
description:
|
||||||
- Manage schemas on Cisco ACI Multi-Site.
|
- Manage schemas on Cisco ACI Multi-Site.
|
||||||
|
@ -46,13 +46,13 @@ options:
|
||||||
type: str
|
type: str
|
||||||
choices: [ absent, present, query ]
|
choices: [ absent, present, query ]
|
||||||
default: present
|
default: present
|
||||||
extends_documentation_fragment: msc
|
extends_documentation_fragment: mso
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
- name: Add a new schema
|
- name: Add a new schema
|
||||||
msc_schema:
|
mso_schema:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
schema: Schema 1
|
schema: Schema 1
|
||||||
|
@ -71,8 +71,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Remove schemas
|
- name: Remove schemas
|
||||||
msc_schema:
|
mso_schema:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
schema: Schema 1
|
schema: Schema 1
|
||||||
|
@ -80,8 +80,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Query a schema
|
- name: Query a schema
|
||||||
msc_schema:
|
mso_schema:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
schema: Schema 1
|
schema: Schema 1
|
||||||
|
@ -90,8 +90,8 @@ EXAMPLES = r'''
|
||||||
register: query_result
|
register: query_result
|
||||||
|
|
||||||
- name: Query all schemas
|
- name: Query all schemas
|
||||||
msc_schema:
|
mso_schema:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
state: query
|
state: query
|
||||||
|
@ -103,11 +103,11 @@ RETURN = r'''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = msc_argument_spec()
|
argument_spec = mso_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
schema=dict(type='str', required=False, aliases=['name', 'schema_name']),
|
schema=dict(type='str', required=False, aliases=['name', 'schema_name']),
|
||||||
schema_id=dict(type='str', required=False),
|
schema_id=dict(type='str', required=False),
|
||||||
|
@ -136,24 +136,24 @@ def main():
|
||||||
sites = module.params['sites']
|
sites = module.params['sites']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
msc = MSCModule(module)
|
mso = MSOModule(module)
|
||||||
|
|
||||||
path = 'schemas'
|
path = 'schemas'
|
||||||
|
|
||||||
# Query for existing object(s)
|
# Query for existing object(s)
|
||||||
if schema_id is None and schema is None:
|
if schema_id is None and schema is None:
|
||||||
msc.existing = msc.query_objs(path)
|
mso.existing = mso.query_objs(path)
|
||||||
elif schema_id is None:
|
elif schema_id is None:
|
||||||
msc.existing = msc.get_obj(path, displayName=schema)
|
mso.existing = mso.get_obj(path, displayName=schema)
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
schema_id = msc.existing['id']
|
schema_id = mso.existing['id']
|
||||||
elif schema is None:
|
elif schema is None:
|
||||||
msc.existing = msc.get_obj(path, id=schema_id)
|
mso.existing = mso.get_obj(path, id=schema_id)
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.get_obj(path, id=schema_id)
|
mso.existing = mso.get_obj(path, id=schema_id)
|
||||||
existing_by_name = msc.get_obj(path, displayName=schema)
|
existing_by_name = mso.get_obj(path, displayName=schema)
|
||||||
if existing_by_name and schema_id != existing_by_name['id']:
|
if existing_by_name and schema_id != existing_by_name['id']:
|
||||||
msc.fail_json(msg="Provided schema '{1}' with id '{2}' does not match existing id '{3}'.".format(schema, schema_id, existing_by_name['id']))
|
mso.fail_json(msg="Provided schema '{1}' with id '{2}' does not match existing id '{3}'.".format(schema, schema_id, existing_by_name['id']))
|
||||||
|
|
||||||
if schema_id:
|
if schema_id:
|
||||||
path = 'schemas/{id}'.format(id=schema_id)
|
path = 'schemas/{id}'.format(id=schema_id)
|
||||||
|
@ -162,15 +162,15 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = {}
|
mso.existing = {}
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='DELETE')
|
mso.existing = mso.request(path, method='DELETE')
|
||||||
|
|
||||||
elif state == 'present':
|
elif state == 'present':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
|
|
||||||
payload = dict(
|
payload = dict(
|
||||||
id=schema_id,
|
id=schema_id,
|
||||||
|
@ -179,21 +179,21 @@ def main():
|
||||||
sites=sites,
|
sites=sites,
|
||||||
)
|
)
|
||||||
|
|
||||||
msc.sanitize(payload, collate=True)
|
mso.sanitize(payload, collate=True)
|
||||||
|
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if not issubset(msc.sent, msc.existing):
|
if not issubset(mso.sent, mso.existing):
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||||
else:
|
else:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||||
|
|
||||||
msc.exit_json()
|
mso.exit_json()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
|
|
||||||
DOCUMENTATION = r'''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: msc_site
|
module: mso_site
|
||||||
short_description: Manage sites
|
short_description: Manage sites
|
||||||
description:
|
description:
|
||||||
- Manage sites on Cisco ACI Multi-Site.
|
- Manage sites on Cisco ACI Multi-Site.
|
||||||
|
@ -76,18 +76,18 @@ options:
|
||||||
type: str
|
type: str
|
||||||
choices: [ absent, present, query ]
|
choices: [ absent, present, query ]
|
||||||
default: present
|
default: present
|
||||||
extends_documentation_fragment: msc
|
extends_documentation_fragment: mso
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
- name: Add a new site
|
- name: Add a new site
|
||||||
msc_site:
|
mso_site:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
site: north_europe
|
site: north_europe
|
||||||
description: North European Datacenter
|
description: North European Datacenter
|
||||||
apic_username: msc_admin
|
apic_username: mso_admin
|
||||||
apic_password: AnotherSecretPassword
|
apic_password: AnotherSecretPassword
|
||||||
apic_site_id: 12
|
apic_site_id: 12
|
||||||
urls:
|
urls:
|
||||||
|
@ -105,8 +105,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Remove a site
|
- name: Remove a site
|
||||||
msc_site:
|
mso_site:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
site: north_europe
|
site: north_europe
|
||||||
|
@ -114,8 +114,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Query a site
|
- name: Query a site
|
||||||
msc_site:
|
mso_site:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
site: north_europe
|
site: north_europe
|
||||||
|
@ -124,8 +124,8 @@ EXAMPLES = r'''
|
||||||
register: query_result
|
register: query_result
|
||||||
|
|
||||||
- name: Query all sites
|
- name: Query all sites
|
||||||
msc_site:
|
mso_site:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
state: query
|
state: query
|
||||||
|
@ -137,7 +137,7 @@ RETURN = r'''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -146,7 +146,7 @@ def main():
|
||||||
longitude=dict(type='float'),
|
longitude=dict(type='float'),
|
||||||
)
|
)
|
||||||
|
|
||||||
argument_spec = msc_argument_spec()
|
argument_spec = mso_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
apic_password=dict(type='str', no_log=True),
|
apic_password=dict(type='str', no_log=True),
|
||||||
apic_site_id=dict(type='str'),
|
apic_site_id=dict(type='str'),
|
||||||
|
@ -180,27 +180,27 @@ def main():
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
urls = module.params['urls']
|
urls = module.params['urls']
|
||||||
|
|
||||||
msc = MSCModule(module)
|
mso = MSOModule(module)
|
||||||
|
|
||||||
path = 'sites'
|
path = 'sites'
|
||||||
|
|
||||||
# Convert labels
|
# Convert labels
|
||||||
labels = msc.lookup_labels(module.params['labels'], 'site')
|
labels = mso.lookup_labels(module.params['labels'], 'site')
|
||||||
|
|
||||||
# Query for msc.existing object(s)
|
# Query for mso.existing object(s)
|
||||||
if site_id is None and site is None:
|
if site_id is None and site is None:
|
||||||
msc.existing = msc.query_objs(path)
|
mso.existing = mso.query_objs(path)
|
||||||
elif site_id is None:
|
elif site_id is None:
|
||||||
msc.existing = msc.get_obj(path, name=site)
|
mso.existing = mso.get_obj(path, name=site)
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
site_id = msc.existing['id']
|
site_id = mso.existing['id']
|
||||||
elif site is None:
|
elif site is None:
|
||||||
msc.existing = msc.get_obj(path, id=site_id)
|
mso.existing = mso.get_obj(path, id=site_id)
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.get_obj(path, id=site_id)
|
mso.existing = mso.get_obj(path, id=site_id)
|
||||||
existing_by_name = msc.get_obj(path, name=site)
|
existing_by_name = mso.get_obj(path, name=site)
|
||||||
if existing_by_name and site_id != existing_by_name['id']:
|
if existing_by_name and site_id != existing_by_name['id']:
|
||||||
msc.fail_json(msg="Provided site '{0}' with id '{1}' does not match existing id '{2}'.".format(site, site_id, existing_by_name['id']))
|
mso.fail_json(msg="Provided site '{0}' with id '{1}' does not match existing id '{2}'.".format(site, site_id, existing_by_name['id']))
|
||||||
|
|
||||||
# If we found an existing object, continue with it
|
# If we found an existing object, continue with it
|
||||||
if site_id:
|
if site_id:
|
||||||
|
@ -210,15 +210,15 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = {}
|
mso.existing = {}
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='DELETE', qs=dict(force='true'))
|
mso.existing = mso.request(path, method='DELETE', qs=dict(force='true'))
|
||||||
|
|
||||||
elif state == 'present':
|
elif state == 'present':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
|
|
||||||
payload = dict(
|
payload = dict(
|
||||||
apicSiteId=apic_site_id,
|
apicSiteId=apic_site_id,
|
||||||
|
@ -236,24 +236,24 @@ def main():
|
||||||
long=longitude,
|
long=longitude,
|
||||||
)
|
)
|
||||||
|
|
||||||
msc.sanitize(payload, collate=True)
|
mso.sanitize(payload, collate=True)
|
||||||
|
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if not issubset(msc.sent, msc.existing):
|
if not issubset(mso.sent, mso.existing):
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||||
else:
|
else:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||||
|
|
||||||
if 'password' in msc.existing:
|
if 'password' in mso.existing:
|
||||||
msc.existing['password'] = '******'
|
mso.existing['password'] = '******'
|
||||||
|
|
||||||
msc.exit_json()
|
mso.exit_json()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
|
|
||||||
DOCUMENTATION = r'''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: msc_tenant
|
module: mso_tenant
|
||||||
short_description: Manage tenants
|
short_description: Manage tenants
|
||||||
description:
|
description:
|
||||||
- Manage tenants on Cisco ACI Multi-Site.
|
- Manage tenants on Cisco ACI Multi-Site.
|
||||||
|
@ -43,13 +43,13 @@ options:
|
||||||
type: str
|
type: str
|
||||||
users:
|
users:
|
||||||
description:
|
description:
|
||||||
- A list of allowed users for this tenant.
|
- A list of associated users for this tenant.
|
||||||
- Using this property will replace any existing allowed users.
|
- Using this property will replace any existing associated users.
|
||||||
type: list
|
type: list
|
||||||
sites:
|
sites:
|
||||||
description:
|
description:
|
||||||
- A list of allowed sites for this tenant.
|
- A list of associated sites for this tenant.
|
||||||
- Using this property will replace any existing allowed sites.
|
- Using this property will replace any existing associated sites.
|
||||||
type: list
|
type: list
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
|
@ -58,13 +58,13 @@ options:
|
||||||
type: str
|
type: str
|
||||||
choices: [ absent, present, query ]
|
choices: [ absent, present, query ]
|
||||||
default: present
|
default: present
|
||||||
extends_documentation_fragment: msc
|
extends_documentation_fragment: mso
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
- name: Add a new tenant
|
- name: Add a new tenant
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
tenant: north_europe
|
tenant: north_europe
|
||||||
|
@ -75,8 +75,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Remove a tenant
|
- name: Remove a tenant
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
tenant: north_europe
|
tenant: north_europe
|
||||||
|
@ -84,8 +84,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Query a tenant
|
- name: Query a tenant
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
tenant: north_europe
|
tenant: north_europe
|
||||||
|
@ -94,8 +94,8 @@ EXAMPLES = r'''
|
||||||
register: query_result
|
register: query_result
|
||||||
|
|
||||||
- name: Query all tenants
|
- name: Query all tenants
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
state: query
|
state: query
|
||||||
|
@ -107,11 +107,11 @@ RETURN = r'''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = msc_argument_spec()
|
argument_spec = mso_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
description=dict(type='str'),
|
description=dict(type='str'),
|
||||||
display_name=dict(type='str'),
|
display_name=dict(type='str'),
|
||||||
|
@ -137,28 +137,28 @@ def main():
|
||||||
tenant_id = module.params['tenant_id']
|
tenant_id = module.params['tenant_id']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
msc = MSCModule(module)
|
mso = MSOModule(module)
|
||||||
|
|
||||||
# Convert sites and users
|
# Convert sites and users
|
||||||
sites = msc.lookup_sites(module.params['sites'])
|
sites = mso.lookup_sites(module.params['sites'])
|
||||||
users = msc.lookup_users(module.params['users'])
|
users = mso.lookup_users(module.params['users'])
|
||||||
|
|
||||||
path = 'tenants'
|
path = 'tenants'
|
||||||
|
|
||||||
# Query for existing object(s)
|
# Query for existing object(s)
|
||||||
if tenant_id is None and tenant is None:
|
if tenant_id is None and tenant is None:
|
||||||
msc.existing = msc.query_objs(path)
|
mso.existing = mso.query_objs(path)
|
||||||
elif tenant_id is None:
|
elif tenant_id is None:
|
||||||
msc.existing = msc.get_obj(path, name=tenant)
|
mso.existing = mso.get_obj(path, name=tenant)
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
tenant_id = msc.existing['id']
|
tenant_id = mso.existing['id']
|
||||||
elif tenant is None:
|
elif tenant is None:
|
||||||
msc.existing = msc.get_obj(path, id=tenant_id)
|
mso.existing = mso.get_obj(path, id=tenant_id)
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.get_obj(path, id=tenant_id)
|
mso.existing = mso.get_obj(path, id=tenant_id)
|
||||||
existing_by_name = msc.get_obj(path, name=tenant)
|
existing_by_name = mso.get_obj(path, name=tenant)
|
||||||
if existing_by_name and tenant_id != existing_by_name['id']:
|
if existing_by_name and tenant_id != existing_by_name['id']:
|
||||||
msc.fail_json(msg="Provided tenant '{0}' with id '{1}' does not match existing id '{2}'.".format(tenant, tenant_id, existing_by_name['id']))
|
mso.fail_json(msg="Provided tenant '{0}' with id '{1}' does not match existing id '{2}'.".format(tenant, tenant_id, existing_by_name['id']))
|
||||||
|
|
||||||
# If we found an existing object, continue with it
|
# If we found an existing object, continue with it
|
||||||
if tenant_id:
|
if tenant_id:
|
||||||
|
@ -168,15 +168,15 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = {}
|
mso.existing = {}
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='DELETE')
|
mso.existing = mso.request(path, method='DELETE')
|
||||||
|
|
||||||
elif state == 'present':
|
elif state == 'present':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
|
|
||||||
payload = dict(
|
payload = dict(
|
||||||
description=description,
|
description=description,
|
||||||
|
@ -187,29 +187,29 @@ def main():
|
||||||
userAssociations=users,
|
userAssociations=users,
|
||||||
)
|
)
|
||||||
|
|
||||||
msc.sanitize(payload, collate=True)
|
mso.sanitize(payload, collate=True)
|
||||||
|
|
||||||
# Ensure displayName is not undefined
|
# Ensure displayName is not undefined
|
||||||
if msc.sent.get('displayName') is None:
|
if mso.sent.get('displayName') is None:
|
||||||
msc.sent['displayName'] = tenant
|
mso.sent['displayName'] = tenant
|
||||||
|
|
||||||
# Ensure tenant has at least admin user
|
# Ensure tenant has at least admin user
|
||||||
if msc.sent.get('userAssociations') is None:
|
if mso.sent.get('userAssociations') is None:
|
||||||
msc.sent['userAssociations'] = [dict(userId="0000ffff0000000000000020")]
|
mso.sent['userAssociations'] = [dict(userId="0000ffff0000000000000020")]
|
||||||
|
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if not issubset(msc.sent, msc.existing):
|
if not issubset(mso.sent, mso.existing):
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||||
else:
|
else:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||||
|
|
||||||
msc.exit_json()
|
mso.exit_json()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
|
|
||||||
DOCUMENTATION = r'''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: msc_user
|
module: mso_user
|
||||||
short_description: Manage users
|
short_description: Manage users
|
||||||
description:
|
description:
|
||||||
- Manage users on Cisco ACI Multi-Site.
|
- Manage users on Cisco ACI Multi-Site.
|
||||||
|
@ -80,13 +80,13 @@ options:
|
||||||
notes:
|
notes:
|
||||||
- A default installation of ACI Multi-Site ships with admin password 'we1come!' which requires a password change on first login.
|
- A default installation of ACI Multi-Site ships with admin password 'we1come!' which requires a password change on first login.
|
||||||
See the examples of how to change the 'admin' password using Ansible.
|
See the examples of how to change the 'admin' password using Ansible.
|
||||||
extends_documentation_fragment: msc
|
extends_documentation_fragment: mso
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = r'''
|
EXAMPLES = r'''
|
||||||
- name: Update initial admin password
|
- name: Update initial admin password
|
||||||
msc_user:
|
mso_user:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: we1come!
|
password: we1come!
|
||||||
user_name: admin
|
user_name: admin
|
||||||
|
@ -95,8 +95,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Add a new user
|
- name: Add a new user
|
||||||
msc_user:
|
mso_user:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
user_name: dag
|
user_name: dag
|
||||||
|
@ -109,8 +109,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Remove a user
|
- name: Remove a user
|
||||||
msc_user:
|
mso_user:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
user_name: dag
|
user_name: dag
|
||||||
|
@ -118,8 +118,8 @@ EXAMPLES = r'''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Query a user
|
- name: Query a user
|
||||||
msc_user:
|
mso_user:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
user_name: dag
|
user_name: dag
|
||||||
|
@ -128,8 +128,8 @@ EXAMPLES = r'''
|
||||||
register: query_result
|
register: query_result
|
||||||
|
|
||||||
- name: Query all users
|
- name: Query all users
|
||||||
msc_user:
|
mso_user:
|
||||||
host: msc_host
|
host: mso_host
|
||||||
username: admin
|
username: admin
|
||||||
password: SomeSecretPassword
|
password: SomeSecretPassword
|
||||||
state: query
|
state: query
|
||||||
|
@ -140,11 +140,11 @@ EXAMPLES = r'''
|
||||||
RETURN = r''' # '''
|
RETURN = r''' # '''
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.network.aci.msc import MSCModule, msc_argument_spec, issubset
|
from ansible.module_utils.network.aci.mso import MSOModule, mso_argument_spec, issubset
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = msc_argument_spec()
|
argument_spec = mso_argument_spec()
|
||||||
argument_spec.update(
|
argument_spec.update(
|
||||||
user_id=dict(type='str', required=False),
|
user_id=dict(type='str', required=False),
|
||||||
user=dict(type='str', required=False, aliases=['name', 'user_name']),
|
user=dict(type='str', required=False, aliases=['name', 'user_name']),
|
||||||
|
@ -179,27 +179,27 @@ def main():
|
||||||
account_status = module.params['account_status']
|
account_status = module.params['account_status']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
msc = MSCModule(module)
|
mso = MSOModule(module)
|
||||||
|
|
||||||
roles = msc.lookup_roles(module.params['roles'])
|
roles = mso.lookup_roles(module.params['roles'])
|
||||||
domain = msc.lookup_domain(module.params['domain'])
|
domain = mso.lookup_domain(module.params['domain'])
|
||||||
|
|
||||||
path = 'users'
|
path = 'users'
|
||||||
|
|
||||||
# Query for existing object(s)
|
# Query for existing object(s)
|
||||||
if user_id is None and user_name is None:
|
if user_id is None and user_name is None:
|
||||||
msc.existing = msc.query_objs(path)
|
mso.existing = mso.query_objs(path)
|
||||||
elif user_id is None:
|
elif user_id is None:
|
||||||
msc.existing = msc.get_obj(path, username=user_name)
|
mso.existing = mso.get_obj(path, username=user_name)
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
user_id = msc.existing['id']
|
user_id = mso.existing['id']
|
||||||
elif user_name is None:
|
elif user_name is None:
|
||||||
msc.existing = msc.get_obj(path, id=user_id)
|
mso.existing = mso.get_obj(path, id=user_id)
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.get_obj(path, id=user_id)
|
mso.existing = mso.get_obj(path, id=user_id)
|
||||||
existing_by_name = msc.get_obj(path, username=user_name)
|
existing_by_name = mso.get_obj(path, username=user_name)
|
||||||
if existing_by_name and user_id != existing_by_name['id']:
|
if existing_by_name and user_id != existing_by_name['id']:
|
||||||
msc.fail_json(msg="Provided user '{0}' with id '{1}' does not match existing id '{2}'.".format(user_name, user_id, existing_by_name['id']))
|
mso.fail_json(msg="Provided user '{0}' with id '{1}' does not match existing id '{2}'.".format(user_name, user_id, existing_by_name['id']))
|
||||||
|
|
||||||
# If we found an existing object, continue with it
|
# If we found an existing object, continue with it
|
||||||
if user_id:
|
if user_id:
|
||||||
|
@ -209,15 +209,15 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif state == 'absent':
|
elif state == 'absent':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = {}
|
mso.existing = {}
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='DELETE')
|
mso.existing = mso.request(path, method='DELETE')
|
||||||
|
|
||||||
elif state == 'present':
|
elif state == 'present':
|
||||||
msc.previous = msc.existing
|
mso.previous = mso.existing
|
||||||
|
|
||||||
payload = dict(
|
payload = dict(
|
||||||
id=user_id,
|
id=user_id,
|
||||||
|
@ -234,29 +234,29 @@ def main():
|
||||||
# remote=True,
|
# remote=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
msc.sanitize(payload, collate=True)
|
mso.sanitize(payload, collate=True)
|
||||||
|
|
||||||
if msc.sent.get('accountStatus') is None:
|
if mso.sent.get('accountStatus') is None:
|
||||||
msc.sent['accountStatus'] = 'active'
|
mso.sent['accountStatus'] = 'active'
|
||||||
|
|
||||||
if msc.existing:
|
if mso.existing:
|
||||||
if not issubset(msc.sent, msc.existing):
|
if not issubset(mso.sent, mso.existing):
|
||||||
# NOTE: Since MSC always returns '******' as password, we need to assume a change
|
# NOTE: Since MSO always returns '******' as password, we need to assume a change
|
||||||
if 'password' in msc.proposed:
|
if 'password' in mso.proposed:
|
||||||
msc.module.warn("A password change is assumed, as the MSC REST API does not return passwords we do not know.")
|
mso.module.warn("A password change is assumed, as the MSO REST API does not return passwords we do not know.")
|
||||||
msc.result['changed'] = True
|
mso.result['changed'] = True
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='PUT', data=msc.sent)
|
mso.existing = mso.request(path, method='PUT', data=mso.sent)
|
||||||
else:
|
else:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
msc.existing = msc.proposed
|
mso.existing = mso.proposed
|
||||||
else:
|
else:
|
||||||
msc.existing = msc.request(path, method='POST', data=msc.sent)
|
mso.existing = mso.request(path, method='POST', data=mso.sent)
|
||||||
|
|
||||||
msc.exit_json()
|
mso.exit_json()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
|
@ -24,15 +24,15 @@ aci_use_proxy=no
|
||||||
[aci]
|
[aci]
|
||||||
localhost ansible_ssh_host=127.0.0.1 ansible_connection=local
|
localhost ansible_ssh_host=127.0.0.1 ansible_connection=local
|
||||||
|
|
||||||
[msc:vars]
|
[mso:vars]
|
||||||
msc_hostname=your-msc-1
|
mso_hostname=your-mso-1
|
||||||
msc_username=admin
|
mso_username=admin
|
||||||
msc_password=your-msc-password
|
mso_password=your-mso-password
|
||||||
msc_validate_certs=no
|
mso_validate_certs=no
|
||||||
msc_use_ssl=yes
|
mso_use_ssl=yes
|
||||||
msc_use_proxy=no
|
mso_use_proxy=no
|
||||||
|
|
||||||
[msc]
|
[mso]
|
||||||
localhost ansible_ssh_host=127.0.0.1 ansible_connection=local
|
localhost ansible_ssh_host=127.0.0.1 ansible_connection=local
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
|
@ -19,7 +19,7 @@ iosxr
|
||||||
ironware
|
ironware
|
||||||
junos
|
junos
|
||||||
meraki
|
meraki
|
||||||
msc
|
mso
|
||||||
net
|
net
|
||||||
netconf
|
netconf
|
||||||
nxos
|
nxos
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
# Test code for the MSC modules
|
# Test code for the MSO modules
|
||||||
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
||||||
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Test that we have an ACI MultiSite host, username and password
|
- name: Test that we have an ACI MultiSite host, username and password
|
||||||
fail:
|
fail:
|
||||||
msg: 'Please define the following variables: msc_hostname, msc_username and msc_password.'
|
msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.'
|
||||||
when: msc_hostname is not defined or msc_username is not defined or msc_password is not defined
|
when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined
|
||||||
|
|
||||||
|
|
||||||
# CLEAN ENVIRONMENT
|
# CLEAN ENVIRONMENT
|
||||||
- name: Remove label ansible_test2
|
- name: Remove label ansible_test2
|
||||||
msc_label: &label_absent
|
mso_label: &label_absent
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
label: ansible_test2
|
label: ansible_test2
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Remove label ansible_test
|
- name: Remove label ansible_test
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_absent
|
<<: *label_absent
|
||||||
label: ansible_test
|
label: ansible_test
|
||||||
register: cm_remove_label
|
register: cm_remove_label
|
||||||
|
@ -31,14 +31,14 @@
|
||||||
|
|
||||||
# ADD LABEL
|
# ADD LABEL
|
||||||
- name: Add label (check_mode)
|
- name: Add label (check_mode)
|
||||||
msc_label: &label_present
|
mso_label: &label_present
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
label: ansible_test
|
label: ansible_test
|
||||||
state: present
|
state: present
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
- cm_add_label.current.type == 'site'
|
- cm_add_label.current.type == 'site'
|
||||||
|
|
||||||
- name: Add label (normal mode)
|
- name: Add label (normal mode)
|
||||||
msc_label: *label_present
|
mso_label: *label_present
|
||||||
register: nm_add_label
|
register: nm_add_label
|
||||||
|
|
||||||
- name: nm_Verify add_label
|
- name: nm_Verify add_label
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
- nm_add_label.current.type == 'site'
|
- nm_add_label.current.type == 'site'
|
||||||
|
|
||||||
- name: Add label again (check_mode)
|
- name: Add label again (check_mode)
|
||||||
msc_label: *label_present
|
mso_label: *label_present
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_add_label_again
|
register: cm_add_label_again
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
- cm_add_label_again.current.type == 'site'
|
- cm_add_label_again.current.type == 'site'
|
||||||
|
|
||||||
- name: Add label again (normal mode)
|
- name: Add label again (normal mode)
|
||||||
msc_label: *label_present
|
mso_label: *label_present
|
||||||
register: nm_add_label_again
|
register: nm_add_label_again
|
||||||
|
|
||||||
- name: Verify nm_add_label_again
|
- name: Verify nm_add_label_again
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
|
|
||||||
# CHANGE LABEL
|
# CHANGE LABEL
|
||||||
- name: Change label (check_mode)
|
- name: Change label (check_mode)
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_present
|
<<: *label_present
|
||||||
label_id: '{{ nm_add_label.current.id }}'
|
label_id: '{{ nm_add_label.current.id }}'
|
||||||
label: ansible_test2
|
label: ansible_test2
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
- cm_change_label.current.type == 'site'
|
- cm_change_label.current.type == 'site'
|
||||||
|
|
||||||
- name: Change label (normal mode)
|
- name: Change label (normal mode)
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_present
|
<<: *label_present
|
||||||
label_id: '{{ nm_add_label.current.id }}'
|
label_id: '{{ nm_add_label.current.id }}'
|
||||||
label: ansible_test2
|
label: ansible_test2
|
||||||
|
@ -130,7 +130,7 @@
|
||||||
- nm_change_label.current.type == 'site'
|
- nm_change_label.current.type == 'site'
|
||||||
|
|
||||||
- name: Change label again (check_mode)
|
- name: Change label again (check_mode)
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_present
|
<<: *label_present
|
||||||
label_id: '{{ nm_add_label.current.id }}'
|
label_id: '{{ nm_add_label.current.id }}'
|
||||||
label: ansible_test2
|
label: ansible_test2
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
- cm_change_label_again.current.type == 'site'
|
- cm_change_label_again.current.type == 'site'
|
||||||
|
|
||||||
- name: Change label again (normal mode)
|
- name: Change label again (normal mode)
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_present
|
<<: *label_present
|
||||||
label_id: '{{ nm_add_label.current.id }}'
|
label_id: '{{ nm_add_label.current.id }}'
|
||||||
label: ansible_test2
|
label: ansible_test2
|
||||||
|
@ -163,20 +163,20 @@
|
||||||
|
|
||||||
# QUERY ALL LABELS
|
# QUERY ALL LABELS
|
||||||
- name: Query all labels (check_mode)
|
- name: Query all labels (check_mode)
|
||||||
msc_label: &label_query
|
mso_label: &label_query
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
state: query
|
state: query
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_all_labels
|
register: cm_query_all_labels
|
||||||
|
|
||||||
- name: Query all labels (normal mode)
|
- name: Query all labels (normal mode)
|
||||||
msc_label: *label_query
|
mso_label: *label_query
|
||||||
register: nm_query_all_labels
|
register: nm_query_all_labels
|
||||||
|
|
||||||
- name: Verify query_all_labels
|
- name: Verify query_all_labels
|
||||||
|
@ -190,14 +190,14 @@
|
||||||
|
|
||||||
# QUERY A LABEL
|
# QUERY A LABEL
|
||||||
- name: Query our label
|
- name: Query our label
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_query
|
<<: *label_query
|
||||||
label: ansible_test2
|
label: ansible_test2
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_label
|
register: cm_query_label
|
||||||
|
|
||||||
- name: Query our label
|
- name: Query our label
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_query
|
<<: *label_query
|
||||||
label: ansible_test2
|
label: ansible_test2
|
||||||
register: nm_query_label
|
register: nm_query_label
|
||||||
|
@ -218,7 +218,7 @@
|
||||||
|
|
||||||
# REMOVE LABEL
|
# REMOVE LABEL
|
||||||
- name: Remove label (check_mode)
|
- name: Remove label (check_mode)
|
||||||
msc_label: *label_absent
|
mso_label: *label_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_label
|
register: cm_remove_label
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@
|
||||||
- cm_remove_label.current == {}
|
- cm_remove_label.current == {}
|
||||||
|
|
||||||
- name: Remove label (normal mode)
|
- name: Remove label (normal mode)
|
||||||
msc_label: *label_absent
|
mso_label: *label_absent
|
||||||
register: nm_remove_label
|
register: nm_remove_label
|
||||||
|
|
||||||
- name: Verify nm_remove_label
|
- name: Verify nm_remove_label
|
||||||
|
@ -239,7 +239,7 @@
|
||||||
- nm_remove_label.current == {}
|
- nm_remove_label.current == {}
|
||||||
|
|
||||||
- name: Remove label again (check_mode)
|
- name: Remove label again (check_mode)
|
||||||
msc_label: *label_absent
|
mso_label: *label_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_label_again
|
register: cm_remove_label_again
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@
|
||||||
- cm_remove_label_again.current == {}
|
- cm_remove_label_again.current == {}
|
||||||
|
|
||||||
- name: Remove label again (normal mode)
|
- name: Remove label again (normal mode)
|
||||||
msc_label: *label_absent
|
mso_label: *label_absent
|
||||||
register: nm_remove_label_again
|
register: nm_remove_label_again
|
||||||
|
|
||||||
- name: Verify nm_remove_label_again
|
- name: Verify nm_remove_label_again
|
||||||
|
@ -262,14 +262,14 @@
|
||||||
|
|
||||||
# QUERY NON-EXISTING LABEL
|
# QUERY NON-EXISTING LABEL
|
||||||
- name: Query non-existing label (check_mode)
|
- name: Query non-existing label (check_mode)
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_query
|
<<: *label_query
|
||||||
label: ansible_test
|
label: ansible_test
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_non_label
|
register: cm_query_non_label
|
||||||
|
|
||||||
- name: Query non-existing label (normal mode)
|
- name: Query non-existing label (normal mode)
|
||||||
msc_label:
|
mso_label:
|
||||||
<<: *label_query
|
<<: *label_query
|
||||||
label: ansible_test
|
label: ansible_test
|
||||||
register: nm_query_non_label
|
register: nm_query_non_label
|
|
@ -1,29 +1,29 @@
|
||||||
# Test code for the MSC modules
|
# Test code for the MSO modules
|
||||||
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
||||||
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Test that we have an ACI MultiSite host, username and password
|
- name: Test that we have an ACI MultiSite host, username and password
|
||||||
fail:
|
fail:
|
||||||
msg: 'Please define the following variables: msc_hostname, msc_username and msc_password.'
|
msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.'
|
||||||
when: msc_hostname is not defined or msc_username is not defined or msc_password is not defined
|
when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined
|
||||||
|
|
||||||
|
|
||||||
# CLEAN ENVIRONMENT
|
# CLEAN ENVIRONMENT
|
||||||
- name: Remove role ansible_test2
|
- name: Remove role ansible_test2
|
||||||
msc_role: &role_absent
|
mso_role: &role_absent
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
role: ansible_test2
|
role: ansible_test2
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Remove role ansible_test
|
- name: Remove role ansible_test
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_absent
|
<<: *role_absent
|
||||||
role: ansible_test
|
role: ansible_test
|
||||||
register: cm_remove_role
|
register: cm_remove_role
|
||||||
|
@ -31,14 +31,14 @@
|
||||||
|
|
||||||
# ADD ROLE
|
# ADD ROLE
|
||||||
- name: Add role (check_mode)
|
- name: Add role (check_mode)
|
||||||
msc_role: &role_present
|
mso_role: &role_present
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
role: ansible_test
|
role: ansible_test
|
||||||
description: Ansible test role
|
description: Ansible test role
|
||||||
permissions: view-sites
|
permissions: view-sites
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
- cm_add_role.current.id is not defined
|
- cm_add_role.current.id is not defined
|
||||||
|
|
||||||
- name: Add role (normal mode)
|
- name: Add role (normal mode)
|
||||||
msc_role: *role_present
|
mso_role: *role_present
|
||||||
register: nm_add_role
|
register: nm_add_role
|
||||||
|
|
||||||
- name: nm_Verify add_role
|
- name: nm_Verify add_role
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
- nm_add_role.current.id is defined
|
- nm_add_role.current.id is defined
|
||||||
|
|
||||||
- name: Add role again (check_mode)
|
- name: Add role again (check_mode)
|
||||||
msc_role: *role_present
|
mso_role: *role_present
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_add_role_again
|
register: cm_add_role_again
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
- cm_add_role_again.current.id == nm_add_role.current.id
|
- cm_add_role_again.current.id == nm_add_role.current.id
|
||||||
|
|
||||||
- name: Add role again (normal mode)
|
- name: Add role again (normal mode)
|
||||||
msc_role: *role_present
|
mso_role: *role_present
|
||||||
register: nm_add_role_again
|
register: nm_add_role_again
|
||||||
|
|
||||||
- name: Verify nm_add_role_again
|
- name: Verify nm_add_role_again
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
# CHANGE ROLE
|
# CHANGE ROLE
|
||||||
- name: Change role (check_mode)
|
- name: Change role (check_mode)
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_present
|
<<: *role_present
|
||||||
role_id: '{{ nm_add_role.current.id }}'
|
role_id: '{{ nm_add_role.current.id }}'
|
||||||
role: ansible_test2
|
role: ansible_test2
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
- cm_change_role.current.id == nm_add_role.current.id
|
- cm_change_role.current.id == nm_add_role.current.id
|
||||||
|
|
||||||
- name: Change role (normal mode)
|
- name: Change role (normal mode)
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_present
|
<<: *role_present
|
||||||
role_id: '{{ nm_add_role.current.id }}'
|
role_id: '{{ nm_add_role.current.id }}'
|
||||||
role: ansible_test2
|
role: ansible_test2
|
||||||
|
@ -134,7 +134,7 @@
|
||||||
- nm_change_role.current.id == nm_add_role.current.id
|
- nm_change_role.current.id == nm_add_role.current.id
|
||||||
|
|
||||||
- name: Change role again (check_mode)
|
- name: Change role again (check_mode)
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_present
|
<<: *role_present
|
||||||
role_id: '{{ nm_add_role.current.id }}'
|
role_id: '{{ nm_add_role.current.id }}'
|
||||||
role: ansible_test2
|
role: ansible_test2
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
- cm_change_role_again.current.id == nm_add_role.current.id
|
- cm_change_role_again.current.id == nm_add_role.current.id
|
||||||
|
|
||||||
- name: Change role again (normal mode)
|
- name: Change role again (normal mode)
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_present
|
<<: *role_present
|
||||||
role_id: '{{ nm_add_role.current.id }}'
|
role_id: '{{ nm_add_role.current.id }}'
|
||||||
role: ansible_test2
|
role: ansible_test2
|
||||||
|
@ -169,20 +169,20 @@
|
||||||
|
|
||||||
# QUERY ALL ROLES
|
# QUERY ALL ROLES
|
||||||
- name: Query all roles (check_mode)
|
- name: Query all roles (check_mode)
|
||||||
msc_role: &role_query
|
mso_role: &role_query
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
state: query
|
state: query
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_all_roles
|
register: cm_query_all_roles
|
||||||
|
|
||||||
- name: Query all roles (normal mode)
|
- name: Query all roles (normal mode)
|
||||||
msc_role: *role_query
|
mso_role: *role_query
|
||||||
register: nm_query_all_roles
|
register: nm_query_all_roles
|
||||||
|
|
||||||
- name: Verify query_all_roles
|
- name: Verify query_all_roles
|
||||||
|
@ -196,14 +196,14 @@
|
||||||
|
|
||||||
# QUERY A ROLE
|
# QUERY A ROLE
|
||||||
- name: Query our role
|
- name: Query our role
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_query
|
<<: *role_query
|
||||||
role: ansible_test2
|
role: ansible_test2
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_role
|
register: cm_query_role
|
||||||
|
|
||||||
- name: Query our role
|
- name: Query our role
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_query
|
<<: *role_query
|
||||||
role: ansible_test2
|
role: ansible_test2
|
||||||
register: nm_query_role
|
register: nm_query_role
|
||||||
|
@ -224,7 +224,7 @@
|
||||||
|
|
||||||
# REMOVE ROLE
|
# REMOVE ROLE
|
||||||
- name: Remove role (check_mode)
|
- name: Remove role (check_mode)
|
||||||
msc_role: *role_absent
|
mso_role: *role_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_role
|
register: cm_remove_role
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@
|
||||||
- cm_remove_role.current == {}
|
- cm_remove_role.current == {}
|
||||||
|
|
||||||
- name: Remove role (normal mode)
|
- name: Remove role (normal mode)
|
||||||
msc_role: *role_absent
|
mso_role: *role_absent
|
||||||
register: nm_remove_role
|
register: nm_remove_role
|
||||||
|
|
||||||
- name: Verify nm_remove_role
|
- name: Verify nm_remove_role
|
||||||
|
@ -245,7 +245,7 @@
|
||||||
- nm_remove_role.current == {}
|
- nm_remove_role.current == {}
|
||||||
|
|
||||||
- name: Remove role again (check_mode)
|
- name: Remove role again (check_mode)
|
||||||
msc_role: *role_absent
|
mso_role: *role_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_role_again
|
register: cm_remove_role_again
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@
|
||||||
- cm_remove_role_again.current == {}
|
- cm_remove_role_again.current == {}
|
||||||
|
|
||||||
- name: Remove role again (normal mode)
|
- name: Remove role again (normal mode)
|
||||||
msc_role: *role_absent
|
mso_role: *role_absent
|
||||||
register: nm_remove_role_again
|
register: nm_remove_role_again
|
||||||
|
|
||||||
- name: Verify nm_remove_role_again
|
- name: Verify nm_remove_role_again
|
||||||
|
@ -268,14 +268,14 @@
|
||||||
|
|
||||||
# QUERY NON-EXISTING ROLE
|
# QUERY NON-EXISTING ROLE
|
||||||
- name: Query non-existing role (check_mode)
|
- name: Query non-existing role (check_mode)
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_query
|
<<: *role_query
|
||||||
role: ansible_test
|
role: ansible_test
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_non_role
|
register: cm_query_non_role
|
||||||
|
|
||||||
- name: Query non-existing role (normal mode)
|
- name: Query non-existing role (normal mode)
|
||||||
msc_role:
|
mso_role:
|
||||||
<<: *role_query
|
<<: *role_query
|
||||||
role: ansible_test
|
role: ansible_test
|
||||||
register: nm_query_non_role
|
register: nm_query_non_role
|
|
@ -1,45 +1,45 @@
|
||||||
# Test code for the MSC modules
|
# Test code for the MSO modules
|
||||||
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
||||||
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Test that we have an ACI MultiSite host, username and password
|
- name: Test that we have an ACI MultiSite host, username and password
|
||||||
fail:
|
fail:
|
||||||
msg: 'Please define the following variables: msc_hostname, msc_username and msc_password.'
|
msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.'
|
||||||
when: msc_hostname is not defined or msc_username is not defined or msc_password is not defined
|
when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined
|
||||||
|
|
||||||
|
|
||||||
# CLEAN ENVIRONMENT
|
# CLEAN ENVIRONMENT
|
||||||
- name: Remove site 2
|
- name: Remove site 2
|
||||||
msc_site: &site_absent
|
mso_site: &site_absent
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
site: '{{ msc_site | default("ansible_test") }}_2'
|
site: '{{ mso_site | default("ansible_test") }}_2'
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Remove site
|
- name: Remove site
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_absent
|
<<: *site_absent
|
||||||
site: '{{ msc_site | default("ansible_test") }}'
|
site: '{{ mso_site | default("ansible_test") }}'
|
||||||
register: cm_remove_site
|
register: cm_remove_site
|
||||||
|
|
||||||
|
|
||||||
# ADD SITE
|
# ADD SITE
|
||||||
- name: Add site (check_mode)
|
- name: Add site (check_mode)
|
||||||
msc_site: &site_present
|
mso_site: &site_present
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
site: '{{ msc_site | default("ansible_test") }}'
|
site: '{{ mso_site | default("ansible_test") }}'
|
||||||
apic_username: admin
|
apic_username: admin
|
||||||
apic_password: '{{ apic_password }}'
|
apic_password: '{{ apic_password }}'
|
||||||
apic_site_id: 101
|
apic_site_id: 101
|
||||||
|
@ -62,10 +62,10 @@
|
||||||
- cm_add_site is changed
|
- cm_add_site is changed
|
||||||
- cm_add_site.previous == {}
|
- cm_add_site.previous == {}
|
||||||
- cm_add_site.current.id is not defined
|
- cm_add_site.current.id is not defined
|
||||||
- cm_add_site.current.name == msc_site|default("ansible_test")
|
- cm_add_site.current.name == mso_site|default("ansible_test")
|
||||||
|
|
||||||
- name: Add site (normal mode)
|
- name: Add site (normal mode)
|
||||||
msc_site: *site_present
|
mso_site: *site_present
|
||||||
register: nm_add_site
|
register: nm_add_site
|
||||||
|
|
||||||
- name: nm_Verify add_site
|
- name: nm_Verify add_site
|
||||||
|
@ -74,10 +74,10 @@
|
||||||
- nm_add_site is changed
|
- nm_add_site is changed
|
||||||
- nm_add_site.previous == {}
|
- nm_add_site.previous == {}
|
||||||
- nm_add_site.current.id is defined
|
- nm_add_site.current.id is defined
|
||||||
- nm_add_site.current.name == msc_site|default("ansible_test")
|
- nm_add_site.current.name == mso_site|default("ansible_test")
|
||||||
|
|
||||||
- name: Add site again (check_mode)
|
- name: Add site again (check_mode)
|
||||||
msc_site: *site_present
|
mso_site: *site_present
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_add_site_again
|
register: cm_add_site_again
|
||||||
|
|
||||||
|
@ -85,29 +85,29 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- cm_add_site_again is not changed
|
- cm_add_site_again is not changed
|
||||||
- cm_add_site_again.previous.name == msc_site|default("ansible_test")
|
- cm_add_site_again.previous.name == mso_site|default("ansible_test")
|
||||||
- cm_add_site_again.current.id == nm_add_site.current.id
|
- cm_add_site_again.current.id == nm_add_site.current.id
|
||||||
- cm_add_site_again.current.name == msc_site|default("ansible_test")
|
- cm_add_site_again.current.name == mso_site|default("ansible_test")
|
||||||
|
|
||||||
- name: Add site again (normal mode)
|
- name: Add site again (normal mode)
|
||||||
msc_site: *site_present
|
mso_site: *site_present
|
||||||
register: nm_add_site_again
|
register: nm_add_site_again
|
||||||
|
|
||||||
- name: Verify nm_add_site_again
|
- name: Verify nm_add_site_again
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- nm_add_site_again is not changed
|
- nm_add_site_again is not changed
|
||||||
- nm_add_site_again.previous.name == msc_site|default("ansible_test")
|
- nm_add_site_again.previous.name == mso_site|default("ansible_test")
|
||||||
- nm_add_site_again.current.id == nm_add_site.current.id
|
- nm_add_site_again.current.id == nm_add_site.current.id
|
||||||
- nm_add_site_again.current.name == msc_site|default("ansible_test")
|
- nm_add_site_again.current.name == mso_site|default("ansible_test")
|
||||||
|
|
||||||
|
|
||||||
# CHANGE SITE
|
# CHANGE SITE
|
||||||
- name: Change site (check_mode)
|
- name: Change site (check_mode)
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_present
|
<<: *site_present
|
||||||
site_id: '{{ nm_add_site.current.id }}'
|
site_id: '{{ nm_add_site.current.id }}'
|
||||||
site: '{{ msc_site | default("ansible_test") }}_2'
|
site: '{{ mso_site | default("ansible_test") }}_2'
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_change_site
|
register: cm_change_site
|
||||||
|
|
||||||
|
@ -116,13 +116,13 @@
|
||||||
that:
|
that:
|
||||||
- cm_change_site is changed
|
- cm_change_site is changed
|
||||||
- cm_change_site.current.id == nm_add_site.current.id
|
- cm_change_site.current.id == nm_add_site.current.id
|
||||||
- cm_change_site.current.name == '{{ msc_site | default("ansible_test") }}_2'
|
- cm_change_site.current.name == '{{ mso_site | default("ansible_test") }}_2'
|
||||||
|
|
||||||
- name: Change site (normal mode)
|
- name: Change site (normal mode)
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_present
|
<<: *site_present
|
||||||
site_id: '{{ nm_add_site.current.id }}'
|
site_id: '{{ nm_add_site.current.id }}'
|
||||||
site: '{{ msc_site | default("ansible_test") }}_2'
|
site: '{{ mso_site | default("ansible_test") }}_2'
|
||||||
output_level: debug
|
output_level: debug
|
||||||
register: nm_change_site
|
register: nm_change_site
|
||||||
|
|
||||||
|
@ -131,13 +131,13 @@
|
||||||
that:
|
that:
|
||||||
- nm_change_site is changed
|
- nm_change_site is changed
|
||||||
- nm_change_site.current.id == nm_add_site.current.id
|
- nm_change_site.current.id == nm_add_site.current.id
|
||||||
- nm_change_site.current.name == '{{ msc_site | default("ansible_test") }}_2'
|
- nm_change_site.current.name == '{{ mso_site | default("ansible_test") }}_2'
|
||||||
|
|
||||||
- name: Change site again (check_mode)
|
- name: Change site again (check_mode)
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_present
|
<<: *site_present
|
||||||
site_id: '{{ nm_add_site.current.id }}'
|
site_id: '{{ nm_add_site.current.id }}'
|
||||||
site: '{{ msc_site | default("ansible_test") }}_2'
|
site: '{{ mso_site | default("ansible_test") }}_2'
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_change_site_again
|
register: cm_change_site_again
|
||||||
|
|
||||||
|
@ -146,13 +146,13 @@
|
||||||
that:
|
that:
|
||||||
- cm_change_site_again is not changed
|
- cm_change_site_again is not changed
|
||||||
- cm_change_site_again.current.id == nm_add_site.current.id
|
- cm_change_site_again.current.id == nm_add_site.current.id
|
||||||
- cm_change_site_again.current.name == '{{ msc_site | default("ansible_test") }}_2'
|
- cm_change_site_again.current.name == '{{ mso_site | default("ansible_test") }}_2'
|
||||||
|
|
||||||
- name: Change site again (normal mode)
|
- name: Change site again (normal mode)
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_present
|
<<: *site_present
|
||||||
site_id: '{{ nm_add_site.current.id }}'
|
site_id: '{{ nm_add_site.current.id }}'
|
||||||
site: '{{ msc_site | default("ansible_test") }}_2'
|
site: '{{ mso_site | default("ansible_test") }}_2'
|
||||||
register: nm_change_site_again
|
register: nm_change_site_again
|
||||||
|
|
||||||
- name: Verify nm_change_site_again
|
- name: Verify nm_change_site_again
|
||||||
|
@ -160,25 +160,25 @@
|
||||||
that:
|
that:
|
||||||
- nm_change_site_again is not changed
|
- nm_change_site_again is not changed
|
||||||
- nm_change_site_again.current.id == nm_add_site.current.id
|
- nm_change_site_again.current.id == nm_add_site.current.id
|
||||||
- nm_change_site_again.current.name == '{{ msc_site | default("ansible_test") }}_2'
|
- nm_change_site_again.current.name == '{{ mso_site | default("ansible_test") }}_2'
|
||||||
|
|
||||||
|
|
||||||
# QUERY ALL SITES
|
# QUERY ALL SITES
|
||||||
- name: Query all sites (check_mode)
|
- name: Query all sites (check_mode)
|
||||||
msc_site: &site_query
|
mso_site: &site_query
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
state: query
|
state: query
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_all_sites
|
register: cm_query_all_sites
|
||||||
|
|
||||||
- name: Query all sites (normal mode)
|
- name: Query all sites (normal mode)
|
||||||
msc_site: *site_query
|
mso_site: *site_query
|
||||||
register: nm_query_all_sites
|
register: nm_query_all_sites
|
||||||
|
|
||||||
- name: Verify query_all_sites
|
- name: Verify query_all_sites
|
||||||
|
@ -192,16 +192,16 @@
|
||||||
|
|
||||||
# QUERY A SITE
|
# QUERY A SITE
|
||||||
- name: Query our site
|
- name: Query our site
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_query
|
<<: *site_query
|
||||||
site: '{{ msc_site | default("ansible_test") }}_2'
|
site: '{{ mso_site | default("ansible_test") }}_2'
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_site
|
register: cm_query_site
|
||||||
|
|
||||||
- name: Query our site
|
- name: Query our site
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_query
|
<<: *site_query
|
||||||
site: '{{ msc_site | default("ansible_test") }}_2'
|
site: '{{ mso_site | default("ansible_test") }}_2'
|
||||||
register: nm_query_site
|
register: nm_query_site
|
||||||
|
|
||||||
- name: Verify query_site
|
- name: Verify query_site
|
||||||
|
@ -209,16 +209,16 @@
|
||||||
that:
|
that:
|
||||||
- cm_query_site is not changed
|
- cm_query_site is not changed
|
||||||
- cm_query_site.current.id == nm_add_site.current.id
|
- cm_query_site.current.id == nm_add_site.current.id
|
||||||
- cm_query_site.current.name == '{{ msc_site | default("ansible_test") }}_2'
|
- cm_query_site.current.name == '{{ mso_site | default("ansible_test") }}_2'
|
||||||
- nm_query_site is not changed
|
- nm_query_site is not changed
|
||||||
- nm_query_site.current.id == nm_add_site.current.id
|
- nm_query_site.current.id == nm_add_site.current.id
|
||||||
- nm_query_site.current.name == '{{ msc_site | default("ansible_test") }}_2'
|
- nm_query_site.current.name == '{{ mso_site | default("ansible_test") }}_2'
|
||||||
- cm_query_site == nm_query_site
|
- cm_query_site == nm_query_site
|
||||||
|
|
||||||
|
|
||||||
# REMOVE SITE
|
# REMOVE SITE
|
||||||
- name: Remove site (check_mode)
|
- name: Remove site (check_mode)
|
||||||
msc_site: *site_absent
|
mso_site: *site_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_site
|
register: cm_remove_site
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@
|
||||||
- cm_remove_site.current == {}
|
- cm_remove_site.current == {}
|
||||||
|
|
||||||
- name: Remove site (normal mode)
|
- name: Remove site (normal mode)
|
||||||
msc_site: *site_absent
|
mso_site: *site_absent
|
||||||
register: nm_remove_site
|
register: nm_remove_site
|
||||||
|
|
||||||
- name: Verify nm_remove_site
|
- name: Verify nm_remove_site
|
||||||
|
@ -239,7 +239,7 @@
|
||||||
- nm_remove_site.current == {}
|
- nm_remove_site.current == {}
|
||||||
|
|
||||||
- name: Remove site again (check_mode)
|
- name: Remove site again (check_mode)
|
||||||
msc_site: *site_absent
|
mso_site: *site_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_site_again
|
register: cm_remove_site_again
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@
|
||||||
- cm_remove_site_again.current == {}
|
- cm_remove_site_again.current == {}
|
||||||
|
|
||||||
- name: Remove site again (normal mode)
|
- name: Remove site again (normal mode)
|
||||||
msc_site: *site_absent
|
mso_site: *site_absent
|
||||||
register: nm_remove_site_again
|
register: nm_remove_site_again
|
||||||
|
|
||||||
- name: Verify nm_remove_site_again
|
- name: Verify nm_remove_site_again
|
||||||
|
@ -262,16 +262,16 @@
|
||||||
|
|
||||||
# QUERY NON-EXISTING SITE
|
# QUERY NON-EXISTING SITE
|
||||||
- name: Query non-existing site (check_mode)
|
- name: Query non-existing site (check_mode)
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_query
|
<<: *site_query
|
||||||
site: '{{ msc_site | default("ansible_test") }}'
|
site: '{{ mso_site | default("ansible_test") }}'
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_non_site
|
register: cm_query_non_site
|
||||||
|
|
||||||
- name: Query non-existing site (normal mode)
|
- name: Query non-existing site (normal mode)
|
||||||
msc_site:
|
mso_site:
|
||||||
<<: *site_query
|
<<: *site_query
|
||||||
site: '{{ msc_site | default("ansible_test") }}'
|
site: '{{ mso_site | default("ansible_test") }}'
|
||||||
register: nm_query_non_site
|
register: nm_query_non_site
|
||||||
|
|
||||||
# TODO: Implement more tests
|
# TODO: Implement more tests
|
|
@ -1,29 +1,29 @@
|
||||||
# Test code for the MSC modules
|
# Test code for the MSO modules
|
||||||
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
||||||
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Test that we have an ACI MultiSite host, username and password
|
- name: Test that we have an ACI MultiSite host, username and password
|
||||||
fail:
|
fail:
|
||||||
msg: 'Please define the following variables: msc_hostname, msc_username and msc_password.'
|
msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.'
|
||||||
when: msc_hostname is not defined or msc_username is not defined or msc_password is not defined
|
when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined
|
||||||
|
|
||||||
|
|
||||||
# CLEAN ENVIRONMENT
|
# CLEAN ENVIRONMENT
|
||||||
- name: Remove tenant ansible_test2
|
- name: Remove tenant ansible_test2
|
||||||
msc_tenant: &tenant_absent
|
mso_tenant: &tenant_absent
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
tenant: ansible_test2
|
tenant: ansible_test2
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Remove tenant ansible_test
|
- name: Remove tenant ansible_test
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_absent
|
<<: *tenant_absent
|
||||||
tenant: ansible_test
|
tenant: ansible_test
|
||||||
register: cm_remove_tenant
|
register: cm_remove_tenant
|
||||||
|
@ -31,14 +31,14 @@
|
||||||
|
|
||||||
# ADD TENANT
|
# ADD TENANT
|
||||||
- name: Add tenant (check_mode)
|
- name: Add tenant (check_mode)
|
||||||
msc_tenant: &tenant_present
|
mso_tenant: &tenant_present
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
tenant: ansible_test
|
tenant: ansible_test
|
||||||
display_name: Ansible test title
|
display_name: Ansible test title
|
||||||
description: Ansible test tenant
|
description: Ansible test tenant
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
- cm_add_tenant.current.description == 'Ansible test tenant'
|
- cm_add_tenant.current.description == 'Ansible test tenant'
|
||||||
|
|
||||||
- name: Add tenant (normal mode)
|
- name: Add tenant (normal mode)
|
||||||
msc_tenant: *tenant_present
|
mso_tenant: *tenant_present
|
||||||
register: nm_add_tenant
|
register: nm_add_tenant
|
||||||
|
|
||||||
- name: nm_Verify add_tenant
|
- name: nm_Verify add_tenant
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
- nm_add_tenant.current.description == 'Ansible test tenant'
|
- nm_add_tenant.current.description == 'Ansible test tenant'
|
||||||
|
|
||||||
- name: Add tenant again (check_mode)
|
- name: Add tenant again (check_mode)
|
||||||
msc_tenant: *tenant_present
|
mso_tenant: *tenant_present
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_add_tenant_again
|
register: cm_add_tenant_again
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
- cm_add_tenant_again.current.description == 'Ansible test tenant'
|
- cm_add_tenant_again.current.description == 'Ansible test tenant'
|
||||||
|
|
||||||
- name: Add tenant again (normal mode)
|
- name: Add tenant again (normal mode)
|
||||||
msc_tenant: *tenant_present
|
mso_tenant: *tenant_present
|
||||||
register: nm_add_tenant_again
|
register: nm_add_tenant_again
|
||||||
|
|
||||||
- name: Verify nm_add_tenant_again
|
- name: Verify nm_add_tenant_again
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
# CHANGE TENANT
|
# CHANGE TENANT
|
||||||
- name: Change tenant (check_mode)
|
- name: Change tenant (check_mode)
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_present
|
<<: *tenant_present
|
||||||
tenant_id: '{{ nm_add_tenant.current.id }}'
|
tenant_id: '{{ nm_add_tenant.current.id }}'
|
||||||
tenant: ansible_test2
|
tenant: ansible_test2
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
- cm_change_tenant.current.description == 'Ansible test tenant 2'
|
- cm_change_tenant.current.description == 'Ansible test tenant 2'
|
||||||
|
|
||||||
- name: Change tenant (normal mode)
|
- name: Change tenant (normal mode)
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_present
|
<<: *tenant_present
|
||||||
tenant_id: '{{ nm_add_tenant.current.id }}'
|
tenant_id: '{{ nm_add_tenant.current.id }}'
|
||||||
tenant: ansible_test2
|
tenant: ansible_test2
|
||||||
|
@ -134,7 +134,7 @@
|
||||||
- nm_change_tenant.current.description == 'Ansible test tenant 2'
|
- nm_change_tenant.current.description == 'Ansible test tenant 2'
|
||||||
|
|
||||||
- name: Change tenant again (check_mode)
|
- name: Change tenant again (check_mode)
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_present
|
<<: *tenant_present
|
||||||
tenant_id: '{{ nm_add_tenant.current.id }}'
|
tenant_id: '{{ nm_add_tenant.current.id }}'
|
||||||
tenant: ansible_test2
|
tenant: ansible_test2
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
- cm_change_tenant_again.current.description == 'Ansible test tenant 2'
|
- cm_change_tenant_again.current.description == 'Ansible test tenant 2'
|
||||||
|
|
||||||
- name: Change tenant again (normal mode)
|
- name: Change tenant again (normal mode)
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_present
|
<<: *tenant_present
|
||||||
tenant_id: '{{ nm_add_tenant.current.id }}'
|
tenant_id: '{{ nm_add_tenant.current.id }}'
|
||||||
tenant: ansible_test2
|
tenant: ansible_test2
|
||||||
|
@ -169,20 +169,20 @@
|
||||||
|
|
||||||
# QUERY ALL TENANTS
|
# QUERY ALL TENANTS
|
||||||
- name: Query all tenants (check_mode)
|
- name: Query all tenants (check_mode)
|
||||||
msc_tenant: &tenant_query
|
mso_tenant: &tenant_query
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
state: query
|
state: query
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_all_tenants
|
register: cm_query_all_tenants
|
||||||
|
|
||||||
- name: Query all tenants (normal mode)
|
- name: Query all tenants (normal mode)
|
||||||
msc_tenant: *tenant_query
|
mso_tenant: *tenant_query
|
||||||
register: nm_query_all_tenants
|
register: nm_query_all_tenants
|
||||||
|
|
||||||
- name: Verify query_all_tenants
|
- name: Verify query_all_tenants
|
||||||
|
@ -196,14 +196,14 @@
|
||||||
|
|
||||||
# QUERY A TENANT
|
# QUERY A TENANT
|
||||||
- name: Query our tenant
|
- name: Query our tenant
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_query
|
<<: *tenant_query
|
||||||
tenant: ansible_test2
|
tenant: ansible_test2
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_tenant
|
register: cm_query_tenant
|
||||||
|
|
||||||
- name: Query our tenant
|
- name: Query our tenant
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_query
|
<<: *tenant_query
|
||||||
tenant: ansible_test2
|
tenant: ansible_test2
|
||||||
register: nm_query_tenant
|
register: nm_query_tenant
|
||||||
|
@ -224,7 +224,7 @@
|
||||||
|
|
||||||
# REMOVE TENANT
|
# REMOVE TENANT
|
||||||
- name: Remove tenant (check_mode)
|
- name: Remove tenant (check_mode)
|
||||||
msc_tenant: *tenant_absent
|
mso_tenant: *tenant_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_tenant
|
register: cm_remove_tenant
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@
|
||||||
- cm_remove_tenant.current == {}
|
- cm_remove_tenant.current == {}
|
||||||
|
|
||||||
- name: Remove tenant (normal mode)
|
- name: Remove tenant (normal mode)
|
||||||
msc_tenant: *tenant_absent
|
mso_tenant: *tenant_absent
|
||||||
register: nm_remove_tenant
|
register: nm_remove_tenant
|
||||||
|
|
||||||
- name: Verify nm_remove_tenant
|
- name: Verify nm_remove_tenant
|
||||||
|
@ -245,7 +245,7 @@
|
||||||
- nm_remove_tenant.current == {}
|
- nm_remove_tenant.current == {}
|
||||||
|
|
||||||
- name: Remove tenant again (check_mode)
|
- name: Remove tenant again (check_mode)
|
||||||
msc_tenant: *tenant_absent
|
mso_tenant: *tenant_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_tenant_again
|
register: cm_remove_tenant_again
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@
|
||||||
- cm_remove_tenant_again.current == {}
|
- cm_remove_tenant_again.current == {}
|
||||||
|
|
||||||
- name: Remove tenant again (normal mode)
|
- name: Remove tenant again (normal mode)
|
||||||
msc_tenant: *tenant_absent
|
mso_tenant: *tenant_absent
|
||||||
register: nm_remove_tenant_again
|
register: nm_remove_tenant_again
|
||||||
|
|
||||||
- name: Verify nm_remove_tenant_again
|
- name: Verify nm_remove_tenant_again
|
||||||
|
@ -268,14 +268,14 @@
|
||||||
|
|
||||||
# QUERY NON-EXISTING TENANT
|
# QUERY NON-EXISTING TENANT
|
||||||
- name: Query non-existing tenant (check_mode)
|
- name: Query non-existing tenant (check_mode)
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_query
|
<<: *tenant_query
|
||||||
tenant: ansible_test
|
tenant: ansible_test
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_non_tenant
|
register: cm_query_non_tenant
|
||||||
|
|
||||||
- name: Query non-existing tenant (normal mode)
|
- name: Query non-existing tenant (normal mode)
|
||||||
msc_tenant:
|
mso_tenant:
|
||||||
<<: *tenant_query
|
<<: *tenant_query
|
||||||
tenant: ansible_test
|
tenant: ansible_test
|
||||||
register: nm_query_non_tenant
|
register: nm_query_non_tenant
|
|
@ -1,29 +1,29 @@
|
||||||
# Test code for the MSC modules
|
# Test code for the MSO modules
|
||||||
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
||||||
|
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
- name: Test that we have an ACI MultiSite host, username and password
|
- name: Test that we have an ACI MultiSite host, username and password
|
||||||
fail:
|
fail:
|
||||||
msg: 'Please define the following variables: msc_hostname, msc_username and msc_password.'
|
msg: 'Please define the following variables: mso_hostname, mso_username and mso_password.'
|
||||||
when: msc_hostname is not defined or msc_username is not defined or msc_password is not defined
|
when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined
|
||||||
|
|
||||||
|
|
||||||
# CLEAN ENVIRONMENT
|
# CLEAN ENVIRONMENT
|
||||||
- name: Remove user ansible_test2
|
- name: Remove user ansible_test2
|
||||||
msc_user: &user_absent
|
mso_user: &user_absent
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
user_name: ansible_test2
|
user_name: ansible_test2
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Remove user ansible_test
|
- name: Remove user ansible_test
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_absent
|
<<: *user_absent
|
||||||
user_name: ansible_test
|
user_name: ansible_test
|
||||||
register: cm_remove_user
|
register: cm_remove_user
|
||||||
|
@ -31,14 +31,14 @@
|
||||||
|
|
||||||
# ADD USER
|
# ADD USER
|
||||||
- name: Add user (check_mode)
|
- name: Add user (check_mode)
|
||||||
msc_user: &user_present
|
mso_user: &user_present
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
user_name: ansible_test
|
user_name: ansible_test
|
||||||
user_password: 'S0m3!1n1t14l!p455w0rd'
|
user_password: 'S0m3!1n1t14l!p455w0rd'
|
||||||
# NOTE: First name, last name, phone and email are mandatory on creation
|
# NOTE: First name, last name, phone and email are mandatory on creation
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
- cm_add_user.current.username == 'ansible_test'
|
- cm_add_user.current.username == 'ansible_test'
|
||||||
|
|
||||||
- name: Add user (normal mode)
|
- name: Add user (normal mode)
|
||||||
msc_user: *user_present
|
mso_user: *user_present
|
||||||
register: nm_add_user
|
register: nm_add_user
|
||||||
|
|
||||||
- name: nm_Verify add_user
|
- name: nm_Verify add_user
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
- nm_add_user.current.username == 'ansible_test'
|
- nm_add_user.current.username == 'ansible_test'
|
||||||
|
|
||||||
- name: Add user again (check_mode)
|
- name: Add user again (check_mode)
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_present
|
<<: *user_present
|
||||||
# NOTE: We need to modify the password for a new user
|
# NOTE: We need to modify the password for a new user
|
||||||
user_password: 'S0m3!n3w!p455w0rd'
|
user_password: 'S0m3!n3w!p455w0rd'
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
- cm_add_user_again.current.username == 'ansible_test'
|
- cm_add_user_again.current.username == 'ansible_test'
|
||||||
|
|
||||||
- name: Add user again (normal mode)
|
- name: Add user again (normal mode)
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_present
|
<<: *user_present
|
||||||
# NOTE: We need to modify the password for a new user
|
# NOTE: We need to modify the password for a new user
|
||||||
user_password: 'S0m3!n3w!p455w0rd'
|
user_password: 'S0m3!n3w!p455w0rd'
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
|
|
||||||
# CHANGE USER
|
# CHANGE USER
|
||||||
- name: Change user (check_mode)
|
- name: Change user (check_mode)
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_present
|
<<: *user_present
|
||||||
user_id: '{{ nm_add_user.current.id }}'
|
user_id: '{{ nm_add_user.current.id }}'
|
||||||
user_name: ansible_test2
|
user_name: ansible_test2
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
- cm_change_user.current.username == 'ansible_test2'
|
- cm_change_user.current.username == 'ansible_test2'
|
||||||
|
|
||||||
- name: Change user (normal mode)
|
- name: Change user (normal mode)
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_present
|
<<: *user_present
|
||||||
user_id: '{{ nm_add_user.current.id }}'
|
user_id: '{{ nm_add_user.current.id }}'
|
||||||
user_name: ansible_test2
|
user_name: ansible_test2
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
- nm_change_user.current.username == 'ansible_test2'
|
- nm_change_user.current.username == 'ansible_test2'
|
||||||
|
|
||||||
- name: Change user again (check_mode)
|
- name: Change user again (check_mode)
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_present
|
<<: *user_present
|
||||||
user_id: '{{ nm_add_user.current.id }}'
|
user_id: '{{ nm_add_user.current.id }}'
|
||||||
user_name: ansible_test2
|
user_name: ansible_test2
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
- cm_change_user_again.current.username == 'ansible_test2'
|
- cm_change_user_again.current.username == 'ansible_test2'
|
||||||
|
|
||||||
- name: Change user again (normal mode)
|
- name: Change user again (normal mode)
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_present
|
<<: *user_present
|
||||||
user_id: '{{ nm_add_user.current.id }}'
|
user_id: '{{ nm_add_user.current.id }}'
|
||||||
user_name: ansible_test2
|
user_name: ansible_test2
|
||||||
|
@ -174,20 +174,20 @@
|
||||||
|
|
||||||
# QUERY ALL USERS
|
# QUERY ALL USERS
|
||||||
- name: Query all users (check_mode)
|
- name: Query all users (check_mode)
|
||||||
msc_user: &user_query
|
mso_user: &user_query
|
||||||
host: '{{ msc_hostname }}'
|
host: '{{ mso_hostname }}'
|
||||||
username: '{{ msc_username }}'
|
username: '{{ mso_username }}'
|
||||||
password: '{{ msc_password }}'
|
password: '{{ mso_password }}'
|
||||||
validate_certs: '{{ msc_validate_certs | default(false) }}'
|
validate_certs: '{{ mso_validate_certs | default(false) }}'
|
||||||
use_ssl: '{{ msc_use_ssl | default(true) }}'
|
use_ssl: '{{ mso_use_ssl | default(true) }}'
|
||||||
use_proxy: '{{ msc_use_proxy | default(true) }}'
|
use_proxy: '{{ mso_use_proxy | default(true) }}'
|
||||||
output_level: '{{ msc_output_level | default("info") }}'
|
output_level: '{{ mso_output_level | default("info") }}'
|
||||||
state: query
|
state: query
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_all_users
|
register: cm_query_all_users
|
||||||
|
|
||||||
- name: Query all users (normal mode)
|
- name: Query all users (normal mode)
|
||||||
msc_user: *user_query
|
mso_user: *user_query
|
||||||
register: nm_query_all_users
|
register: nm_query_all_users
|
||||||
|
|
||||||
- name: Verify query_all_users
|
- name: Verify query_all_users
|
||||||
|
@ -201,14 +201,14 @@
|
||||||
|
|
||||||
# QUERY A USER
|
# QUERY A USER
|
||||||
- name: Query our user
|
- name: Query our user
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_query
|
<<: *user_query
|
||||||
user_name: ansible_test2
|
user_name: ansible_test2
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_user
|
register: cm_query_user
|
||||||
|
|
||||||
- name: Query our user
|
- name: Query our user
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_query
|
<<: *user_query
|
||||||
user_name: ansible_test2
|
user_name: ansible_test2
|
||||||
register: nm_query_user
|
register: nm_query_user
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
|
|
||||||
# REMOVE USER
|
# REMOVE USER
|
||||||
- name: Remove user (check_mode)
|
- name: Remove user (check_mode)
|
||||||
msc_user: *user_absent
|
mso_user: *user_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_user
|
register: cm_remove_user
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@
|
||||||
- cm_remove_user.current == {}
|
- cm_remove_user.current == {}
|
||||||
|
|
||||||
- name: Remove user (normal mode)
|
- name: Remove user (normal mode)
|
||||||
msc_user: *user_absent
|
mso_user: *user_absent
|
||||||
register: nm_remove_user
|
register: nm_remove_user
|
||||||
|
|
||||||
- name: Verify nm_remove_user
|
- name: Verify nm_remove_user
|
||||||
|
@ -248,7 +248,7 @@
|
||||||
- nm_remove_user.current == {}
|
- nm_remove_user.current == {}
|
||||||
|
|
||||||
- name: Remove user again (check_mode)
|
- name: Remove user again (check_mode)
|
||||||
msc_user: *user_absent
|
mso_user: *user_absent
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_remove_user_again
|
register: cm_remove_user_again
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@
|
||||||
- cm_remove_user_again.current == {}
|
- cm_remove_user_again.current == {}
|
||||||
|
|
||||||
- name: Remove user again (normal mode)
|
- name: Remove user again (normal mode)
|
||||||
msc_user: *user_absent
|
mso_user: *user_absent
|
||||||
register: nm_remove_user_again
|
register: nm_remove_user_again
|
||||||
|
|
||||||
- name: Verify nm_remove_user_again
|
- name: Verify nm_remove_user_again
|
||||||
|
@ -271,14 +271,14 @@
|
||||||
|
|
||||||
# QUERY NON-EXISTING USER
|
# QUERY NON-EXISTING USER
|
||||||
- name: Query non-existing user (check_mode)
|
- name: Query non-existing user (check_mode)
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_query
|
<<: *user_query
|
||||||
user_name: ansible_test
|
user_name: ansible_test
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
register: cm_query_non_user
|
register: cm_query_non_user
|
||||||
|
|
||||||
- name: Query non-existing user (normal mode)
|
- name: Query non-existing user (normal mode)
|
||||||
msc_user:
|
mso_user:
|
||||||
<<: *user_query
|
<<: *user_query
|
||||||
user_name: ansible_test
|
user_name: ansible_test
|
||||||
register: nm_query_non_user
|
register: nm_query_non_user
|
Loading…
Reference in a new issue