meraki_ssid - Modifying SSID won't work when specifying number (#51645)

* Fix bug when specifying SSID by number
- Migrated integration test to blocks with always
- Minor URL fixes

(cherry picked from commit ed79c294f2e3f82d4828226004c055dcd7ce9f63)

* Create changelog file

* Add new line
pull/52550/head
Kevin Breit 6 years ago committed by ansibot
parent 20ed819acd
commit 48128ec2fc

@ -0,0 +1,2 @@
bugfixes:
- meraki_ssid - Fix module to actually perform changes when state is present and SSID is referenced by number and not name.

@ -375,8 +375,8 @@ def main():
meraki.params['follow_redirects'] = 'all' meraki.params['follow_redirects'] = 'all'
query_urls = {'ssid': '/networks/{net_id}/ssids'} query_urls = {'ssid': '/networks/{net_id}/ssids'}
query_url = {'ssid': 'networks/{net_id}/ssids/'} query_url = {'ssid': '/networks/{net_id}/ssids/'}
update_url = {'ssid': 'networks/{net_id}/ssids/'} update_url = {'ssid': '/networks/{net_id}/ssids/'}
meraki.url_catalog['get_all'].update(query_urls) meraki.url_catalog['get_all'].update(query_urls)
meraki.url_catalog['get_one'].update(query_url) meraki.url_catalog['get_one'].update(query_url)
@ -434,8 +434,10 @@ def main():
if meraki.params[v] is not None: if meraki.params[v] is not None:
payload[k] = meraki.params[v] payload[k] = meraki.params[v]
ssids = get_ssids(meraki, net_id) ssids = get_ssids(meraki, net_id)
original = ssids[get_ssid_number(meraki.params['name'], ssids)] number = meraki.params['number']
# meraki.fail_json(msg=meraki.is_update_required(original, payload), original=original, payload=payload) if number is None:
number = get_ssid_number(meraki.params['name'], ssids)
original = ssids[number]
if meraki.is_update_required(original, payload): if meraki.is_update_required(original, payload):
ssid_id = meraki.params['number'] ssid_id = meraki.params['number']
if ssid_id is None: # Name should be used to lookup number if ssid_id is None: # Name should be used to lookup number

@ -3,23 +3,24 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # 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 - block:
- name: Test an API key is provided
fail: fail:
msg: Please define an API key msg: Please define an API key
when: auth_key is not defined when: auth_key is not defined
- name: Use an invalid domain # - name: Use an invalid domain
meraki_organization: # meraki_organization:
auth_key: '{{ auth_key }}' # auth_key: '{{ auth_key }}'
host: marrrraki.com # host: marrrraki.com
state: present # state: present
org_name: IntTestOrg # org_name: IntTestOrg
output_level: debug # output_level: debug
delegate_to: localhost # delegate_to: localhost
register: invalid_domain # register: invalid_domain
ignore_errors: yes # ignore_errors: yes
- name: Disable HTTP - name: Disable HTTP
meraki_organization: meraki_organization:
auth_key: '{{ auth_key }}' auth_key: '{{ auth_key }}'
use_https: false use_https: false
@ -29,13 +30,13 @@
register: http register: http
ignore_errors: yes ignore_errors: yes
- name: Connection assertions - name: Connection assertions
assert: assert:
that: that:
- '"Failed to connect to" in invalid_domain.msg' # - '"Failed to connect to" in invalid_domain.msg'
- '"http" in http.url' - '"http" in http.url'
- name: Create test network - name: Create test network
meraki_network: meraki_network:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -44,10 +45,10 @@
type: wireless type: wireless
register: test_net register: test_net
- debug: - debug:
msg: '{{test_net}}' msg: '{{test_net}}'
- name: Query all SSIDs - name: Query all SSIDs
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: query state: query
@ -56,10 +57,7 @@
delegate_to: localhost delegate_to: localhost
register: query_all register: query_all
- debug: - name: Enable and name SSID
msg: '{{query_all}}'
- name: Enable and name SSID
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -70,16 +68,16 @@
delegate_to: localhost delegate_to: localhost
register: enable_name_ssid register: enable_name_ssid
- debug: - debug:
msg: '{{ enable_name_ssid }}' msg: '{{ enable_name_ssid }}'
- assert: - assert:
that: that:
- query_all.data | length == 15 - query_all.data | length == 15
- query_all.data.0.name == 'TestNetSSID WiFi' - query_all.data.0.name == 'TestNetSSID WiFi'
- enable_name_ssid.data.name == 'AnsibleSSID' - enable_name_ssid.data.name == 'AnsibleSSID'
- name: Check for idempotency - name: Check for idempotency
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -90,14 +88,14 @@
delegate_to: localhost delegate_to: localhost
register: enable_name_ssid_idempotent register: enable_name_ssid_idempotent
- debug: - debug:
msg: '{{ enable_name_ssid_idempotent }}' msg: '{{ enable_name_ssid_idempotent }}'
- assert: - assert:
that: that:
- enable_name_ssid_idempotent.changed == False - enable_name_ssid_idempotent.changed == False
- name: Query one SSIDs - name: Query one SSIDs
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: query state: query
@ -107,14 +105,14 @@
delegate_to: localhost delegate_to: localhost
register: query_one register: query_one
- debug: - debug:
msg: '{{query_one}}' msg: '{{query_one}}'
- assert: - assert:
that: that:
- query_one.data.name == 'AnsibleSSID' - query_one.data.name == 'AnsibleSSID'
- name: Disable SSID without specifying number - name: Disable SSID without specifying number
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -125,14 +123,14 @@
delegate_to: localhost delegate_to: localhost
register: disable_ssid register: disable_ssid
- debug: - debug:
msg: '{{ disable_ssid.data.enabled }}' msg: '{{ disable_ssid.data.enabled }}'
- assert: - assert:
that: that:
- disable_ssid.data.enabled == False - disable_ssid.data.enabled == False
- name: Enable SSID with number - name: Enable SSID with number
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -143,14 +141,14 @@
delegate_to: localhost delegate_to: localhost
register: enable_ssid_number register: enable_ssid_number
- debug: - debug:
msg: '{{ enable_ssid_number.data.enabled }}' msg: '{{ enable_ssid_number.data.enabled }}'
- assert: - assert:
that: that:
- enable_ssid_number.data.enabled == True - enable_ssid_number.data.enabled == True
- name: Set PSK with wrong mode - name: Set PSK with wrong mode
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -163,14 +161,14 @@
register: psk_invalid register: psk_invalid
ignore_errors: yes ignore_errors: yes
- debug: - debug:
msg: '{{ psk_invalid }}' msg: '{{ psk_invalid }}'
- assert: - assert:
that: that:
- psk_invalid.msg == 'PSK is only allowed when auth_mode is set to psk' - psk_invalid.msg == 'PSK is only allowed when auth_mode is set to psk'
- name: Set PSK with invalid encryption mode - name: Set PSK with invalid encryption mode
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -184,14 +182,14 @@
register: psk_invalid_mode register: psk_invalid_mode
ignore_errors: yes ignore_errors: yes
- debug: - debug:
msg: '{{ psk_invalid_mode }}' msg: '{{ psk_invalid_mode }}'
- assert: - assert:
that: that:
- psk_invalid_mode.msg == 'PSK requires encryption_mode be set to wpa' - psk_invalid_mode.msg == 'PSK requires encryption_mode be set to wpa'
- name: Set PSK - name: Set PSK
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -204,16 +202,16 @@
delegate_to: localhost delegate_to: localhost
register: psk register: psk
- debug: - debug:
msg: '{{ psk }}' msg: '{{ psk }}'
- assert: - assert:
that: that:
- psk.data.authMode == 'psk' - psk.data.authMode == 'psk'
- psk.data.encryptionMode == 'wpa' - psk.data.encryptionMode == 'wpa'
- psk.data.wpaEncryptionMode == 'WPA2 only' - psk.data.wpaEncryptionMode == 'WPA2 only'
- name: Enable click-through splash page - name: Enable click-through splash page
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -224,14 +222,14 @@
delegate_to: localhost delegate_to: localhost
register: splash_click register: splash_click
- debug: - debug:
msg: '{{ splash_click }}' msg: '{{ splash_click }}'
- assert: - assert:
that: that:
- splash_click.data.splashPage == 'Click-through splash page' - splash_click.data.splashPage == 'Click-through splash page'
- name: Configure RADIUS servers - name: Configure RADIUS servers
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: present state: present
@ -246,14 +244,14 @@
delegate_to: localhost delegate_to: localhost
register: set_radius_server register: set_radius_server
- debug: - debug:
msg: '{{ set_radius_server }}' msg: '{{ set_radius_server }}'
- assert: - assert:
that: that:
- set_radius_server.data.radiusServers.0.host == '192.0.1.200' - set_radius_server.data.radiusServers.0.host == '192.0.1.200'
always:
- name: Delete SSID - name: Delete SSID
meraki_ssid: meraki_ssid:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: absent state: absent
@ -263,14 +261,14 @@
delegate_to: localhost delegate_to: localhost
register: delete_ssid register: delete_ssid
- debug: - debug:
msg: '{{ delete_ssid }}' msg: '{{ delete_ssid }}'
- assert: - assert:
that: that:
- delete_ssid.data.name == 'Unconfigured SSID 2' - delete_ssid.data.name == 'Unconfigured SSID 2'
- name: Delete test network - name: Delete test network
meraki_network: meraki_network:
auth_key: '{{auth_key}}' auth_key: '{{auth_key}}'
state: absent state: absent
@ -278,5 +276,5 @@
net_name: TestNetSSID net_name: TestNetSSID
register: delete_net register: delete_net
- debug: - debug:
msg: '{{delete_net}}' msg: '{{delete_net}}'
Loading…
Cancel
Save