From cccaf951faabeda1c52bf1aabf581bfcbf21f5b4 Mon Sep 17 00:00:00 2001 From: Kevin Breit Date: Wed, 20 Jun 2018 02:40:10 -0500 Subject: [PATCH] Improved support for parameter testing and checks for org_id (#41517) --- .../modules/network/meraki/meraki_snmp.py | 5 ++- .../targets/meraki_snmp/tasks/main.yml | 34 +++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/network/meraki/meraki_snmp.py b/lib/ansible/modules/network/meraki/meraki_snmp.py index c9ef1055f8..4c12b97a90 100644 --- a/lib/ansible/modules/network/meraki/meraki_snmp.py +++ b/lib/ansible/modules/network/meraki/meraki_snmp.py @@ -234,8 +234,11 @@ def main(): # 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['org_id'] + if not meraki.params['org_name'] and not meraki.params['org_id']: + meraki.fail_json(msg='org_name or org_id is required') + + org_id = meraki.params['org_id'] if org_id is None: org_id = meraki.get_org_id(meraki.params['org_name']) diff --git a/test/integration/targets/meraki_snmp/tasks/main.yml b/test/integration/targets/meraki_snmp/tasks/main.yml index 8e300a256d..f41ce0fb1b 100644 --- a/test/integration/targets/meraki_snmp/tasks/main.yml +++ b/test/integration/targets/meraki_snmp/tasks/main.yml @@ -45,14 +45,42 @@ delegate_to: localhost register: snmp_v2_disable -# - debug: -# msg: '{{snmp_v2_disable}}' - - assert: that: - snmp_v2_disable.data.v2CommunityString is not defined - snmp_v2_disable.data.v2cEnabled == False +- 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: + - snmp_v2_enable_id.data.v2CommunityString is defined + - snmp_v2_enable_id.data.v2cEnabled == true + +- 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: + - snmp_v2_disable_id.data.v2CommunityString is not defined + - snmp_v2_disable_id.data.v2cEnabled == False + - name: Enable SNMPv3 meraki_snmp: auth_key: '{{auth_key}}'