ansible/test/integration/targets/meraki_organization/tasks/main.yml
Kevin Breit c87e26449a Backport/2.6/40856 (#41278)
* Changed request() to run json.loads() instead of module doing it
- Removed json.loads() from modules
- Removed some unreliable integration tests
- Removed self.function setting in construct_path()
-

(cherry picked from commit 0ba1e52bdd7d0d622ac7506172f743e01bc3f461)

* PEP8 changes

(cherry picked from commit 182979ffc493e7c3574f2cf67b4378a4d8603160)

* Remove debug line for push

(cherry picked from commit 5350dcf52cae7699601307d39e13d121d9bae317)
2018-06-07 16:15:10 -07:00

125 lines
No EOL
3 KiB
YAML

# Test code for the Meraki Organization module
# Copyright: (c) 2018, Kevin Breit (@kbreit)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: Test an API key is provided
fail:
msg: Please define an API key
when: auth_key is not defined
- name: Use an invalid domain
meraki_organization:
auth_key: '{{ auth_key }}'
host: marrrraki.com
state: present
org_name: IntTestOrg
output_level: debug
delegate_to: localhost
register: invalid_domain
ignore_errors: yes
- name: Disable HTTP
meraki_organization:
auth_key: '{{ auth_key }}'
use_https: false
state: query
output_level: debug
delegate_to: localhost
register: http
ignore_errors: yes
- name: Connection assertions
assert:
that:
- '"Failed to connect to" in invalid_domain.msg'
- '"http" in http.url'
- name: Create a new organization named IntTestOrg
meraki_organization:
auth_key: '{{ auth_key }}'
org_name: IntTestOrg
state: present
output_level: debug
delegate_to: localhost
register: new_org
- debug:
msg: '{{new_org}}'
- name: Clone IntTestOrg
meraki_organization:
auth_key: '{{ auth_key }}'
clone: IntTestOrg
org_name: IntTestOrgCloned
state: present
delegate_to: localhost
register: cloned_org
- debug:
msg: '{{cloned_org}}'
- name: Rename IntTestOrg
meraki_organization:
auth_key: '{{ auth_key }}'
org_name: IntTestOrgRenamed
org_id: '{{ new_org.data.id }}'
state: present
delegate_to: localhost
register: modify_org
- debug:
msg: '{{ modify_org }}'
- name: Rename IntTestOrg idempotent
meraki_organization:
auth_key: '{{ auth_key }}'
org_name: IntTestOrgRenamed
org_id: '{{ new_org.data.id }}'
state: present
delegate_to: localhost
register: modify_org_idempotent
- name: Present assertions
assert:
that:
- '"https" in new_org.url'
- new_org.changed == True
- new_org.data.id is defined
- cloned_org.changed == True
- cloned_org.data.id is defined
- modify_org.changed == True
- 'modify_org.data.name == "IntTestOrgRenamed"'
- modify_org_idempotent.changed == False
- name: List all organizations
meraki_organization:
auth_key: '{{ auth_key }}'
state: query
delegate_to: localhost
register: query_all
- name: Query information about a single organization named IntTestOrg
meraki_organization:
auth_key: '{{ auth_key }}'
org_name: IntTestOrgRenamed
state: query
delegate_to: localhost
register: query_org
- name: Query information about IntTestOrg by organization ID
meraki_organization:
auth_key: '{{ auth_key }}'
org_id: '{{ query_org.data.id }}'
state: query
delegate_to: localhost
register: query_org_id
- name: Query assertions
assert:
that:
- query_org.data.id is defined
- query_all.changed == False
- query_all.data | length >= 1
- 'query_org.data.name == "IntTestOrgRenamed"'
- 'query_org_id.data.id == query_org.data.id'