2018-05-26 02:22:38 +02:00
|
|
|
# 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: Query all SNMP settings
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: query
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_query
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: '{{snmp_query}}'
|
|
|
|
|
2019-06-19 17:35:10 +02:00
|
|
|
- name: Enable SNMPv2c with check mode
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
v2c_enabled: true
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_v2_enable_check
|
|
|
|
check_mode: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- snmp_v2_enable_check is not changed
|
|
|
|
|
2018-05-26 02:22:38 +02:00
|
|
|
- name: Enable SNMPv2c
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
v2c_enabled: true
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_v2_enable
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: '{{snmp_v2_enable}}'
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-13 21:07:30 +02:00
|
|
|
- snmp_v2_enable.data.v2_community_string is defined
|
|
|
|
- snmp_v2_enable.data.v2c_enabled == true
|
2018-05-26 02:22:38 +02:00
|
|
|
|
|
|
|
- name: Disable SNMPv2c
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
v2c_enabled: False
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_v2_disable
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-13 21:07:30 +02:00
|
|
|
- snmp_v2_disable.data.v2_community_string is not defined
|
|
|
|
- snmp_v2_disable.data.v2c_enabled == False
|
2018-05-26 02:22:38 +02:00
|
|
|
|
2018-06-20 09:40:10 +02:00
|
|
|
- name: Enable SNMPv2c with org_id
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_id: '{{test_org_id}}'
|
|
|
|
state: present
|
|
|
|
v2c_enabled: true
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_v2_enable_id
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: '{{snmp_v2_enable_id}}'
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-13 21:07:30 +02:00
|
|
|
- snmp_v2_enable_id.data.v2_community_string is defined
|
|
|
|
- snmp_v2_enable_id.data.v2c_enabled == true
|
2018-06-20 09:40:10 +02:00
|
|
|
|
|
|
|
- name: Disable SNMPv2c with org_id
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_id: '{{test_org_id}}'
|
|
|
|
state: present
|
|
|
|
v2c_enabled: False
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_v2_disable_id
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-13 21:07:30 +02:00
|
|
|
- snmp_v2_disable_id.data.v2_community_string is not defined
|
|
|
|
- snmp_v2_disable_id.data.v2c_enabled == False
|
2018-06-20 09:40:10 +02:00
|
|
|
|
2018-05-26 02:22:38 +02:00
|
|
|
- name: Enable SNMPv3
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
v3_enabled: true
|
|
|
|
v3_auth_mode: SHA
|
|
|
|
v3_auth_pass: ansiblepass
|
|
|
|
v3_priv_mode: AES128
|
|
|
|
v3_priv_pass: ansiblepass
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_v3_enable
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-13 21:07:30 +02:00
|
|
|
- snmp_v3_enable.data.v3_enabled == True
|
2018-05-26 02:22:38 +02:00
|
|
|
- snmp_v3_enable.changed == True
|
|
|
|
|
|
|
|
- name: Check for idempotency
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
v3_enabled: true
|
|
|
|
v3_auth_mode: SHA
|
|
|
|
v3_auth_pass: ansiblepass
|
|
|
|
v3_priv_mode: AES128
|
|
|
|
v3_priv_pass: ansiblepass
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_idempotent
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: '{{snmp_idempotent}}'
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- snmp_idempotent.changed == False
|
2019-05-17 05:04:16 +02:00
|
|
|
- snmp_idempotent.data is defined
|
2018-05-26 02:22:38 +02:00
|
|
|
|
2019-06-19 17:35:10 +02:00
|
|
|
- name: Check for idempotency with check mode
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
v3_enabled: true
|
|
|
|
v3_auth_mode: SHA
|
|
|
|
v3_auth_pass: ansiblepass
|
|
|
|
v3_priv_mode: AES128
|
|
|
|
v3_priv_pass: ansiblepass
|
|
|
|
delegate_to: localhost
|
|
|
|
register: snmp_idempotent_check
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- snmp_idempotent_check is not changed
|
|
|
|
|
2018-05-26 02:22:38 +02:00
|
|
|
- name: Add peer IPs
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
v3_enabled: true
|
|
|
|
v3_auth_mode: SHA
|
|
|
|
v3_auth_pass: ansiblepass
|
|
|
|
v3_priv_mode: AES128
|
|
|
|
v3_priv_pass: ansiblepass
|
|
|
|
peer_ips: 1.1.1.1;2.2.2.2
|
|
|
|
delegate_to: localhost
|
|
|
|
register: peers
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: '{{peers}}'
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-13 21:07:30 +02:00
|
|
|
- peers.data.peer_ips is defined
|
2018-05-26 02:22:38 +02:00
|
|
|
|
|
|
|
- name: Add invalid peer IPs
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
peer_ips: 1.1.1.1 2.2.2.2
|
|
|
|
delegate_to: localhost
|
|
|
|
register: invalid_peers
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
'"Peer IP addresses are semi-colon delimited." in invalid_peers.msg'
|
|
|
|
|
|
|
|
- name: Set short password
|
|
|
|
meraki_snmp:
|
|
|
|
auth_key: '{{auth_key}}'
|
|
|
|
org_name: '{{test_org_name}}'
|
|
|
|
state: present
|
|
|
|
v3_enabled: true
|
|
|
|
v3_auth_mode: SHA
|
|
|
|
v3_auth_pass: ansible
|
|
|
|
v3_priv_mode: AES128
|
|
|
|
v3_priv_pass: ansible
|
|
|
|
peer_ips: 1.1.1.1;2.2.2.2
|
|
|
|
delegate_to: localhost
|
|
|
|
register: short_password
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
msg: '{{short_password}}'
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- '"at least 8" in short_password.msg'
|