mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
20ed819acd
commit
48128ec2fc
3 changed files with 245 additions and 243 deletions
2
changelogs/fragments/meraki_ssid_number_fix.yml
Normal file
2
changelogs/fragments/meraki_ssid_number_fix.yml
Normal file
|
@ -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'
|
||||
|
||||
query_urls = {'ssid': '/networks/{net_id}/ssids'}
|
||||
query_url = {'ssid': 'networks/{net_id}/ssids/'}
|
||||
update_url = {'ssid': 'networks/{net_id}/ssids/'}
|
||||
query_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_one'].update(query_url)
|
||||
|
@ -434,8 +434,10 @@ def main():
|
|||
if meraki.params[v] is not None:
|
||||
payload[k] = meraki.params[v]
|
||||
ssids = get_ssids(meraki, net_id)
|
||||
original = ssids[get_ssid_number(meraki.params['name'], ssids)]
|
||||
# meraki.fail_json(msg=meraki.is_update_required(original, payload), original=original, payload=payload)
|
||||
number = meraki.params['number']
|
||||
if number is None:
|
||||
number = get_ssid_number(meraki.params['name'], ssids)
|
||||
original = ssids[number]
|
||||
if meraki.is_update_required(original, payload):
|
||||
ssid_id = meraki.params['number']
|
||||
if ssid_id is None: # Name should be used to lookup number
|
||||
|
|
|
@ -3,280 +3,278 @@
|
|||
|
||||
# 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
|
||||
- block:
|
||||
- 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: Connection assertions
|
||||
assert:
|
||||
that:
|
||||
# - '"Failed to connect to" in invalid_domain.msg'
|
||||
- '"http" in http.url'
|
||||
|
||||
- name: Create test network
|
||||
meraki_network:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
type: wireless
|
||||
register: test_net
|
||||
- name: Create test network
|
||||
meraki_network:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
type: wireless
|
||||
register: test_net
|
||||
|
||||
- debug:
|
||||
msg: '{{test_net}}'
|
||||
- debug:
|
||||
msg: '{{test_net}}'
|
||||
|
||||
- name: Query all SSIDs
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: query
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
delegate_to: localhost
|
||||
register: query_all
|
||||
- name: Query all SSIDs
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: query
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
delegate_to: localhost
|
||||
register: query_all
|
||||
|
||||
- debug:
|
||||
msg: '{{query_all}}'
|
||||
- name: Enable and name SSID
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
enabled: true
|
||||
delegate_to: localhost
|
||||
register: enable_name_ssid
|
||||
|
||||
- name: Enable and name SSID
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
enabled: true
|
||||
delegate_to: localhost
|
||||
register: enable_name_ssid
|
||||
- debug:
|
||||
msg: '{{ enable_name_ssid }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ enable_name_ssid }}'
|
||||
- assert:
|
||||
that:
|
||||
- query_all.data | length == 15
|
||||
- query_all.data.0.name == 'TestNetSSID WiFi'
|
||||
- enable_name_ssid.data.name == 'AnsibleSSID'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- query_all.data | length == 15
|
||||
- query_all.data.0.name == 'TestNetSSID WiFi'
|
||||
- enable_name_ssid.data.name == 'AnsibleSSID'
|
||||
- name: Check for idempotency
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
enabled: true
|
||||
delegate_to: localhost
|
||||
register: enable_name_ssid_idempotent
|
||||
|
||||
- name: Check for idempotency
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
enabled: true
|
||||
delegate_to: localhost
|
||||
register: enable_name_ssid_idempotent
|
||||
- debug:
|
||||
msg: '{{ enable_name_ssid_idempotent }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ enable_name_ssid_idempotent }}'
|
||||
- assert:
|
||||
that:
|
||||
- enable_name_ssid_idempotent.changed == False
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- enable_name_ssid_idempotent.changed == False
|
||||
- name: Query one SSIDs
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: query
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
delegate_to: localhost
|
||||
register: query_one
|
||||
|
||||
- name: Query one SSIDs
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: query
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
delegate_to: localhost
|
||||
register: query_one
|
||||
- debug:
|
||||
msg: '{{query_one}}'
|
||||
|
||||
- debug:
|
||||
msg: '{{query_one}}'
|
||||
- assert:
|
||||
that:
|
||||
- query_one.data.name == 'AnsibleSSID'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- query_one.data.name == 'AnsibleSSID'
|
||||
- name: Disable SSID without specifying number
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
enabled: false
|
||||
delegate_to: localhost
|
||||
register: disable_ssid
|
||||
|
||||
- name: Disable SSID without specifying number
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
enabled: false
|
||||
delegate_to: localhost
|
||||
register: disable_ssid
|
||||
- debug:
|
||||
msg: '{{ disable_ssid.data.enabled }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ disable_ssid.data.enabled }}'
|
||||
- assert:
|
||||
that:
|
||||
- disable_ssid.data.enabled == False
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- disable_ssid.data.enabled == False
|
||||
- name: Enable SSID with number
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
number: 1
|
||||
enabled: true
|
||||
delegate_to: localhost
|
||||
register: enable_ssid_number
|
||||
|
||||
- name: Enable SSID with number
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
number: 1
|
||||
enabled: true
|
||||
delegate_to: localhost
|
||||
register: enable_ssid_number
|
||||
- debug:
|
||||
msg: '{{ enable_ssid_number.data.enabled }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ enable_ssid_number.data.enabled }}'
|
||||
- assert:
|
||||
that:
|
||||
- enable_ssid_number.data.enabled == True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- enable_ssid_number.data.enabled == True
|
||||
- name: Set PSK with wrong mode
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
auth_mode: open
|
||||
psk: abc1234
|
||||
delegate_to: localhost
|
||||
register: psk_invalid
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Set PSK with wrong mode
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
auth_mode: open
|
||||
psk: abc1234
|
||||
delegate_to: localhost
|
||||
register: psk_invalid
|
||||
ignore_errors: yes
|
||||
- debug:
|
||||
msg: '{{ psk_invalid }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ psk_invalid }}'
|
||||
- assert:
|
||||
that:
|
||||
- psk_invalid.msg == 'PSK is only allowed when auth_mode is set to psk'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- psk_invalid.msg == 'PSK is only allowed when auth_mode is set to psk'
|
||||
- name: Set PSK with invalid encryption mode
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
auth_mode: psk
|
||||
psk: abc1234
|
||||
encryption_mode: eap
|
||||
delegate_to: localhost
|
||||
register: psk_invalid_mode
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Set PSK with invalid encryption mode
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
auth_mode: psk
|
||||
psk: abc1234
|
||||
encryption_mode: eap
|
||||
delegate_to: localhost
|
||||
register: psk_invalid_mode
|
||||
ignore_errors: yes
|
||||
- debug:
|
||||
msg: '{{ psk_invalid_mode }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ psk_invalid_mode }}'
|
||||
- assert:
|
||||
that:
|
||||
- psk_invalid_mode.msg == 'PSK requires encryption_mode be set to wpa'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- psk_invalid_mode.msg == 'PSK requires encryption_mode be set to wpa'
|
||||
- name: Set PSK
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
auth_mode: psk
|
||||
psk: abc1234567890
|
||||
encryption_mode: wpa
|
||||
delegate_to: localhost
|
||||
register: psk
|
||||
|
||||
- name: Set PSK
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
auth_mode: psk
|
||||
psk: abc1234567890
|
||||
encryption_mode: wpa
|
||||
delegate_to: localhost
|
||||
register: psk
|
||||
- debug:
|
||||
msg: '{{ psk }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ psk }}'
|
||||
- assert:
|
||||
that:
|
||||
- psk.data.authMode == 'psk'
|
||||
- psk.data.encryptionMode == 'wpa'
|
||||
- psk.data.wpaEncryptionMode == 'WPA2 only'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- psk.data.authMode == 'psk'
|
||||
- psk.data.encryptionMode == 'wpa'
|
||||
- psk.data.wpaEncryptionMode == 'WPA2 only'
|
||||
- name: Enable click-through splash page
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
splash_page: Click-through splash page
|
||||
delegate_to: localhost
|
||||
register: splash_click
|
||||
|
||||
- name: Enable click-through splash page
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
splash_page: Click-through splash page
|
||||
delegate_to: localhost
|
||||
register: splash_click
|
||||
- debug:
|
||||
msg: '{{ splash_click }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ splash_click }}'
|
||||
- assert:
|
||||
that:
|
||||
- splash_click.data.splashPage == 'Click-through splash page'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- splash_click.data.splashPage == 'Click-through splash page'
|
||||
- name: Configure RADIUS servers
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
auth_mode: open-with-radius
|
||||
radius_servers:
|
||||
- host: 192.0.1.200
|
||||
port: 1234
|
||||
secret: abc98765
|
||||
delegate_to: localhost
|
||||
register: set_radius_server
|
||||
|
||||
- name: Configure RADIUS servers
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
auth_mode: open-with-radius
|
||||
radius_servers:
|
||||
- host: 192.0.1.200
|
||||
port: 1234
|
||||
secret: abc98765
|
||||
delegate_to: localhost
|
||||
register: set_radius_server
|
||||
- debug:
|
||||
msg: '{{ set_radius_server }}'
|
||||
|
||||
- debug:
|
||||
msg: '{{ set_radius_server }}'
|
||||
- assert:
|
||||
that:
|
||||
- set_radius_server.data.radiusServers.0.host == '192.0.1.200'
|
||||
always:
|
||||
- name: Delete SSID
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: absent
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
delegate_to: localhost
|
||||
register: delete_ssid
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- set_radius_server.data.radiusServers.0.host == '192.0.1.200'
|
||||
- debug:
|
||||
msg: '{{ delete_ssid }}'
|
||||
|
||||
- name: Delete SSID
|
||||
meraki_ssid:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: absent
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
name: AnsibleSSID
|
||||
delegate_to: localhost
|
||||
register: delete_ssid
|
||||
- assert:
|
||||
that:
|
||||
- delete_ssid.data.name == 'Unconfigured SSID 2'
|
||||
|
||||
- debug:
|
||||
msg: '{{ delete_ssid }}'
|
||||
- name: Delete test network
|
||||
meraki_network:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: absent
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
register: delete_net
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- delete_ssid.data.name == 'Unconfigured SSID 2'
|
||||
|
||||
- name: Delete test network
|
||||
meraki_network:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: absent
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: TestNetSSID
|
||||
register: delete_net
|
||||
|
||||
- debug:
|
||||
msg: '{{delete_net}}'
|
||||
- debug:
|
||||
msg: '{{delete_net}}'
|
||||
|
|
Loading…
Reference in a new issue