mirror of https://github.com/ansible/ansible.git
Allow module to claim devices into an organization (#42448)
- Before this, it allowed claiming devices into a network only - Make integration tests a block - Note, API doesn't allow unclaiming in an organization, only net - Added an integration test for claiming into an org - Requires unclaiming manually - There is a bug in the API which isn't showing claimed devicespull/42439/merge
parent
5960b215bb
commit
779f3c0c1a
@ -1,202 +1,213 @@
|
|||||||
---
|
---
|
||||||
- name: Claim a device
|
- block:
|
||||||
meraki_device:
|
- name: Claim a device into an organization
|
||||||
auth_key: '{{auth_key}}'
|
meraki_device:
|
||||||
org_name: '{{test_org_name}}'
|
auth_key: '{{auth_key}}'
|
||||||
net_name: '{{test_net_name}}'
|
org_name: '{{test_org_name}}'
|
||||||
serial: '{{serial}}'
|
serial: '{{serial}}'
|
||||||
state: present
|
state: present
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: claim_device
|
register: claim_device_org
|
||||||
|
|
||||||
- debug:
|
- assert:
|
||||||
msg: '{{claim_device}}'
|
that:
|
||||||
|
- claim_device_org.changed == true
|
||||||
- assert:
|
|
||||||
that:
|
- name: Query status of all devices in an organization
|
||||||
- claim_device.changed == true
|
meraki_device:
|
||||||
|
auth_key: '{{auth_key}}'
|
||||||
- name: Query all devices
|
org_name: '{{test_org_name}}'
|
||||||
meraki_device:
|
state: query
|
||||||
auth_key: '{{auth_key}}'
|
delegate_to: localhost
|
||||||
org_name: '{{test_org_name}}'
|
register: query_device_org
|
||||||
state: query
|
|
||||||
delegate_to: localhost
|
- debug:
|
||||||
register: query_all
|
msg: '{{query_device_org}}'
|
||||||
|
|
||||||
- debug:
|
- name: Claim a device into a network
|
||||||
msg: '{{query_all}}'
|
meraki_device:
|
||||||
|
auth_key: '{{auth_key}}'
|
||||||
- assert:
|
org_name: '{{test_org_name}}'
|
||||||
that:
|
net_name: '{{test_net_name}}'
|
||||||
- query_all.changed == False
|
serial: '{{serial}}'
|
||||||
|
state: present
|
||||||
- name: Query all devices in one network by network ID
|
delegate_to: localhost
|
||||||
meraki_device:
|
register: claim_device
|
||||||
auth_key: '{{auth_key}}'
|
|
||||||
org_name: '{{test_org_name}}'
|
- debug:
|
||||||
net_id: '{{test_net_id}}'
|
msg: '{{claim_device}}'
|
||||||
state: query
|
|
||||||
delegate_to: localhost
|
- assert:
|
||||||
register: query_one_net_id
|
that:
|
||||||
|
- claim_device.changed == true
|
||||||
- debug:
|
|
||||||
msg: '{{query_one_net_id}}'
|
- name: Query all devices in one network by network ID
|
||||||
|
meraki_device:
|
||||||
- name: Query all devices in one network
|
auth_key: '{{auth_key}}'
|
||||||
meraki_device:
|
org_name: '{{test_org_name}}'
|
||||||
auth_key: '{{auth_key}}'
|
net_id: '{{test_net_id}}'
|
||||||
org_name: '{{test_org_name}}'
|
state: query
|
||||||
net_name: '{{test_net_name}}'
|
delegate_to: localhost
|
||||||
state: query
|
register: query_one_net_id
|
||||||
delegate_to: localhost
|
|
||||||
register: query_one_net
|
- debug:
|
||||||
|
msg: '{{query_one_net_id}}'
|
||||||
- debug:
|
|
||||||
msg: '{{query_one_net}}'
|
- name: Query all devices in one network
|
||||||
|
meraki_device:
|
||||||
- name: Query device by serial
|
auth_key: '{{auth_key}}'
|
||||||
meraki_device:
|
org_name: '{{test_org_name}}'
|
||||||
auth_key: '{{auth_key}}'
|
net_name: '{{test_net_name}}'
|
||||||
org_name: '{{test_org_name}}'
|
state: query
|
||||||
serial: '{{serial}}'
|
delegate_to: localhost
|
||||||
state: query
|
register: query_one_net
|
||||||
delegate_to: localhost
|
|
||||||
register: query_serial_no_net
|
- debug:
|
||||||
|
msg: '{{query_one_net}}'
|
||||||
- debug:
|
|
||||||
msg: '{{query_serial_no_net}}'
|
- name: Query device by serial
|
||||||
|
meraki_device:
|
||||||
- name: Query device by serial
|
auth_key: '{{auth_key}}'
|
||||||
meraki_device:
|
org_name: '{{test_org_name}}'
|
||||||
auth_key: '{{auth_key}}'
|
serial: '{{serial}}'
|
||||||
org_name: '{{test_org_name}}'
|
state: query
|
||||||
net_name: '{{test_net_name}}'
|
delegate_to: localhost
|
||||||
serial: '{{serial}}'
|
register: query_serial_no_net
|
||||||
state: query
|
|
||||||
delegate_to: localhost
|
- debug:
|
||||||
register: query_serial
|
msg: '{{query_serial_no_net}}'
|
||||||
|
|
||||||
- debug:
|
- name: Query device by serial
|
||||||
msg: '{{query_serial}}'
|
meraki_device:
|
||||||
|
auth_key: '{{auth_key}}'
|
||||||
- assert:
|
org_name: '{{test_org_name}}'
|
||||||
that:
|
net_name: '{{test_net_name}}'
|
||||||
- query_serial.changed == False
|
serial: '{{serial}}'
|
||||||
|
state: query
|
||||||
- name: Query uplink information for a device
|
delegate_to: localhost
|
||||||
meraki_device:
|
register: query_serial
|
||||||
auth_key: '{{auth_key}}'
|
|
||||||
org_name: '{{test_org_name}}'
|
- debug:
|
||||||
net_name: '{{test_net_name}}'
|
msg: '{{query_serial}}'
|
||||||
serial_uplink: '{{serial}}'
|
|
||||||
state: query
|
- assert:
|
||||||
delegate_to: localhost
|
that:
|
||||||
register: query_serial_uplink
|
- query_serial.changed == False
|
||||||
|
|
||||||
- debug:
|
- name: Query uplink information for a device
|
||||||
msg: '{{query_serial_uplink}}'
|
meraki_device:
|
||||||
|
auth_key: '{{auth_key}}'
|
||||||
- name: Query LLDP/CDP information about a device
|
org_name: '{{test_org_name}}'
|
||||||
meraki_device:
|
net_name: '{{test_net_name}}'
|
||||||
auth_key: '{{auth_key}}'
|
serial_uplink: '{{serial}}'
|
||||||
org_name: '{{test_org_name}}'
|
state: query
|
||||||
net_name: '{{test_net_name}}'
|
delegate_to: localhost
|
||||||
serial_lldp_cdp: '{{serial}}'
|
register: query_serial_uplink
|
||||||
lldp_cdp_timespan: 6000
|
|
||||||
state: query
|
- debug:
|
||||||
delegate_to: localhost
|
msg: '{{query_serial_uplink}}'
|
||||||
register: query_serial_lldp_cdp
|
|
||||||
|
- name: Query LLDP/CDP information about a device
|
||||||
- debug:
|
meraki_device:
|
||||||
msg: '{{query_serial_lldp_cdp}}'
|
auth_key: '{{auth_key}}'
|
||||||
|
org_name: '{{test_org_name}}'
|
||||||
- name: Query a device by hostname
|
net_name: '{{test_net_name}}'
|
||||||
meraki_device:
|
serial_lldp_cdp: '{{serial}}'
|
||||||
auth_key: '{{auth_key}}'
|
lldp_cdp_timespan: 6000
|
||||||
org_name: '{{test_org_name}}'
|
state: query
|
||||||
net_name: '{{test_net_name}}'
|
delegate_to: localhost
|
||||||
hostname: test-hostname
|
register: query_serial_lldp_cdp
|
||||||
state: query
|
|
||||||
delegate_to: localhost
|
- debug:
|
||||||
register: query_hostname
|
msg: '{{query_serial_lldp_cdp}}'
|
||||||
|
|
||||||
- debug:
|
- name: Query a device by hostname
|
||||||
msg: '{{query_hostname}}'
|
meraki_device:
|
||||||
|
auth_key: '{{auth_key}}'
|
||||||
- name: Query a device by model
|
org_name: '{{test_org_name}}'
|
||||||
meraki_device:
|
net_name: '{{test_net_name}}'
|
||||||
auth_key: '{{auth_key}}'
|
hostname: test-hostname
|
||||||
org_name: '{{test_org_name}}'
|
state: query
|
||||||
net_name: '{{test_net_name}}'
|
delegate_to: localhost
|
||||||
model: MR26
|
register: query_hostname
|
||||||
state: query
|
|
||||||
delegate_to: localhost
|
- debug:
|
||||||
register: query_model
|
msg: '{{query_hostname}}'
|
||||||
|
|
||||||
- debug:
|
- name: Query a device by model
|
||||||
msg: '{{query_model}}'
|
meraki_device:
|
||||||
|
auth_key: '{{auth_key}}'
|
||||||
- name: Update a device
|
org_name: '{{test_org_name}}'
|
||||||
meraki_device:
|
net_name: '{{test_net_name}}'
|
||||||
auth_key: '{{auth_key}}'
|
model: MR26
|
||||||
org_name: '{{test_org_name}}'
|
state: query
|
||||||
net_name: '{{test_net_name}}'
|
delegate_to: localhost
|
||||||
serial: '{{serial}}'
|
register: query_model
|
||||||
name: mr26
|
|
||||||
address: 1060 W. Addison St., Chicago, IL
|
- debug:
|
||||||
lat: 41.948038
|
msg: '{{query_model}}'
|
||||||
lng: -87.65568
|
|
||||||
tags: recently-added
|
- name: Update a device
|
||||||
state: present
|
meraki_device:
|
||||||
move_map_marker: True
|
auth_key: '{{auth_key}}'
|
||||||
delegate_to: localhost
|
org_name: '{{test_org_name}}'
|
||||||
register: update_device
|
net_name: '{{test_net_name}}'
|
||||||
|
serial: '{{serial}}'
|
||||||
- debug:
|
name: mr26
|
||||||
msg: '{{update_device}}'
|
address: 1060 W. Addison St., Chicago, IL
|
||||||
|
lat: 41.948038
|
||||||
# - assert:
|
lng: -87.65568
|
||||||
# that:
|
tags: recently-added
|
||||||
# - update_device.changed == true
|
state: present
|
||||||
# - '"1060 W. Addison St., Chicago, IL" in update_device.data.0.address'
|
move_map_marker: True
|
||||||
|
delegate_to: localhost
|
||||||
- name: Update a device with idempotency
|
register: update_device
|
||||||
meraki_device:
|
|
||||||
auth_key: '{{auth_key}}'
|
- debug:
|
||||||
org_name: '{{test_org_name}}'
|
msg: '{{update_device}}'
|
||||||
net_name: '{{test_net_name}}'
|
|
||||||
serial: '{{serial}}'
|
# - assert:
|
||||||
name: mr26
|
# that:
|
||||||
address: 1060 W. Addison St., Chicago, IL
|
# - update_device.changed == true
|
||||||
lat: 41.948038
|
# - '"1060 W. Addison St., Chicago, IL" in update_device.data.0.address'
|
||||||
lng: -87.65568
|
|
||||||
tags: recently-added
|
- name: Update a device with idempotency
|
||||||
state: present
|
meraki_device:
|
||||||
move_map_marker: True
|
auth_key: '{{auth_key}}'
|
||||||
delegate_to: localhost
|
org_name: '{{test_org_name}}'
|
||||||
register: update_device_idempotent
|
net_name: '{{test_net_name}}'
|
||||||
|
serial: '{{serial}}'
|
||||||
- debug:
|
name: mr26
|
||||||
msg: '{{update_device_idempotent}}'
|
address: 1060 W. Addison St., Chicago, IL
|
||||||
|
lat: 41.948038
|
||||||
- assert:
|
lng: -87.65568
|
||||||
that:
|
tags: recently-added
|
||||||
- update_device_idempotent.changed == False
|
state: present
|
||||||
|
move_map_marker: True
|
||||||
- name: Remove a device
|
delegate_to: localhost
|
||||||
meraki_device:
|
register: update_device_idempotent
|
||||||
auth_key: '{{auth_key}}'
|
|
||||||
org_name: '{{test_org_name}}'
|
- debug:
|
||||||
net_name: '{{test_net_name}}'
|
msg: '{{update_device_idempotent}}'
|
||||||
serial: '{{serial}}'
|
|
||||||
state: absent
|
- assert:
|
||||||
delegate_to: localhost
|
that:
|
||||||
register: delete_device
|
- update_device_idempotent.changed == False
|
||||||
|
|
||||||
- debug:
|
always:
|
||||||
msg: '{{delete_device}}'
|
- name: Remove a device
|
||||||
|
meraki_device:
|
||||||
- assert:
|
auth_key: '{{auth_key}}'
|
||||||
that:
|
org_name: '{{test_org_name}}'
|
||||||
- delete_device.changed == true
|
net_name: '{{test_net_name}}'
|
||||||
|
serial: '{{serial}}'
|
||||||
|
state: absent
|
||||||
|
delegate_to: localhost
|
||||||
|
register: delete_device
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
msg: '{{delete_device}}'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- delete_device.changed == true
|
Loading…
Reference in New Issue