Coverage for plugins/modules/meraki_admin.py : 94%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/python # -*- coding: utf-8 -*-
# Copyright: (c) 2018, Kevin Breit (@kbreit) <kevin.breit@kevinbreit.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community' }
--- module: meraki_admin short_description: Manage administrators in the Meraki cloud version_added: '2.6' description: - Allows for creation, management, and visibility into administrators within Meraki. options: name: description: - Name of the dashboard administrator. - Required when creating a new administrator. type: str email: description: - Email address for the dashboard administrator. - Email cannot be updated. - Required when creating or editing an administrator. type: str org_access: description: - Privileges assigned to the administrator in the organization. aliases: [ orgAccess ] choices: [ full, none, read-only ] type: str tags: description: - Tags the administrator has privileges on. - When creating a new administrator, C(org_name), C(network), or C(tags) must be specified. - If C(none) is specified, C(network) or C(tags) must be specified. type: list suboptions: tag: description: - Object tag which privileges should be assigned. type: str access: description: - The privilege of the dashboard administrator for the tag. type: str networks: description: - List of networks the administrator has privileges on. - When creating a new administrator, C(org_name), C(network), or C(tags) must be specified. type: list suboptions: id: description: - Network ID for which administrator should have privileges assigned. type: str access: description: - The privilege of the dashboard administrator on the network. - Valid options are C(full), C(read-only), or C(none). type: str state: description: - Create or modify, or delete an organization - If C(state) is C(absent), name takes priority over email if both are specified. choices: [ absent, present, query ] required: true type: str org_name: description: - Name of organization. - Used when C(name) should refer to another object. - When creating a new administrator, C(org_name), C(network), or C(tags) must be specified. aliases: ['organization'] type: str author: - Kevin Breit (@kbreit) extends_documentation_fragment: meraki '''
- name: Query information about all administrators associated to the organization meraki_admin: auth_key: abc12345 org_name: YourOrg state: query delegate_to: localhost
- name: Query information about a single administrator by name meraki_admin: auth_key: abc12345 org_id: 12345 state: query name: Jane Doe
- name: Query information about a single administrator by email meraki_admin: auth_key: abc12345 org_name: YourOrg state: query email: jane@doe.com
- name: Create new administrator with organization access meraki_admin: auth_key: abc12345 org_name: YourOrg state: present name: Jane Doe org_access: read-only email: jane@doe.com
- name: Create new administrator with organization access meraki_admin: auth_key: abc12345 org_name: YourOrg state: present name: Jane Doe org_access: read-only email: jane@doe.com
- name: Create a new administrator with organization access meraki_admin: auth_key: abc12345 org_name: YourOrg state: present name: Jane Doe org_access: read-only email: jane@doe.com
- name: Revoke access to an organization for an administrator meraki_admin: auth_key: abc12345 org_name: YourOrg state: absent email: jane@doe.com
- name: Create a new administrator with full access to two tags meraki_admin: auth_key: abc12345 org_name: YourOrg state: present name: Jane Doe orgAccess: read-only email: jane@doe.com tags: - tag: tenant access: full - tag: corporate access: read-only
- name: Create a new administrator with full access to a network meraki_admin: auth_key: abc12345 org_name: YourOrg state: present name: Jane Doe orgAccess: read-only email: jane@doe.com networks: - id: N_12345 access: full '''
data: description: List of administrators. returned: success type: complex contains: email: description: Email address of administrator. returned: success type: str sample: your@email.com id: description: Unique identification number of administrator. returned: success type: str sample: 1234567890 name: description: Given name of administrator. returned: success type: str sample: John Doe account_status: description: Status of account. returned: success type: str sample: ok two_factor_auth_enabled: description: Enabled state of two-factor authentication for administrator. returned: success type: bool sample: false has_api_key: description: Defines whether administrator has an API assigned to their account. returned: success type: bool sample: false last_active: description: Date and time of time the administrator was active within Dashboard. returned: success type: str sample: 2019-01-28 14:58:56 -0800 networks: description: List of networks administrator has access on. returned: success type: complex contains: id: description: The network ID. returned: when network permissions are set type: str sample: N_0123456789 access: description: Access level of administrator. Options are 'full', 'read-only', or 'none'. returned: when network permissions are set type: str sample: read-only tags: description: Tags the administrator has access on. returned: success type: complex contains: tag: description: Tag name. returned: when tag permissions are set type: str sample: production access: description: Access level of administrator. Options are 'full', 'read-only', or 'none'. returned: when tag permissions are set type: str sample: full org_access: description: The privilege of the dashboard administrator on the organization. Options are 'full', 'read-only', or 'none'. returned: success type: str sample: full
'''
meraki.construct_path( 'query', function='admin', org_id=org_id ), method='GET' )
else:
method='DELETE' )
net_name=n['network'], data=nets), 'access': n['access'] })
method='POST', payload=json.dumps(payload) ) method='PUT', payload=json.dumps(payload) ) else:
# define the available arguments/parameters that a user can pass to # the module
access=dict(type='str'), )
access=dict(type='str'), )
name=dict(type='str'), email=dict(type='str'), org_access=dict(type='str', aliases=['orgAccess'], choices=['full', 'read-only', 'none']), tags=dict(type='list', element='dict', options=tag_arg_spec), networks=dict(type='list', element='dict', options=network_arg_spec), org_name=dict(type='str', aliases=['organization']), org_id=dict(type='str'), )
# the AnsibleModule object will be our abstraction working with Ansible # this includes instantiation, a couple of common attr would be the # args/params passed to the execution, as well as if the module # supports check mode supports_check_mode=True, )
} } } }
# if the user is working with this module in only check mode we do not # want to make any changes to the environment, just return the current # state with no modifications
# execute checks for argument completeness ]
# manipulate or modify the state as needed (this is going to be the # part where your module will do what it needs to do) org_id, meraki.params['name'], meraki.params['email'], ) get_admins(meraki, org_id), email=meraki.params['email'] )
# in the event of a successful module execution, you will want to # simple AnsibleModule.exit_json(), passing the key/value results
|