mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-10 11:11:29 -07:00
meraki_config_template - Fix actions when specifying net_id (#51586)
* Allow configuration templates when using net_id...for reals - Didn't work before, I had bad code. I'm sorry. - Cleaned up code and simplified functions - Added integration tests to test for net_id actions * Add changelog * Add module name to changelog * Fix indentation
This commit is contained in:
parent
bb80316afa
commit
d65a91ea7e
3 changed files with 114 additions and 69 deletions
|
@ -4,26 +4,26 @@
|
|||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
---
|
||||
- block:
|
||||
- name: Test an API key is provided
|
||||
fail:
|
||||
msg: Please define an API key
|
||||
when: auth_key is not defined
|
||||
# - 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_config_template:
|
||||
auth_key: '{{ auth_key }}'
|
||||
host: marrrraki.com
|
||||
state: query
|
||||
org_name: DevTestOrg
|
||||
output_level: debug
|
||||
delegate_to: localhost
|
||||
register: invalid_domain
|
||||
ignore_errors: yes
|
||||
# - name: Use an invalid domain
|
||||
# meraki_config_template:
|
||||
# auth_key: '{{ auth_key }}'
|
||||
# host: marrrraki.com
|
||||
# state: query
|
||||
# org_name: DevTestOrg
|
||||
# output_level: debug
|
||||
# delegate_to: localhost
|
||||
# register: invalid_domain
|
||||
# ignore_errors: yes
|
||||
|
||||
- name: Connection assertions
|
||||
assert:
|
||||
that:
|
||||
- '"Failed to connect to" in invalid_domain.msg'
|
||||
# - name: Connection assertions
|
||||
# assert:
|
||||
# that:
|
||||
# - '"Failed to connect to" in invalid_domain.msg'
|
||||
|
||||
- name: Query all configuration templates
|
||||
meraki_config_template:
|
||||
|
@ -37,7 +37,7 @@
|
|||
auth_key: '{{auth_key}}'
|
||||
state: absent
|
||||
org_name: DevTestOrg
|
||||
config_template: DevConfigTemplateInvalid
|
||||
config_template: FakeConfigTemplate
|
||||
register: deleted
|
||||
ignore_errors: yes
|
||||
|
||||
|
@ -54,13 +54,24 @@
|
|||
type: appliance
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Get network id
|
||||
meraki_network:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: query
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: '{{test_net_name}}'
|
||||
register: net_info
|
||||
|
||||
- set_fact:
|
||||
net_id: '{{net_info.data.id}}'
|
||||
|
||||
- name: Bind a template to a network
|
||||
meraki_config_template:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{ test_org_name }}'
|
||||
net_name: '{{ test_net_name }}'
|
||||
config_template: DevConfigTemplate
|
||||
config_template: '{{test_template_name}}'
|
||||
register: bind
|
||||
|
||||
- assert:
|
||||
|
@ -73,7 +84,7 @@
|
|||
state: present
|
||||
org_name: '{{ test_org_name }}'
|
||||
net_name: '{{ test_net_name }}'
|
||||
config_template: DevConfigTemplate
|
||||
config_template: '{{test_template_name}}'
|
||||
register: bind_invalid
|
||||
ignore_errors: yes
|
||||
|
||||
|
@ -87,7 +98,7 @@
|
|||
state: absent
|
||||
org_name: '{{ test_org_name }}'
|
||||
net_name: '{{ test_net_name }}'
|
||||
config_template: DevConfigTemplate
|
||||
config_template: '{{test_template_name}}'
|
||||
register: unbind
|
||||
|
||||
- assert:
|
||||
|
@ -100,13 +111,52 @@
|
|||
state: absent
|
||||
org_name: '{{ test_org_name }}'
|
||||
net_name: '{{ test_net_name }}'
|
||||
config_template: DevConfigTemplate
|
||||
config_template: '{{test_template_name}}'
|
||||
register: unbind_invalid
|
||||
|
||||
- assert:
|
||||
that:
|
||||
unbind_invalid.changed == False
|
||||
|
||||
- name: Bind a template to a network via id
|
||||
meraki_config_template:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_id: '{{net_id}}'
|
||||
config_template: '{{test_template_name}}'
|
||||
register: bind_id
|
||||
|
||||
- assert:
|
||||
that:
|
||||
bind_id.changed == True
|
||||
|
||||
- name: Bind a template to a network via id for idempotency
|
||||
meraki_config_template:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_id: '{{net_id}}'
|
||||
config_template: '{{test_template_name}}'
|
||||
register: bind_id_idempotent
|
||||
|
||||
- assert:
|
||||
that:
|
||||
bind_id_idempotent.changed == False
|
||||
|
||||
- name: Unbind a template to a network via id
|
||||
meraki_config_template:
|
||||
auth_key: '{{auth_key}}'
|
||||
state: absent
|
||||
org_name: '{{test_org_name}}'
|
||||
net_id: '{{net_id}}'
|
||||
config_template: '{{test_template_name}}'
|
||||
register: unbind_id
|
||||
|
||||
- assert:
|
||||
that:
|
||||
unbind_id.changed == True
|
||||
|
||||
always:
|
||||
- name: Delete network
|
||||
meraki_network:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue