diff options
Diffstat (limited to 'collections-debian-merged/ansible_collections/cisco/meraki/tests')
80 files changed, 9247 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/inventory.networking b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/inventory.networking new file mode 100644 index 00000000..ab895895 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/inventory.networking @@ -0,0 +1,42 @@ +# This is the configuration template for ansible-test network-integration tests. +# +# You do not need this template if you are: +# +# 1) Running integration tests without using ansible-test. +# 2) Using the `--platform` option to provision temporary network instances on EC2. +# +# If you do not want to use the automatically provisioned temporary network instances, +# fill in the @VAR placeholders below and save this file without the .template extension. +# +# NOTE: Automatic provisioning of network instances on EC2 requires an ansible-core-ci API key. + +[meraki] +localhost ansible_connection="local" + +[meraki:vars] +auth_key=b4aa1133085792857ae08a22ed01bc99b7e9c97d +test_org_id=133277 +test_org_name=kbreit@insight.com +test_net_name=Home - Appliance +test_net_id=N_624874448297678702 +test_switch_net_name=Home - Switch +test_wireless_net_name=Home - Wireless +test_appliance_net_name=Home - Appliance +test_template_name=AnsibleTemplate +test_template_id=L_624874448297661409 +email_prefix=meraki +email_domain=kevinbreit.net +serial=Q2BN-MCH8-VEL5 +serial_switch=Q2HP-2C6E-GTLD +serial_wireless=Q2KD-83UG-JL8X +serial_switch_l3=QBSB-VLNE-E299 +serial_appliance=Q2BN-MCH8-VEL5 +# serial=QBSC-HJSL-A64F +# serial=Q2HD-DPPR-QTAE +# serial=Q2HP-2C6E-GTLD + +### +# Example +# +# [vyos] +# vyos01.example.net ansible_connection=local ansible_network_os="vyos" ansible_user=admin ansible_ssh_pass=mypassword diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/inventory.networking.template b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/inventory.networking.template new file mode 100644 index 00000000..3057b7f2 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/inventory.networking.template @@ -0,0 +1,37 @@ +# This is the configuration template for ansible-test network-integration tests. +# +# You do not need this template if you are: +# +# 1) Running integration tests without using ansible-test. +# 2) Using the `--platform` option to provision temporary network instances on EC2. +# +# If you do not want to use the automatically provisioned temporary network instances, +# fill in the @VAR placeholders below and save this file without the .template extension. +# +# NOTE: Automatic provisioning of network instances on EC2 requires an ansible-core-ci API key. + +[meraki] +localhost ansible_connection="local" + +[meraki:vars] +auth_key=abc1234567890 +test_org_id=12345 +test_org_name=YourOrg +test_net_name=YourNet +test_net_id=54321 +test_switch_net_name=Switch Net +test_wireless_net_name=Wireless Net +test_template_name=YourTemplate +test_template_id=L_12345 +email_prefix=YourEmail +email_domain=YourDomain +serial=YourSerial +serial_switch=YourSwitchSerial +serial_switch_l3=YourL3SwitchSerial + + +### +# Example +# +# [vyos] +# vyos01.example.net ansible_connection=local ansible_network_os="vyos" ansible_user=admin ansible_ssh_pass=mypassword diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/target-prefixes.network b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/target-prefixes.network new file mode 100644 index 00000000..2516cd48 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/target-prefixes.network @@ -0,0 +1 @@ +meraki diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_admin/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_admin/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_admin/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_admin/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_admin/tasks/main.yml new file mode 100644 index 00000000..336f9e4f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_admin/tasks/main.yml @@ -0,0 +1,404 @@ +# Test code for the Meraki Admin 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) +--- +- block: + - name: Create new administrator in check mode + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jane Doe + email: '{{email_prefix}}+janedoe@{{email_domain}}' + org_access: read-only + delegate_to: localhost + check_mode: yes + register: create_org_check + + - name: Create new admin check mode assertion + assert: + that: + - create_org_check is changed + - 'create_org_check.data.name == "Jane Doe"' + + - name: Create new administrator + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jane Doe + email: '{{email_prefix}}+janedoe@{{email_domain}}' + org_access: read-only + delegate_to: localhost + register: create_orgaccess + + - name: Create new admin assertion + assert: + that: + - create_orgaccess.changed == true + - 'create_orgaccess.data.name == "Jane Doe"' + + - name: Delete recently created administrator with check mode + meraki_admin: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + email: '{{email_prefix}}+janedoe@{{email_domain}}' + delegate_to: localhost + register: delete_one_check + check_mode: yes + + - assert: + that: + - delete_one_check is changed + + - name: Delete recently created administrator + meraki_admin: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + email: '{{email_prefix}}+janedoe@{{email_domain}}' + delegate_to: localhost + register: delete_one + + - name: Create new administrator with org_id + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + name: Jane Doe + email: '{{email_prefix}}+janedoe@{{email_domain}}' + orgAccess: read-only + delegate_to: localhost + register: create_orgaccess_id + + - name: Create new admin assertion + assert: + that: + - create_orgaccess_id.changed == true + - 'create_orgaccess_id.data.name == "Jane Doe"' + + - name: Create administrator with tags with check mode + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: John Doe + email: '{{email_prefix}}+johndoe@{{email_domain}}' + orgAccess: none + tags: + - tag: production + access: read-only + - tag: beta + access: full + delegate_to: localhost + register: create_tags_check + check_mode: yes + + - assert: + that: + - create_tags_check is changed + - create_tags_check.data.name == "John Doe" + - create_tags_check.data.tags | length == 2 + + - name: Create administrator with tags + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: John Doe + email: '{{email_prefix}}+johndoe@{{email_domain}}' + orgAccess: none + tags: + - tag: production + access: read-only + - tag: beta + access: full + delegate_to: localhost + register: create_tags + + - assert: + that: + - create_tags.changed == true + - create_tags.data.name == "John Doe" + - create_tags.data.tags | length == 2 + + - name: Create administrator with invalid tags + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jake Doe + email: '{{email_prefix}}+jakedoe@{{email_domain}}' + orgAccess: none + tags: + - tag: production + access: read-only + - tag: alpha + access: invalid + delegate_to: localhost + register: create_tags_invalid + ignore_errors: yes + + - assert: + that: + - '"400" in create_tags_invalid.msg' + - '"must be one of" in create_tags_invalid.msg' + + - name: Create administrator with invalid tag permission + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jake Doe + email: '{{email_prefix}}+jakedoe@{{email_domain}}' + orgAccess: none + tags: + - tag: production + access: read-only + - tag: beta + access: invalid + delegate_to: localhost + register: create_tags_invalid_permission + ignore_errors: yes + + - assert: + that: + - '"400" in create_tags_invalid_permission.msg' + - '"must be one of" in create_tags_invalid_permission.msg' + + - name: Make sure TestNet and TestNet2 are created + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{item}}' + type: switch + register: new_networks + loop: + - TestNet + - TestNet2 + + - set_fact: + testnet_id: new_networks.results[0].data.id + testnet2_id: new_networks.results[1].data.id + + - name: Create administrator with networks with check mode + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jim Doe + email: '{{email_prefix}}+jimdoe@{{email_domain}}' + orgAccess: none + networks: + - network: TestNet + access: read-only + - id: testnet2_id + access: full + delegate_to: localhost + register: create_network_check + check_mode: yes + + - assert: + that: + - create_network_check is changed + - create_network_check.data.name == "Jim Doe" + - create_network_check.data.networks | length == 2 + + - name: Create administrator with networks + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jim Doe + email: '{{email_prefix}}+jimdoe@{{email_domain}}' + orgAccess: none + networks: + - network: TestNet + access: read-only + - network: TestNet2 + access: full + delegate_to: localhost + register: create_network + + - assert: + that: + - create_network.changed == true + - create_network.data.name == "Jim Doe" + - create_network.data.networks | length == 2 + + - name: Update administrator with check mode + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jim Doe + email: '{{email_prefix}}+jimdoe@{{email_domain}}' + orgAccess: none + networks: + - network: TestNet + access: full + delegate_to: localhost + register: update_network_check + check_mode: yes + + - debug: + var: update_network_check + + - assert: + that: + - update_network_check is changed + - update_network_check.data.networks.0.access == "full" + - update_network_check.data.networks | length == 1 + + - name: Update administrator + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jim Doe + email: '{{email_prefix}}+jimdoe@{{email_domain}}' + orgAccess: none + networks: + - network: TestNet + access: full + delegate_to: localhost + register: update_network + + - assert: + that: + - update_network.changed == true + - update_network.data.networks.0.access == "full" + - update_network.data.networks | length == 1 + + - name: Update administrator for idempotency check with check mode + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jim Doe + email: '{{email_prefix}}+jimdoe@{{email_domain}}' + orgAccess: none + networks: + - network: TestNet + access: full + delegate_to: localhost + register: update_network_idempotent_check + check_mode: yes + + - debug: + var: update_network_idempotent_check + + - assert: + that: + - update_network_idempotent_check is not changed + + - name: Update administrator for idempotency + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: Jim Doe + email: '{{email_prefix}}+jimdoe@{{email_domain}}' + orgAccess: none + networks: + - network: TestNet + access: full + delegate_to: localhost + register: update_network_idempotent + + - assert: + that: + - update_network_idempotent.changed == false + - update_network_idempotent.data is defined + + - name: Create administrator with invalid network + meraki_admin: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + name: John Doe + email: '{{email_prefix}}+John@{{email_domain}}' + orgAccess: none + networks: + - network: TestNetFake + access: read-only + delegate_to: localhost + register: create_network_invalid + ignore_errors: yes + + - assert: + that: + - '"No network found with the name" in create_network_invalid.msg' + # - '"400" in create_network_invalid.msg' + + - name: Query all administrators + meraki_admin: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + delegate_to: localhost + register: query_all + + - debug: + var: query_all + + - assert: + that: + - query_all.data | length == 4 + - query_all.changed == False + + - name: Query admin by name + meraki_admin: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + name: Jane Doe + delegate_to: localhost + register: query_name + + - name: Query admin by email + meraki_admin: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + email: '{{email_prefix}}+janedoe@{{email_domain}}' + delegate_to: localhost + register: query_email + + - assert: + that: + - query_name.data.name == "Jane Doe" + - 'query_email.data.email == "{{email_prefix}}+janedoe@{{email_domain}}"' + + always: + ############################################################################# + # Tear down starts here + ############################################################################# + - name: Delete administrators + meraki_admin: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + email: '{{item}}' + delegate_to: localhost + register: delete_all + ignore_errors: yes + loop: + - '{{email_prefix}}+janedoe@{{email_domain}}' + - '{{email_prefix}}+johndoe@{{email_domain}}' + - '{{email_prefix}}+jimdoe@{{email_domain}}' + + - name: Query all administrators + meraki_admin: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + delegate_to: localhost + register: query_all_deleted + + - assert: + that: + - query_all_deleted.data | length == 1
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_alert/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_alert/aliases new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_alert/aliases diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_alert/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_alert/tasks/main.yml new file mode 100644 index 00000000..baf2a081 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_alert/tasks/main.yml @@ -0,0 +1,174 @@ +# Test code for the Meraki modules +# Copyright: (c) 2020, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network with type wireless + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + type: wireless + timezone: America/Chicago + delegate_to: localhost + + - name: Update settings with check mode + meraki_alert: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + default_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: no + snmp: no + alerts: + - alert_type: "gatewayDown" + enabled: yes + filters: + timeout: 60 + alert_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: no + snmp: no + - alert_type: "usageAlert" + enabled: yes + filters: + period: 1200 + threshold: 104857600 + alert_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: yes + snmp: no + delegate_to: localhost + register: update_check + check_mode: yes + + - assert: + that: + - update_check.data is defined + - update_check.diff is defined + - update_check is changed + + - name: Update settings + meraki_alert: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + default_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: no + snmp: no + alerts: + - alert_type: "gatewayDown" + enabled: yes + filters: + timeout: 60 + alert_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: no + snmp: no + - alert_type: "usageAlert" + enabled: yes + filters: + period: 1200 + threshold: 104857600 + alert_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: yes + snmp: no + delegate_to: localhost + register: update + + - assert: + that: + - update.data is defined + - update.diff is defined + - update is changed + + - name: Update settings idempotent + meraki_alert: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + default_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: no + snmp: no + alerts: + - alert_type: "gatewayDown" + enabled: yes + filters: + timeout: 60 + alert_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: no + snmp: no + - alert_type: "usageAlert" + enabled: yes + filters: + period: 1200 + threshold: 104857600 + alert_destinations: + emails: + - '{{ email_prefix }}@{{ email_domain }}' + - '{{ email_prefix }}2@{{ email_domain }}' + all_admins: yes + snmp: no + delegate_to: localhost + register: update_idempotent + + - assert: + that: + - update_idempotent.data is defined + - update_idempotent is not changed + + - name: Query all settings + meraki_alert: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: query + delegate_to: localhost + register: query_all + + - debug: + var: query_all + + - assert: + that: + - query_all.data is defined + + +############################################################################# +# Tear down starts here +############################################################################# + + always: + - name: Delete network + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_config_template/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_config_template/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_config_template/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_config_template/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_config_template/tasks/main.yml new file mode 100644 index 00000000..7bfc5e0b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_config_template/tasks/main.yml @@ -0,0 +1,196 @@ +# 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Query all configuration templates + meraki_config_template: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + register: get_all + + - name: Delete non-existant configuration template + meraki_config_template: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + config_template: FakeConfigTemplate + register: deleted + ignore_errors: yes + + - assert: + that: + - '"No configuration template named" in deleted.msg' + + - name: Create a network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{ test_org_name }}' + net_name: '{{ test_net_name }}' + type: appliance + delegate_to: localhost + register: net_info + + - set_fact: + net_id: '{{net_info.data.id}}' + + - name: Bind a template to a network with check mode + meraki_config_template: + auth_key: '{{auth_key}}' + state: present + org_name: '{{ test_org_name }}' + net_name: '{{ test_net_name }}' + config_template: '{{test_template_name}}' + check_mode: yes + register: bind_check + + - 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: '{{test_template_name}}' + register: bind + + - assert: + that: + bind.changed == True + + - assert: + that: + bind_check is changed + + - name: Bind a template to a network when it's already bound + meraki_config_template: + auth_key: '{{auth_key}}' + state: present + org_name: '{{ test_org_name }}' + net_name: '{{ test_net_name }}' + config_template: '{{test_template_name}}' + register: bind_invalid + ignore_errors: yes + + - assert: + that: + - bind_invalid.changed == False + + - name: Unbind a template from a network + meraki_config_template: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{ test_org_name }}' + net_name: '{{ test_net_name }}' + config_template: '{{test_template_name}}' + register: unbind + + - assert: + that: + unbind.changed == True + + - name: Unbind a template from a network when it's not bound + meraki_config_template: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{ test_org_name }}' + net_name: '{{ test_net_name }}' + 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 + - bind_id_idempotent.data is defined + + - name: Unbind a template from a network via id with check mode + meraki_config_template: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_id: '{{net_id}}' + config_template: '{{test_template_name}}' + check_mode: yes + register: unbind_id_check + + - assert: + that: + unbind_id_check is changed + + - name: Unbind a template from 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 + + # This is disabled by default since they can't be created via API + # - name: Delete sacrificial template with check mode + # meraki_config_template: + # auth_key: '{{auth_key}}' + # state: absent + # org_name: '{{test_org_name}}' + # config_template: sacrificial_template + # check_mode: yes + # register: delete_template_check + + # This is disabled by default since they can't be created via API + # - name: Delete sacrificial template + # meraki_config_template: + # auth_key: '{{auth_key}}' + # state: absent + # org_name: '{{test_org_name}}' + # config_template: sacrificial_template + # output_level: debug + # register: delete_template + + # - debug: + # var: delete_template + + always: + - name: Delete network + meraki_network: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{ test_org_name }}' + net_name: '{{ test_net_name }}' + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_content_filtering/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_content_filtering/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_content_filtering/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_content_filtering/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_content_filtering/tasks/main.yml new file mode 100644 index 00000000..a3a5210f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_content_filtering/tasks/main.yml @@ -0,0 +1,254 @@ +# Test code for the Meraki Content Filteringmodule +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# 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: Create network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + type: appliance + timezone: America/Chicago + delegate_to: localhost + register: create_net_appliance + + - name: Test net_name and id exclusivity + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + net_id: 12345 + state: present + allowed_urls: + - "http://www.ansible.com/*" + register: net_exclusive + ignore_errors: yes + + - assert: + that: + - 'net_exclusive.msg == "net_name and net_id are mutually exclusive"' + + - name: Set single allowed URL pattern with check mode + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + allowed_urls: + - "http://www.ansible.com/*" + register: single_allowed_check + check_mode: yes + + - assert: + that: + - single_allowed_check.data.allowed_url_patterns | length == 1 + - single_allowed_check is changed + + - name: Set single allowed URL pattern + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + allowed_urls: + - "http://www.ansible.com/*" + register: single_allowed + + - assert: + that: + - single_allowed.data.allowed_url_patterns | length == 1 + + - name: Set single allowed URL pattern for idempotency with check mode + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + allowed_urls: + - "http://www.ansible.com/*" + register: single_allowed_idempotent_check + check_mode: yes + + - debug: + var: single_allowed_idempotent_check + + - assert: + that: + - single_allowed_idempotent_check is not changed + - single_allowed.data.allowed_url_patterns | length == 1 + + - name: Set single allowed URL pattern for idempotency + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + allowed_urls: + - "http://www.ansible.com/*" + register: single_allowed_idempotent + + - debug: + var: single_allowed_idempotent + + - assert: + that: + - single_allowed_idempotent.changed == False + - single_allowed_idempotent.data is defined + + - name: Set single blocked URL pattern + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + blocked_urls: + - "http://www.ansible.com/*" + register: single_blocked + + - debug: + var: single_blocked + + - assert: + that: + - single_blocked.data.blocked_url_patterns | length == 1 + + - name: Set two allowed URL pattern + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + allowed_urls: + - "http://www.ansible.com/*" + - "http://www.redhat.com" + register: two_allowed + + - debug: + var: two_allowed + + - assert: + that: + - two_allowed.changed == True + - two_allowed.data.allowed_url_patterns | length == 2 + + - name: Set blocked URL category + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + category_list_size: full list + blocked_categories: + - "Adult and Pornography" + register: blocked_category + + - debug: + var: blocked_category + + - assert: + that: + - blocked_category.changed == True + - blocked_category.data.blocked_url_categories | length == 1 + - blocked_category.data.url_category_list_size == "fullList" + + - name: Set blocked URL category with top sites + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + category_list_size: top sites + blocked_categories: + - "Adult and Pornography" + register: blocked_category + + - debug: + var: blocked_category + + - assert: + that: + - blocked_category.changed == True + - blocked_category.data.blocked_url_categories | length == 1 + - blocked_category.data.url_category_list_size == "topSites" + + - name: Query all content filtering information + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + delegate_to: localhost + register: query_all + + - debug: + var: query_all + + - name: Query all content filtering assertion + assert: + that: + - query_all.data.categories is defined + - query_all.data.policy is defined + + - name: Query categories + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + subset: categories + delegate_to: localhost + register: query_categories + + - debug: + var: query_categories + + - name: Query categories assertion + assert: + that: + - query_categories.data is defined + + - name: Query content filtering policies + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + subset: policy + state: query + delegate_to: localhost + register: query_policy + + - debug: + var: query_policy + + - name: Query contnet filtering policy assertion + assert: + that: + - query_policy.data is defined + + always: + - name: Reset policies + meraki_content_filtering: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + category_list_size: full list + allowed_urls: + - + blocked_urls: + - + + - name: Delete network + meraki_network: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: absent diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_device/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_device/aliases new file mode 100644 index 00000000..89aea537 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_device/aliases @@ -0,0 +1 @@ +unsupported
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_device/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_device/tasks/main.yml new file mode 100644 index 00000000..4b999c41 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_device/tasks/main.yml @@ -0,0 +1,246 @@ +--- +- block: + # This is commented out because a device cannot be unclaimed via API + # - name: Claim a device into an organization + # meraki_device: + # auth_key: '{{auth_key}}' + # org_name: '{{test_org_name}}' + # serial: '{{serial}}' + # state: present + # delegate_to: localhost + # register: claim_device_org + + # - assert: + # that: + # - claim_device_org.changed == true + + - name: Create network + meraki_network: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + type: appliance + state: present + register: net_info + + - set_fact: + net_id: '{{net_info.data.id}}' + + - name: Query status of all devices in an organization + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + state: query + delegate_to: localhost + register: query_device_org + + - debug: + msg: '{{query_device_org}}' + + - name: Claim a device into a network + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + serial: '{{serial}}' + state: present + delegate_to: localhost + register: claim_device + + - debug: + msg: '{{claim_device}}' + + - assert: + that: + - claim_device.changed == true + + - name: Query all devices in one network by network ID + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_id: '{{net_id}}' + state: query + delegate_to: localhost + register: query_one_net_id + + - debug: + msg: '{{query_one_net_id}}' + + - name: Query all devices in one network + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + delegate_to: localhost + register: query_one_net + + - debug: + msg: '{{query_one_net}}' + + - name: Query device by serial + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + serial: '{{serial}}' + state: query + delegate_to: localhost + register: query_serial_no_net + + - debug: + msg: '{{query_serial_no_net}}' + + - name: Query device by serial + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + serial: '{{serial}}' + state: query + delegate_to: localhost + register: query_serial + + - debug: + msg: '{{query_serial}}' + + - assert: + that: + - query_serial.changed == False + + - name: Query uplink information for a device + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + serial: '{{serial}}' + state: query + query: uplink + delegate_to: localhost + register: query_serial_uplink + + - debug: + msg: '{{query_serial_uplink}}' + + - name: Query LLDP/CDP information about a device + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + serial: '{{serial}}' + lldp_cdp_timespan: 6000 + state: query + query: lldp_cdp + delegate_to: localhost + register: query_serial_lldp_cdp + + - debug: + msg: '{{query_serial_lldp_cdp}}' + + - name: Query a device by hostname + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + hostname: test-hostname + state: query + delegate_to: localhost + register: query_hostname + + - debug: + msg: '{{query_hostname}}' + + - name: Query a device by model + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + model: MR26 + state: query + delegate_to: localhost + register: query_model + + - debug: + msg: '{{query_model}}' + + - name: Change device name for future test + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + serial: '{{serial}}' + hostname: mx60-temporary + address: 1060 W. Addison St., Chicago, IL + lat: 41.948038 + lng: -87.65568 + tags: recently-added + state: present + move_map_marker: True + note: Test device notes + delegate_to: localhost + register: update_device + + - name: Update a device + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + serial: '{{serial}}' + hostname: mx60 + address: 1060 W. Addison St., Chicago, IL + lat: 41.948038 + lng: -87.65568 + tags: recently-added + state: present + move_map_marker: True + note: Test device notes + delegate_to: localhost + register: update_device + + - assert: + that: + - update_device.changed == true + - update_device.data.0.notes == "Test device notes" + - '"1060 W. Addison St., Chicago, IL" in update_device.data.0.address' + + - name: Update a device with idempotency + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + serial: '{{serial}}' + name: mx60 + address: 1060 W. Addison St., Chicago, IL + lat: 41.948038 + lng: -87.65568 + tags: recently-added + state: present + move_map_marker: True + note: Test device notes + delegate_to: localhost + register: update_device_idempotent + + - debug: + msg: '{{update_device_idempotent}}' + + - assert: + that: + - update_device_idempotent.changed == False + - update_device_idempotent.data is defined + + always: + - name: Remove a device from a network + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + serial: '{{serial}}' + state: absent + delegate_to: localhost + register: delete_device + + - debug: + msg: '{{delete_device}}' + + - assert: + that: + - delete_device.changed == true
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/tasks/main.yml new file mode 100644 index 00000000..60aa04a9 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/tasks/main.yml @@ -0,0 +1,7 @@ +# Test code for the Meraki Firewalled Services 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: Run test cases + include: tests.yml ansible_connection=local diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/tasks/tests.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/tasks/tests.yml new file mode 100644 index 00000000..29a41f5f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_firewalled_services/tasks/tests.yml @@ -0,0 +1,212 @@ +# Test code for the Meraki modules +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + type: appliance + register: create + + - set_fact: + net_id: '{{create.data.id}}' + + - name: Set icmp service to blocked with check mode + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + service: ICMP + access: blocked + register: icmp_blocked_check + check_mode: yes + + - debug: + var: icmp_blocked_check + + - assert: + that: + - icmp_blocked_check.data is defined + - icmp_blocked_check is changed + + - name: Set icmp service to blocked + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + service: ICMP + access: blocked + register: icmp_blocked + + - debug: + var: icmp_blocked + + - assert: + that: + - icmp_blocked.data is defined + - icmp_blocked is changed + + - name: Set icmp service to blocked with idempotency + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + service: ICMP + access: blocked + register: icmp_blocked_idempotent + + - debug: + var: icmp_blocked_idempotent + + - assert: + that: + - icmp_blocked_idempotent.data is defined + - icmp_blocked_idempotent is not changed + + - name: Set icmp service to restricted with check mode + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + service: web + access: restricted + allowed_ips: + - 192.0.1.1 + - 192.0.1.2 + check_mode: yes + register: web_restricted_check + + - debug: + var: web_restricted_check + + - assert: + that: + - web_restricted_check.data is defined + - web_restricted_check is changed + + - name: Set icmp service to restricted + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + service: web + access: restricted + allowed_ips: + - 192.0.1.1 + - 192.0.1.2 + register: web_restricted + + - debug: + var: web_restricted + + - assert: + that: + - web_restricted.data is defined + - web_restricted is changed + + - name: Set icmp service to restricted with idempotency + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + service: web + access: restricted + allowed_ips: + - 192.0.1.1 + - 192.0.1.2 + register: web_restricted_idempotent + + - debug: + var: web_restricted_idempotent + + - assert: + that: + - web_restricted_idempotent.data is defined + - web_restricted_idempotent is not changed + + - name: Test error for access restricted and allowed_ips + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + service: web + access: unrestricted + allowed_ips: + - 192.0.1.1 + - 192.0.1.2 + register: access_error + ignore_errors: yes + + - assert: + that: + - 'access_error.msg == "allowed_ips is only allowed when access is restricted."' + + - name: Query appliance services with net_id + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_id: '{{net_id}}' + register: query_appliance_id + + - debug: + var: query_appliance_id + + - assert: + that: + - query_appliance_id.data is defined + + + - name: Query appliance services + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + register: query_appliance + + - debug: + var: query_appliance + + - assert: + that: + - query_appliance.data is defined + + - name: Query services + meraki_firewalled_services: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + service: ICMP + register: query_service + + - debug: + var: query_service + + - assert: + that: + - query_service.data is defined + +############################################################################# +# Tear down starts here +############################################################################# + always: + - name: Delete all networks + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/tasks/main.yml new file mode 100644 index 00000000..f671fc92 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/tasks/main.yml @@ -0,0 +1,7 @@ +# Test code for the Meraki Webhooks 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: Run test cases + include: tests.yml ansible_connection=local diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/tasks/tests.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/tasks/tests.yml new file mode 100644 index 00000000..3ac1933e --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_intrusion_prevention/tasks/tests.yml @@ -0,0 +1,312 @@ +# Test code for the Meraki IPS module +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# 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: Create test network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + type: appliance + register: net + + - debug: + var: net + + - name: Set allowed rules for organization in check mode + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + allowed_rules: + - rule_id: "meraki:intrusion/snort/GID/01/SID/5805" + message: Test rule + check_mode: yes + register: create_org_check + + - assert: + that: + - create_org_check is changed + - create_org_check.data is defined + + - name: Set allowed rules for organization + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + allowed_rules: + - rule_id: "meraki:intrusion/snort/GID/01/SID/5805" + message: Test rule + register: create_org + + - assert: + that: + - create_org is changed + - create_org.data is defined + - create_org.data.allowed_rules | length == 1 + + - name: Set allowed rules for organization with idempotency + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + allowed_rules: + - rule_id: "meraki:intrusion/snort/GID/01/SID/5805" + message: Test rule + register: create_org_idempotent + + - assert: + that: + - create_org_idempotent is not changed + - create_org_idempotent.data is defined + + - name: Query IPS info for organization + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + register: query_org + + - assert: + that: + - query_org.data.allowed_rules is defined + + - name: Set mode to prevention with check mode + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + mode: prevention + check_mode: yes + register: mode_check + + - assert: + that: + - mode_check is changed + - mode_check.data is defined + + - name: Set mode to prevention + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + mode: prevention + register: mode + + - debug: + var: mode + + - assert: + that: + - mode is changed + - mode.data.mode is defined + + - name: Set mode to prevention with idempotency + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + mode: prevention + register: mode_idempotent + + - debug: + var: mode_idempotent + + - assert: + that: + - mode_idempotent is not changed + - mode_idempotent.data.mode is defined + + - name: Set full ruleset with check mode + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + mode: prevention + ids_rulesets: security + protected_networks: + use_default: true + included_cidr: + - 192.0.1.0/24 + excluded_cidr: + - 10.0.1.0/24 + check_mode: yes + register: full_check + + - debug: + var: full_check + + - assert: + that: + - full_check is changed + - full_check.data.mode is defined + + # Meraki says protectedNetworks isn't supported on layer 3 firewalls + # Passthrough mode cannot be set via API + # - name: Set full ruleset + # meraki_intrusion_prevention: + # auth_key: '{{auth_key}}' + # state: present + # org_name: '{{test_org_name}}' + # net_name: '{{test_net_name}} - IPS' + # mode: detection + # ids_rulesets: security + # protected_networks: + # use_default: true + # included_cidr: + # - 192.0.1.0/24 + # excluded_cidr: + # - 10.0.1.0/24 + # delegate_to: localhost + # register: full + + # - debug: + # var: full + + # - assert: + # that: + # - full is changed + # - full.data.mode is defined + + # Meraki says protectedNetworks isn't supported on layer 3 firewalls + # Passthrough mode cannot be set via API + # - name: Set full ruleset with idempotency + # meraki_intrusion_prevention: + # auth_key: '{{auth_key}}' + # state: present + # org_name: '{{test_org_name}}' + # net_name: '{{test_net_name}} - IPS' + # mode: prevention + # ids_rulesets: security + # protected_networks: + # use_default: true + # included_cidr: + # - 192.0.1.0/24 + # excluded_cidr: + # - 10.0.1.0/24 + # delegate_to: localhost + # register: full_idempotent + + # - debug: + # var: full_idempotent + + # - assert: + # that: + # - full_idempotent is not changed + # - full_idempotent.data.mode is defined + + - name: Query IPS info for network + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + register: query_net + + - assert: + that: + - query_net is defined + + - name: Test use_default error with included_cidr + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + mode: prevention + ids_rulesets: security + protected_networks: + use_default: false + excluded_cidr: + - 10.0.1.0/24 + check_mode: yes + register: included_missing + ignore_errors: yes + + - assert: + that: + - 'included_missing.msg == "included_cidr is required when use_default is False."' + + - name: Test use_default error with included_cidr + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + mode: prevention + ids_rulesets: security + protected_networks: + use_default: false + included_cidr: + - 10.0.1.0/24 + check_mode: yes + register: excluded_missing + ignore_errors: yes + + - assert: + that: + - 'excluded_missing.msg == "excluded_cidr is required when use_default is False."' + + # ############################################################################# + # # Tear down starts here + # ############################################################################# + always: + - name: Delete network + meraki_network: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' + register: delete_net + + - name: Clear rules from organization with check mode + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + allowed_rules: [] + check_mode: yes + register: cleared + + - assert: + that: + - cleared is changed + - cleared.data is defined + + - name: Clear rules from organization + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + allowed_rules: [] + - name: Clear rules from organization with idempotency + meraki_intrusion_prevention: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + allowed_rules: [] + register: del_idempotent + + - assert: + that: + - del_idempotent is not changed + - del_idempotent.data is defined + + - name: Delete test network + meraki_network: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - IPS' diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_malware/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_malware/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_malware/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_malware/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_malware/tasks/main.yml new file mode 100644 index 00000000..bab98cd0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_malware/tasks/main.yml @@ -0,0 +1,253 @@ +# Test code for the Meraki VLAN 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Create test network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + type: appliance + delegate_to: localhost + register: net + + - set_fact: + net_id: '{{net.data.id}}' + + - name: Enable malware protection with check mode + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + mode: enabled + delegate_to: localhost + check_mode: yes + register: get_malware_check + + - assert: + that: + - get_malware_check is changed + - get_malware_check.data is defined + + - name: Enable malware protection + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + mode: enabled + delegate_to: localhost + register: get_malware + + - debug: + var: get_malware + + - assert: + that: + - get_malware is changed + - get_malware.data.mode is defined + + - name: Enable malware protection with idempotency + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + mode: enabled + delegate_to: localhost + register: get_malware_idempotent + + - debug: + var: get_malware_idempotent + + - assert: + that: + - get_malware_idempotent is not changed + - get_malware_idempotent.data is defined + + - name: Test error when mode is not set + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + allowed_files: + - sha256: e82c5f7d75004727e1f3b94426b9a11c8bc4c312a9170ac9a73abace40aef503 + comment: random zip + delegate_to: localhost + register: test_mode_err + ignore_errors: yes + + - assert: + that: + - test_mode_err.msg == "mode must be set when allowed_files or allowed_urls is set." + + - name: Set whitelisted file with check mode + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + mode: enabled + allowed_files: + - sha256: e82c5f7d75004727e1f3b94426b9a11c8bc4c312a9170ac9a73abace40aef503 + comment: random zip + delegate_to: localhost + check_mode: yes + register: set_file_check + + - debug: + var: + set_file_check + + - assert: + that: + - set_file_check is changed + - set_file_check.data is defined + + - name: Set whitelisted file + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{net_id}}' + mode: enabled + allowed_files: + - sha256: e82c5f7d75004727e1f3b94426b9a11c8bc4c312a9170ac9a73abace40aef503 + comment: random zip + delegate_to: localhost + register: set_file + + - debug: + var: set_file + + - assert: + that: + - set_file is changed + - set_file.data.mode is defined + + - name: Set whitelisted file with idempotency + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + mode: enabled + allowed_files: + - sha256: e82c5f7d75004727e1f3b94426b9a11c8bc4c312a9170ac9a73abace40aef503 + comment: random zip + delegate_to: localhost + register: set_file_idempotent + + - debug: + var: set_file_idempotent + + - assert: + that: + - set_file_idempotent is not changed + - set_file_idempotent.data is defined + + - name: Set whitelisted url with check mode + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + mode: enabled + allowed_urls: + - url: www.ansible.com + comment: Ansible + - url: www.google.com + comment: Google + delegate_to: localhost + check_mode: yes + register: set_url_check + + - debug: + var: + set_url_check + + - assert: + that: + - set_url_check is changed + - set_url_check.data is defined + + - name: Set whitelisted url + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + mode: enabled + allowed_urls: + - url: www.ansible.com + comment: Ansible + - url: www.google.com + comment: Google + delegate_to: localhost + register: set_url + + - debug: + var: set_url + + - assert: + that: + - set_url is changed + - set_url.data.mode is defined + + - name: Set whitelisted url with idempotency + meraki_malware: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + mode: enabled + allowed_urls: + - url: www.ansible.com + comment: Ansible + - url: www.google.com + comment: Google + delegate_to: localhost + register: set_url_idempotent + + - debug: + var: set_url_idempotent + + - assert: + that: + - set_url_idempotent is not changed + - set_url_idempotent.data is defined + + - name: Get malware settings + meraki_malware: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + delegate_to: localhost + register: get_malware + + - assert: + that: + - get_malware.data is defined + + ############################################################################# + # Tear down starts here + ############################################################################# + always: + - name: Delete test network + meraki_network: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Malware' + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_management_interface/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_management_interface/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_management_interface/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_management_interface/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_management_interface/tasks/main.yml new file mode 100644 index 00000000..28337707 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_management_interface/tasks/main.yml @@ -0,0 +1,273 @@ +# Test code for the Meraki Management Interface module +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# 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 + + - set_fact: + net_name: TestNet - Appliance + + - name: 'Create test network {{net_name}}' + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_name: '{{net_name}}' + type: appliance + delegate_to: localhost + register: net + + - set_fact: + net_id: '{{net.data.id}}' + + - name: Test providing wan_enabled to an MS network + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_id: '{{test_switch_net_name}}' + serial: '{{serial_switch}}' + wan1: + wan_enabled: enabled + using_static_ip: false + delegate_to: localhost + register: ms_not_configured + + - debug: + var: ms_not_configured + + - assert: + that: + - ms_not_configured.data is defined + + - name: Set management interface on switch + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_id: '{{test_switch_net_name}}' + serial: '{{serial_switch}}' + wan1: + using_static_ip: no + vlan: 3 + delegate_to: localhost + register: set_switch_mgmt + + - debug: + var: set_switch_mgmt + + - assert: + that: + - set_switch_mgmt.data is defined + + - name: Query non-MX network + meraki_management_interface: + auth_key: '{{auth_key}}' + state: query + org_id: '{{test_org_id}}' + net_id: '{{test_switch_net_name}}' + serial: '{{serial_switch}}' + delegate_to: localhost + register: non_mx_network + + - debug: + var: non_mx_network + + - assert: + that: + - non_mx_network.data is defined + + - name: Reset management interface on switch + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_id: '{{test_switch_net_name}}' + serial: '{{serial_switch}}' + wan1: + using_static_ip: no + vlan: 1 + delegate_to: localhost + register: reset_switch_mgmt + + - debug: + var: reset_switch_mgmt + + - assert: + that: + - reset_switch_mgmt.data is defined + + - name: Set WAN1 as DHCP in check mode + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_id: '{{net_id}}' + serial: '{{serial}}' + wan1: + wan_enabled: enabled + using_static_ip: no + vlan: 1 + delegate_to: localhost + register: set_wan1_check + check_mode: yes + + - debug: + var: set_wan1_check + + - assert: + that: + - set_wan1_check is changed + - set_wan1_check.data is defined + + - name: Set WAN1 as DHCP + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_id: '{{net_id}}' + serial: '{{serial}}' + wan1: + wan_enabled: enabled + using_static_ip: no + vlan: 1 + delegate_to: localhost + register: set_wan1 + + - debug: + var: set_wan1 + + - assert: + that: + - set_wan1 is changed + - set_wan1.data is defined + + - name: Set WAN1 as DHCP with idempotency + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_id: '{{net_id}}' + serial: '{{serial}}' + wan1: + wan_enabled: enabled + using_static_ip: no + vlan: 1 + delegate_to: localhost + register: set_wan1_idempotent + + - debug: + var: set_wan1_idempotent + + - assert: + that: + - set_wan1_idempotent is not changed + - set_wan1_idempotent.data is defined + + - name: Set WAN2 as static IP + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{net_id}}' + serial: '{{serial}}' + wan2: + wan_enabled: enabled + using_static_ip: yes + static_ip: 192.168.16.195 + static_gateway_ip: 192.168.16.1 + static_subnet_mask: 255.255.255.0 + static_dns: + - 1.1.1.1 + vlan: 1 + delegate_to: localhost + register: set_wan2 + + - debug: + var: set_wan2 + + - assert: + that: + - set_wan2 is changed + - set_wan2.data is defined + + - name: Test too many DNS servers + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_id: '{{net_id}}' + serial: '{{serial}}' + wan1: + wan_enabled: enabled + using_static_ip: yes + static_ip: 192.0.1.2 + static_gateway_ip: 192.0.1.1 + static_subnet_mask: 255.255.255.0 + static_dns: + - 1.1.1.1 + - 8.8.8.8 + - 4.4.4.4 + vlan: 1 + delegate_to: localhost + register: too_many_dns + ignore_errors: yes + + - debug: + var: too_many_dns + + - assert: + that: + - 'too_many_dns.msg == "Maximum number of static DNS addresses is 2."' + + - name: Query management information + meraki_management_interface: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_id: '{{net_id}}' + serial: '{{serial}}' + delegate_to: localhost + register: query_mx + + - debug: + var: query_mx + + - assert: + that: + - query_mx.data is defined + + always: + ############################################################################ + # Tear down starts here + ############################################################################ + - name: Reset settings for all interfaces + meraki_management_interface: + auth_key: '{{auth_key}}' + state: present + org_id: '{{test_org_id}}' + net_id: '{{net_id}}' + serial: '{{serial}}' + wan1: + wan_enabled: disabled + using_static_ip: no + wan2: + wan_enabled: enabled + using_static_ip: no + delegate_to: localhost + ignore_errors: yes + + # Network deletion is commented out since this requires a device in a network + # - name: Delete network + # meraki_network: + # auth_key: '{{auth_key}}' + # state: absent + # org_name: '{{test_org_name}}' + # net_name: '{{net_name}}' + # delegate_to: localhost + # register: delete_network diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_l3_firewall/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_l3_firewall/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_l3_firewall/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_l3_firewall/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_l3_firewall/tasks/main.yml new file mode 100644 index 00000000..a267e15f --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_l3_firewall/tasks/main.yml @@ -0,0 +1,171 @@ +# Test code for the Meraki modules +# Copyright: (c) 2018, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create wireless network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: TestNetWireless + type: wireless + delegate_to: localhost + register: new_net + + - set_fact: + net: '{{new_net.data.id}}' + + - name: Create single firewall rule with check mode + meraki_mr_l3_firewall: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{net}}' + number: 1 + rules: + - comment: Integration test rule + policy: allow + protocol: tcp + dest_port: 80 + dest_cidr: 192.0.2.0/24 + allow_lan_access: no + delegate_to: localhost + check_mode: yes + register: create_one_check + + - debug: + msg: '{{create_one_check}}' + + - assert: + that: + - create_one_check.data.0.comment == 'Integration test rule' + - create_one_check.data.1.policy == 'deny' + - create_one_check.data is defined + - create_one_check is changed + + - name: Create single firewall rule + meraki_mr_l3_firewall: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{net}}' + number: 1 + rules: + - comment: Integration test rule + policy: allow + protocol: tcp + dest_port: 80 + dest_cidr: 192.0.2.0/24 + allow_lan_access: no + delegate_to: localhost + register: create_one + + - debug: + msg: '{{create_one}}' + + - assert: + that: + - create_one.data.rules.0.comment == 'Integration test rule' + - create_one.data.rules.1.policy == 'deny' + - create_one.data is defined + + - name: Enable local LAN access with check mode + meraki_mr_l3_firewall: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{net}}' + number: 1 + allow_lan_access: yes + delegate_to: localhost + check_mode: yes + register: enable_lan_check + + - debug: + var: enable_lan_check + + - assert: + that: + - enable_lan_check.data.rules.1.policy == 'allow' + - enable_lan_check is changed + + - name: Enable local LAN access + meraki_mr_l3_firewall: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{net}}' + number: 1 + allow_lan_access: yes + delegate_to: localhost + register: enable_lan + + - assert: + that: + - enable_lan.data.rules.1.policy == 'allow' + + - name: Update rules without specifying LAN access with check mode + meraki_mr_l3_firewall: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{net}}' + number: 1 + rules: + - comment: Integration test rule + policy: allow + protocol: tcp + dest_port: 8080 + dest_cidr: 192.0.2.0/24 + delegate_to: localhost + register: update_one_check + + - debug: + msg: '{{update_one_check}}' + + - assert: + that: + - update_one_check.data.rules.0.comment == 'Integration test rule' + - update_one_check.data is defined + + - name: Query firewall rules + meraki_mr_l3_firewall: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_id: '{{net}}' + number: 1 + delegate_to: localhost + register: query + + - debug: + msg: '{{query}}' + + - assert: + that: + - query.data.rules.1.comment == 'Wireless clients accessing LAN' + - query.data.rules.2.comment == 'Default rule' + - query.changed == False + +############################################################################ +# Tear down starts here +############################################################################ + always: + - name: Delete wireless SSID + meraki_ssid: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_id: '{{net}}' + number: 1 + delegate_to: localhost + + - name: Delete wireless network + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_id: '{{net}}' + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_rf_profile/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_rf_profile/aliases new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_rf_profile/aliases diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_rf_profile/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_rf_profile/tasks/main.yml new file mode 100644 index 00000000..3c78022b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_rf_profile/tasks/main.yml @@ -0,0 +1,271 @@ +# Test code for the Meraki modules +# Copyright: (c) 2020, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network with type wireless + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + type: wireless + timezone: America/Chicago + delegate_to: localhost + + - name: Create RF profile in check mode + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + name: Test Profile + band_selection_type: ap + client_balancing_enabled: True + ap_band_settings: + mode: dual + band_steering_enabled: true + five_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -65 + channel_width: 20 + valid_auto_channels: + - 36 + - 40 + - 44 + two_four_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -65 + ax_enabled: false + valid_auto_channels: + - 1 + delegate_to: localhost + register: create_check + check_mode: true + + - assert: + that: + - create_check.data is defined + - create_check is changed + + - name: Create RF profile + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + name: Test Profile + band_selection_type: ap + client_balancing_enabled: True + ap_band_settings: + mode: dual + band_steering_enabled: true + five_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -65 + channel_width: 20 + valid_auto_channels: + - 36 + - 40 + - 44 + two_four_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -65 + ax_enabled: false + valid_auto_channels: + - 1 + delegate_to: localhost + register: create + + - set_fact: + profile_id: '{{ create.data.id }}' + + - name: Query all RF profiles + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: query + delegate_to: localhost + register: query_one + + - assert: + that: + - query_one.data is defined + + - name: Update profile with check mode + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + profile_id: '{{ profile_id }}' + band_selection_type: ap + client_balancing_enabled: True + ap_band_settings: + mode: dual + band_steering_enabled: true + five_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -65 + channel_width: 20 + valid_auto_channels: + - 36 + - 44 + two_four_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -75 + ax_enabled: false + valid_auto_channels: + - 1 + delegate_to: localhost + register: update_check + check_mode: true + + - assert: + that: + - update_check.data is defined + - update_check is changed + + - name: Update profile + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + profile_id: '{{ profile_id }}' + band_selection_type: ap + client_balancing_enabled: True + ap_band_settings: + mode: dual + band_steering_enabled: true + five_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -65 + channel_width: 20 + valid_auto_channels: + - 36 + - 44 + two_four_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -75 + ax_enabled: false + valid_auto_channels: + - 1 + delegate_to: localhost + register: update + + - assert: + that: + - update.data is defined + - update is changed + + - name: Update profile with idempotency + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + profile_id: '{{ profile_id }}' + band_selection_type: ap + client_balancing_enabled: True + ap_band_settings: + mode: dual + band_steering_enabled: true + five_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -65 + channel_width: 20 + valid_auto_channels: + - 36 + - 44 + two_four_ghz_settings: + max_power: 10 + min_bitrate: 12 + min_power: 8 + rxsop: -75 + ax_enabled: false + valid_auto_channels: + - 1 + delegate_to: localhost + register: update_idempotent + + - assert: + that: + - update_idempotent.data is defined + - update_idempotent is not changed + + - name: Query one RF profile by ID + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: query + profile_id: '{{ profile_id }}' + delegate_to: localhost + register: query_one_id + + - assert: + that: + - query_one_id.data is defined + + - name: Query one RF profile by name + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: query + name: Test Profile + delegate_to: localhost + register: query_one_name + + - assert: + that: + - query_one_name.data is defined + + - name: Delete RF profile + meraki_mr_rf_profile: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: absent + profile_id: '{{ profile_id }}' + delegate_to: localhost + register: delete + + - assert: + that: + - delete.data is defined + - delete is changed + +############################################################################# +# Tear down starts here +############################################################################# + + always: + - name: Delete network + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_settings/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_settings/aliases new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_settings/aliases diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_settings/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_settings/tasks/main.yml new file mode 100644 index 00000000..c2cfed8d --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mr_settings/tasks/main.yml @@ -0,0 +1,102 @@ +# Test code for the Meraki modules +# Copyright: (c) 2020, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network with type wireless + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + type: wireless + timezone: America/Chicago + delegate_to: localhost + + - name: Query all settings + meraki_mr_settings: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: query + delegate_to: localhost + register: query_all + + - debug: + var: query_all + + - assert: + that: + - query_all.data is defined + + - name: Configure settings with check mode + meraki_mr_settings: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + upgrade_strategy: minimize_upgrade_time + ipv6_bridge_enabled: false + led_lights_on: true + location_analytics_enabled: true + meshing_enabled: true + delegate_to: localhost + register: settings_check + check_mode: true + + - assert: + that: + - settings_check.data is defined + - settings_check is changed + + - name: Configure settings + meraki_mr_settings: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + upgrade_strategy: minimize_upgrade_time + ipv6_bridge_enabled: false + led_lights_on: true + location_analytics_enabled: true + meshing_enabled: true + delegate_to: localhost + register: settings + + - assert: + that: + - settings.data is defined + - settings is changed + + - name: Configure settings with idempotency + meraki_mr_settings: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + state: present + upgrade_strategy: minimize_upgrade_time + ipv6_bridge_enabled: false + led_lights_on: true + location_analytics_enabled: true + meshing_enabled: true + delegate_to: localhost + register: settings_idempotent + + - assert: + that: + - settings_idempotent.data is defined + - settings_idempotent is not changed + +############################################################################# +# Tear down starts here +############################################################################# + + always: + - name: Delete network + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_l3_interface/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_l3_interface/tasks/main.yml new file mode 100644 index 00000000..b32135cd --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_l3_interface/tasks/main.yml @@ -0,0 +1,236 @@ +# Test code for the Meraki modules +# Copyright: (c) 2018, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network with type switch + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + type: switch + timezone: America/Chicago + delegate_to: localhost + register: create_net_switch + + - name: Claim a device into a network + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + serial: '{{ serial_switch_l3 }}' + state: present + delegate_to: localhost + + - name: Query all l3 interfaces + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: query + serial: '{{ serial_switch_l3 }}' + delegate_to: localhost + register: query_all + + - set_fact: + interface_id_1: '{{query_all.data.1.interface_id}}' + ignore_errors: true + + - assert: + that: + - query_all.data is defined + - query_all.data | length > 0 + + - name: Query one l3 interface + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: query + serial: '{{ serial_switch_l3 }}' + name: Test L3 interface + delegate_to: localhost + register: query_one + + - assert: + that: + - query_one.data is defined + + - name: Create l3 interface in check mode + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: present + serial: '{{ serial_switch_l3 }}' + name: "Test L3 interface 2" + subnet: "192.168.3.0/24" + interface_ip: "192.168.3.2" + multicast_routing: disabled + vlan_id: 11 + # default_gateway: "192.168.2.1" + ospf_settings: + area: 0 + cost: 1 + is_passive_enabled: true + delegate_to: localhost + check_mode: true + register: create_check + + - assert: + that: + - create_check.data is defined + - create_check is changed + + - name: Create l3 interface + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: present + serial: '{{ serial_switch_l3 }}' + name: "Test L3 interface 2" + subnet: "192.168.3.0/24" + interface_ip: "192.168.3.2" + multicast_routing: disabled + vlan_id: 11 + # default_gateway: "192.168.2.1" + ospf_settings: + area: 0 + cost: 1 + is_passive_enabled: true + delegate_to: localhost + register: create + + - set_fact: + interface_id_1: '{{create.data.interface_id}}' + + - assert: + that: + - create.data is defined + - create is changed + + - name: Update l3 interface with check mode + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: present + serial: '{{ serial_switch_l3 }}' + name: "Test L3 interface 2" + subnet: "192.168.3.0/24" + interface_ip: "192.168.3.2" + multicast_routing: disabled + vlan_id: 11 + ospf_settings: + area: 0 + cost: 2 + is_passive_enabled: false + delegate_to: localhost + register: update_check + check_mode: true + + - assert: + that: + - update_check.data is defined + - update_check is changed + + - name: Update l3 interface + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: present + serial: '{{ serial_switch_l3 }}' + name: "Test L3 interface 2" + subnet: "192.168.3.0/24" + interface_ip: "192.168.3.2" + multicast_routing: disabled + vlan_id: 11 + ospf_settings: + area: 0 + cost: 2 + is_passive_enabled: false + delegate_to: localhost + register: update + + - assert: + that: + - update.data is defined + - update is changed + + - name: Update l3 interface idempotent + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: present + serial: '{{ serial_switch_l3 }}' + name: "Test L3 interface 2" + subnet: "192.168.3.0/24" + interface_ip: "192.168.3.2" + multicast_routing: disabled + vlan_id: 11 + ospf_settings: + area: 0 + cost: 2 + is_passive_enabled: false + delegate_to: localhost + register: update_idempotent + + - assert: + that: + update_idempotent is not changed + + - name: Update l3 interface idempotent with check mode + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: present + serial: '{{ serial_switch_l3 }}' + name: "Test L3 interface 2" + subnet: "192.168.3.0/24" + interface_ip: "192.168.3.2" + multicast_routing: disabled + vlan_id: 11 + ospf_settings: + area: 0 + cost: 2 + is_passive_enabled: false + delegate_to: localhost + register: update_idempotent_check + check_mode: true + + - assert: + that: + update_idempotent_check is not changed + + +############################################################################# +# Tear down starts here +############################################################################# + + always: + - name: Delete l3 interface with check mode + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: absent + serial: '{{ serial_switch_l3 }}' + interface_id: '{{ item }}' + delegate_to: localhost + check_mode: true + register: delete_check + loop: + - '{{interface_id_1}}' + + - assert: + that: + - delete_check is changed + + - name: Delete l3 interface + meraki_ms_l3_interface: + auth_key: '{{ auth_key }}' + state: absent + serial: '{{ serial_switch_l3 }}' + interface_id: '{{ interface_id_1 }}' + delegate_to: localhost + register: delete + + - assert: + that: + - delete is changed + + # - name: Delete network + # meraki_network: + # auth_key: '{{ auth_key }}' + # state: absent + # org_name: '{{test_org_name}}' + # net_name: IntTestNetworkSwitch + # delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/meraki_network/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/meraki_network/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/meraki_network/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/meraki_network/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/meraki_network/tasks/main.yml new file mode 100644 index 00000000..37264abb --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/meraki_network/tasks/main.yml @@ -0,0 +1,473 @@ +# Test code for the Meraki modules +# Copyright: (c) 2018, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network without type + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + timezone: America/Chicago + delegate_to: localhost + register: create_net_no_type + ignore_errors: yes + + - assert: + that: + - create_net_no_type.msg == 'type parameter is required when creating a network.' + + - name: Create network without organization + meraki_network: + auth_key: '{{ auth_key }}' + state: present + net_name: IntTestNetwork + timezone: America/Chicago + delegate_to: localhost + register: create_net_no_org + ignore_errors: yes + + - name: Create network with type switch with check mode + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + type: switch + timezone: America/Chicago + delegate_to: localhost + check_mode: yes + register: create_net_switch_check + + - debug: + var: create_net_switch_check + + - debug: + var: create_net_switch_check.data.organization_id + + - assert: + that: + - create_net_switch_check is changed + - create_net_switch_check.data is defined + - create_net_switch_check.data.organization_id == "{{test_org_id |string}}" + + - name: Create network with type switch + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + type: switch + timezone: America/Chicago + delegate_to: localhost + register: create_net_switch + + - name: Create network with type switch by org ID + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_id: '{{test_org_id}}' + net_name: IntTestNetworkSwitchOrgID + type: switch + timezone: America/Chicago + delegate_to: localhost + register: create_net_switch_org_id + + - name: Create network with type appliance and no timezone + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + type: appliance + delegate_to: localhost + register: create_net_appliance_no_tz + + - name: Enable VLAN support on appliance network with check mode + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: yes + delegate_to: localhost + check_mode: yes + register: enable_vlan_check + + - assert: + that: + - enable_vlan_check.data.enabled == True + - enable_vlan_check is changed + + - name: Enable VLAN support on appliance network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: yes + delegate_to: localhost + register: enable_vlan + + - assert: + that: + - enable_vlan.data.enabled == True + + - name: Enable VLAN support on appliance network with idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: yes + delegate_to: localhost + register: enable_vlan_idempotent + + - debug: + var: enable_vlan_idempotent + + - assert: + that: + - enable_vlan_idempotent is not changed + - enable_vlan_idempotent.data is defined + + - name: Disable VLAN support on appliance network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: no + delegate_to: localhost + register: disable_vlan + + - assert: + that: + - disable_vlan.data.enabled == False + + - name: Disable VLAN support on appliance network with idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: no + delegate_to: localhost + register: disable_vlan_idempotent + + - assert: + that: + - disable_vlan_idempotent is not changed + - disable_vlan_idempotent.data is defined + + - name: Create network with type wireless and disable my.meraki.com + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + type: wireless + timezone: America/Chicago + disable_my_meraki: yes + delegate_to: localhost + register: create_net_wireless + + - name: Create network with type wireless, disable my.meraki.com, and check for idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + type: wireless + timezone: America/Chicago + disable_my_meraki: yes + delegate_to: localhost + register: create_net_wireless_idempotent + + - assert: + that: + - create_net_wireless_idempotent.data is defined + + - name: Create network with type combined and disable my.meraki.com + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkCombined + type: + - appliance + - switch + timezone: America/Chicago + enable_my_meraki: no + delegate_to: localhost + register: create_net_combined + + - name: Reenable my.meraki.com with check mode + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkCombined + enable_my_meraki: yes + delegate_to: localhost + register: enable_meraki_com_check + check_mode: yes + + - assert: + that: + - enable_meraki_com_check is changed + - enable_meraki_com_check.data is defined + + - name: Reenable my.meraki.com + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkCombined + enable_my_meraki: yes + delegate_to: localhost + register: enable_meraki_com + + - name: Disable my.meraki.com for next test + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkCombined + enable_my_meraki: no + delegate_to: localhost + + - name: Enable remote status page + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkCombined + enable_remote_status_page: yes + delegate_to: localhost + register: disable_remote_status + + - debug: + msg: '{{disable_remote_status}}' + + - assert: + that: + - disable_remote_status.data.disable_remote_status_page == False + + - name: Disable remote status page + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkCombined + enable_remote_status_page: no + delegate_to: localhost + register: enable_remote_status + + - debug: + msg: '{{enable_remote_status}}' + + - assert: + that: + - enable_remote_status.data.disable_remote_status_page == True + + - name: Test status pages are mutually exclusive when on + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkCombined + enable_my_meraki: yes + enable_remote_status_page: no + delegate_to: localhost + register: status_exclusivity + ignore_errors: yes + + - assert: + that: + - '"must be true when setting" in status_exclusivity.msg' + + - name: Create network with one tag + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkTag + type: switch + timezone: America/Chicago + tags: first_tag + delegate_to: localhost + register: create_net_tag + + - name: Create network with two tags + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkTags + type: switch + timezone: America/Chicago + tags: + - first_tag + - second_tag + delegate_to: localhost + register: create_net_tags + + - set_fact: + tag_net_id: '{{create_net_tags.data.id}}' + + - name: Modify network by net_id + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{tag_net_id}}' + type: switch + timezone: America/Chicago + tags: + - first_tag + - second_tag + - third_tag + delegate_to: localhost + register: create_net_modified + + - name: Modify network with idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkTags + type: switch + timezone: America/Chicago + tags: + - first_tag + - second_tag + - third_tag + delegate_to: localhost + register: create_net_modified_idempotent + + - assert: + that: + - create_net_modified_idempotent.data is defined + + - name: Present assertions + assert: + that: + - create_net_combined.data.type == 'combined' + - create_net_combined.data.disable_my_meraki_com == True + - enable_meraki_com.data.disable_my_meraki_com == False + - '"org_name or org_id parameters are required" in create_net_no_org.msg' + - '"IntTestNetworkAppliance" in create_net_appliance_no_tz.data.name' + - create_net_appliance_no_tz.changed == True + - '"IntTestNetworkSwitch" in create_net_switch.data.name' + - '"IntTestNetworkSwitchOrgID" in create_net_switch_org_id.data.name' + - '"IntTestNetworkWireless" in create_net_wireless.data.name' + - create_net_wireless.data.disable_my_meraki_com == True + - create_net_wireless_idempotent.changed == False + - create_net_wireless_idempotent.data is defined + - '"first_tag" in create_net_tag.data.tags' + - '"second_tag" in create_net_tags.data.tags' + - '"third_tag" in create_net_modified.data.tags' + - create_net_modified.changed == True + - create_net_modified_idempotent.changed == False + - create_net_modified_idempotent.data is defined + + - name: Query all networks + meraki_network: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + delegate_to: localhost + register: net_query_all + + - name: Query a configuration template + meraki_network: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_template_name}}' + delegate_to: localhost + register: query_config_template + + - name: Query one network + meraki_network: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + delegate_to: localhost + register: net_query_one + + - name: Query assertions + assert: + that: + - 'net_query_one.data.name == "IntTestNetworkSwitch"' + - 'query_config_template.data.name == "{{ test_template_name }}"' + +############################################################################# +# Tear down starts here +############################################################################# + always: + - name: Delete network without org + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + net_name: IntTestNetworkSwitch + delegate_to: localhost + register: delete_all_no_org + ignore_errors: yes + + - name: Delete network by org ID and check mode + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_id: '{{test_org_id}}' + net_name: IntTestNetworkSwitchOrgID + delegate_to: localhost + check_mode: yes + register: delete_net_org_id_check + + - assert: + that: + - delete_net_org_id_check is changed + - delete_net_org_id_check.data is defined + + - name: Delete network by org ID + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_id: '{{test_org_id}}' + net_name: IntTestNetworkSwitchOrgID + delegate_to: localhost + register: delete_net_org_id + + - name: Query after delete with org ID + meraki_network: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + delegate_to: localhost + register: query_deleted_org_id + + - name: Delete all networks + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{ item }}' + delegate_to: localhost + register: delete_all + ignore_errors: yes + loop: + - IntTestNetworkSwitch + - IntTestNetworkWireless + - IntTestNetworkAppliance + - IntTestNetworkCombined + - IntTestNetworkTag + - IntTestNetworkTags + + - assert: + that: + - 'delete_all_no_org.msg == "org_name or org_id parameters are required"' diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/tasks/main.yml new file mode 100644 index 00000000..e7e3b96b --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_link_aggregation/tasks/main.yml @@ -0,0 +1,124 @@ +# Test code for the Meraki MS Link Aggregation 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Create test network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + type: switch + register: test_net + + - name: Add device to network + meraki_device: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + serial: '{{serial_switch}}' + delegate_to: localhost + + - name: Create LAG + meraki_ms_link_aggregation: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + switch_ports: + - serial: '{{serial_switch}}' + port_id: "1" + - serial: '{{serial_switch}}' + port_id: "2" + delegate_to: localhost + register: create_ports + + - debug: + var: create_ports + + - set_fact: + lag_id: '{{create_ports.data.id}}' + + - name: Update LAG + meraki_ms_link_aggregation: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + lag_id: '{{lag_id}}' + switch_ports: + - serial: '{{serial_switch}}' + port_id: "1" + - serial: '{{serial_switch}}' + port_id: "2" + - serial: '{{serial_switch}}' + port_id: "3" + - serial: '{{serial_switch}}' + port_id: "4" + delegate_to: localhost + register: update_ports + + - assert: + that: + - update_ports is changed + + - name: Update LAG with idempotency + meraki_ms_link_aggregation: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + lag_id: '{{lag_id}}' + switch_ports: + - serial: '{{serial_switch}}' + port_id: "1" + - serial: '{{serial_switch}}' + port_id: "2" + - serial: '{{serial_switch}}' + port_id: "3" + - serial: '{{serial_switch}}' + port_id: "4" + delegate_to: localhost + register: update_ports_idempotent + + - assert: + that: + - update_ports_idempotent is not changed + + - name: Query all LAGs + meraki_ms_link_aggregation: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + delegate_to: localhost + register: query_all + + - debug: + var: query_all + + always: + - name: Delete LAG + meraki_ms_link_aggregation: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + lag_id: '{{lag_id}}' + delegate_to: localhost + + # - name: Delete test network + # meraki_network: + # auth_key: '{{auth_key}}' + # state: absent + # org_name: '{{test_org_name}}' + # net_name: '{{test_switch_net_name}}' + # register: delete_net diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_ospf/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_ospf/tasks/main.yml new file mode 100644 index 00000000..c941f85c --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ms_ospf/tasks/main.yml @@ -0,0 +1,136 @@ +# Test code for the Meraki modules +# Copyright: (c) 2018, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network with type switch + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + type: switch + timezone: America/Chicago + delegate_to: localhost + register: create_net_switch + + - name: Claim a device into a network + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + serial: '{{serial_switch_l3}}' + state: present + delegate_to: localhost + + - name: Query OSPF settings + meraki_ms_ospf: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + state: query + delegate_to: localhost + register: query_all + + + - assert: + that: + - query_all.data is defined + + - name: Enable OSPF with check mode + meraki_ms_ospf: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + state: present + enabled: true + hello_timer: 20 + dead_timer: 60 + areas: + - area_id: 0 + area_name: Backbone + area_type: normal + - area_id: 1 + area_name: Office + area_type: nssa + md5_authentication_enabled: true + md5_authentication_key: + id: 1 + passphrase: 'secretpass' + check_mode: true + register: enable_check_mode + + - assert: + that: + - enable_check_mode.data is defined + + - name: Enable OSPF + meraki_ms_ospf: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + state: present + enabled: true + hello_timer: 20 + dead_timer: 60 + areas: + - area_id: 0 + area_name: Backbone + area_type: normal + - area_id: 1 + area_name: Office + area_type: nssa + md5_authentication_enabled: true + md5_authentication_key: + id: 1 + passphrase: 'secretpass' + register: enable + + - assert: + that: + - enable.data is defined + + - name: Enable OSPF with idempotency + meraki_ms_ospf: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + state: present + enabled: true + hello_timer: 20 + dead_timer: 60 + areas: + - area_id: 0 + area_name: Backbone + area_type: normal + - area_id: 1 + area_name: Office + area_type: nssa + md5_authentication_enabled: true + md5_authentication_key: + id: 1 + passphrase: 'secretpass' + delegate_to: localhost + register: enable_ospf_idempotent + + - debug: + var: enable_ospf_idempotent + + - assert: + that: + - enable_ospf_idempotent is not changed + - enable_ospf_idempotent.data is defined + +############################################################################# +# Tear down starts here +############################################################################# + + # always: + # - name: Delete network + # meraki_network: + # auth_key: '{{ auth_key }}' + # state: absent + # org_name: '{{test_org_name}}' + # net_name: IntTestNetworkSwitch + # delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l2_interface/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l2_interface/tasks/main.yml new file mode 100644 index 00000000..3a142b2a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l2_interface/tasks/main.yml @@ -0,0 +1,155 @@ +# Test code for the Meraki modules +# Copyright: (c) 2018, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network with type appliance + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + type: appliance + timezone: America/Chicago + delegate_to: localhost + register: create_net + + - name: Claim a device into a network + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + serial: '{{serial_appliance}}' + state: present + delegate_to: localhost + + - name: Enable VLAN support on appliance network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: '{{test_appliance_net_name}}' + enable_vlans: yes + delegate_to: localhost + + - name: Create a VLAN + meraki_vlan: + auth_key: '{{ auth_key }}' + org_name: '{{ test_org_name }}' + net_name: '{{test_appliance_net_name}}' + state: present + vlan_id: 10 + name: TestVLAN + subnet: 192.0.10.0/24 + appliance_ip: 192.0.10.1 + delegate_to: localhost + + - name: Query layer 2 interface settings + meraki_mx_l2_interface: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + state: query + delegate_to: localhost + register: query_all + + - assert: + that: + - query_all.data is defined + + - name: Query a single layer 2 interface settings + meraki_mx_l2_interface: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + state: query + number: 2 + delegate_to: localhost + register: query_one + + - assert: + that: + - query_one.data is defined + + - name: Update interface configuration with check mode + meraki_mx_l2_interface: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + state: present + number: 2 + port_type: access + vlan: 10 + delegate_to: localhost + register: update_check + check_mode: yes + + - debug: + var: update_check + + - assert: + that: + - update_check.data is defined + - update_check.data.vlan == 10 + - update_check is changed + + - name: Update interface configuration + meraki_mx_l2_interface: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + state: present + number: 2 + port_type: access + vlan: 10 + delegate_to: localhost + register: update + + - assert: + that: + - update.diff is defined + - update.data is defined + - update.data.vlan == 10 + - update is changed + + - name: Update interface configuration with idempotency + meraki_mx_l2_interface: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + state: present + number: 2 + port_type: access + vlan: 10 + delegate_to: localhost + register: update_idempotent + + - assert: + that: + - update_idempotent.data is defined + - update_idempotent.data.vlan == 10 + - update_idempotent is not changed + + +############################################################################# +# Tear down starts here +############################################################################# + + always: + - name: Remove device from network + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + serial: '{{serial_appliance}}' + state: absent + delegate_to: localhost + + - name: Delete network + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_appliance_net_name}}' + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l3_firewall/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l3_firewall/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l3_firewall/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l3_firewall/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l3_firewall/tasks/main.yml new file mode 100644 index 00000000..2e4ddc62 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l3_firewall/tasks/main.yml @@ -0,0 +1,351 @@ +# 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Create network + meraki_network: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + type: appliance + delegate_to: localhost + + - name: Query firewall rules + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: query + delegate_to: localhost + register: query + + - assert: + that: + - query.data|length == 1 + + - name: Set one firewall rule with check mode + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + delegate_to: localhost + check_mode: yes + register: create_one_check + + - debug: + var: create_one_check + + - assert: + that: + - create_one_check.data|length == 2 + - create_one_check.data.0.dest_cidr == '192.0.1.1/32' + - create_one_check.data.0.protocol == 'tcp' + - create_one_check.data.0.policy == 'deny' + - create_one_check is changed + - create_one_check.data is defined + + - name: Set one firewall rule + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_id: '{{test_org_id}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + delegate_to: localhost + register: create_one + + - debug: + var: create_one + + - assert: + that: + - create_one.data.rules|length == 2 + - create_one.data.rules.0.dest_cidr == '192.0.1.1/32' + - create_one.data.rules.0.protocol == 'tcp' + - create_one.data.rules.0.policy == 'deny' + - create_one.changed == True + - create_one.data is defined + + - name: Check for idempotency + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + delegate_to: localhost + register: create_one_idempotent + + - debug: + msg: '{{create_one_idempotent}}' + + - assert: + that: + - create_one_idempotent.changed == False + - create_one_idempotent.data is defined + + - name: Update one existing rule + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny all documentation addresses + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32,192.0.1.2/32 + protocol: tcp + policy: deny + delegate_to: localhost + register: update_one + + - debug: + msg: '{{update_one}}' + + - assert: + that: + - update_one.changed == True + - update_one.data is defined + + - name: Create syslog in network + meraki_syslog: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + servers: + - host: 192.0.2.10 + port: 514 + roles: + - Appliance event log + - Flows + delegate_to: localhost + + - name: Enable syslog for default rule with check mode + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + syslog_default_rule: yes + delegate_to: localhost + check_mode: yes + register: default_syslog_check + + - debug: + msg: '{{default_syslog_check}}' + + - assert: + that: + - default_syslog_check.data is defined + - default_syslog_check.data.1.syslog_enabled == True + + + - name: Enable syslog for default rule + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + syslog_default_rule: yes + delegate_to: localhost + register: default_syslog + + - debug: + msg: '{{default_syslog}}' + + - assert: + that: + - default_syslog.data is defined + + - name: Set protocol to any for idempotency check + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny to documentation address + src_port: any + src_cidr: any + dest_port: any + dest_cidr: 192.0.1.1/32 + protocol: any + policy: deny + delegate_to: localhost + + - name: Check for protocol any idempotency + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny to documentation address + src_port: any + src_cidr: any + dest_port: any + dest_cidr: 192.0.1.1/32 + protocol: any + policy: deny + delegate_to: localhost + register: any_idempotency + + - assert: + that: + - any_idempotency is not changed + + - name: Query firewall rules + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: query + delegate_to: localhost + register: query + + - assert: + that: + - query.data.rules.1.syslog_enabled == True + - default_syslog.changed == True + + - name: Disable syslog for default rule + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + syslog_default_rule: no + delegate_to: localhost + register: disable_syslog + + - debug: + msg: '{{disable_syslog}}' + + - assert: + that: + - disable_syslog.data is defined + + - name: Query firewall rules + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: query + delegate_to: localhost + register: query + + - debug: + msg: '{{query}}' + + - name: Enable syslog for default rule with no rules and with check mode + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + syslog_default_rule: yes + delegate_to: localhost + check_mode: yes + register: enable_syslog_only_check + + - debug: + msg: '{{enable_syslog_only_check}}' + + - assert: + that: + - enable_syslog_only_check.data.rules.1.syslog_enabled == True + - enable_syslog_only_check is changed + + - name: Query firewall rules + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: query + delegate_to: localhost + register: query + + - debug: + msg: '{{query.data.rules.1}}' + + - assert: + that: + - query.data.rules.1.syslog_enabled == False + - disable_syslog.changed == True + + always: + - name: Delete all firewall rules + meraki_mx_l3_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: [] + delegate_to: localhost + register: delete_all + + - name: Delete network + meraki_network: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: absent + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/aliases new file mode 100644 index 00000000..06fe32bc --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/aliases @@ -0,0 +1,2 @@ +unsupported + diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/tasks/main.yml new file mode 100644 index 00000000..bb4c6fc5 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/tasks/main.yml @@ -0,0 +1,7 @@ +# 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: Run test cases + include: tests.yml ansible_connection=local
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/tasks/tests.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/tasks/tests.yml new file mode 100644 index 00000000..1b0e8dde --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_l7_firewall/tasks/tests.yml @@ -0,0 +1,494 @@ +# 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Create network + meraki_network: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + type: appliance + + - name: Query firewall rules + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: query + register: query + + - debug: + var: query + + - assert: + that: + - query.data is defined + + - name: Query firewall application categories + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: query + categories: yes + register: query_categories + + - assert: + that: + - query_categories.data is defined + + - name: Create firewall rule for IP range in check mode + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: ip_range + ip_range: 10.11.12.0/24 + register: create_ip_range_check + check_mode: yes + + - debug: + var: create_ip_range_check + + - assert: + that: + - create_ip_range_check is changed + + - name: Create firewall rule for IP range + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: ip_range + ip_range: 10.11.12.0/24 + register: create_ip_range + + - debug: + var: create_ip_range + + - assert: + that: + - create_ip_range is changed + - create_ip_range.data.rules | length == 1 + + - name: Create firewall rule for IP range with idempotency with check mode + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: ip_range + ip_range: 10.11.12.0/24 + register: create_ip_range_idempotent_check + check_mode: yes + + - assert: + that: + - create_ip_range_idempotent_check is not changed + + - name: Create firewall rule for IP range with idempotency + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: ip_range + ip_range: 10.11.12.0/24 + register: create_ip_range_idempotent + + - assert: + that: + - create_ip_range_idempotent is not changed + + - name: Create firewall rule for IP and port + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: ip_range + ip_range: 10.11.12.1:23 + register: create_ip_range_port + + - debug: + var: create_ip_range_port + + - assert: + that: + - create_ip_range_port is changed + + - name: Create firewall rule for IP range + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: ip_range + ip_range: 10.11.12.0/24 + register: create_ip_range + + - debug: + var: create_ip_range + + - assert: + that: + - create_ip_range is changed + - create_ip_range.data.rules | length == 1 + + - name: Create firewall rule for IP range with idempotency with check mode + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: ip_range + ip_range: 10.11.12.0/24 + register: create_ip_range_idempotent_check + check_mode: yes + + - assert: + that: + - create_ip_range_idempotent_check is not changed + + - name: Create firewall rule for IP range with idempotency + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: ip_range + ip_range: 10.11.12.0/24 + register: create_ip_range_idempotent + + - assert: + that: + - create_ip_range_idempotent is not changed + + - name: Create firewall rule for application + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application + application: + name: facebook + register: application_rule + + - assert: + that: + - application_rule is changed + - application_rule.data.rules is defined + + - name: Create firewall rule for application via ID + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application + application: + id: meraki:layer7/application/205 + register: application_rule_id + + - assert: + that: + - application_rule_id is changed + + - name: Create firewall rule for invalid application + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application + application: + name: ansible + register: application_rule_invalid + ignore_errors: yes + + - name: Create firewall rule for application category + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application_category + application: + name: Advertising + register: application_category_rule + + - debug: + var: application_category_rule + + - assert: + that: + - application_category_rule is changed + + - name: Create firewall rule for application category with ID and conflict + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application_category + application: + id: meraki:layer7/category/27 + register: application_category_rule_id_conflict + + - assert: + that: + - application_category_rule_id_conflict is not changed + + - name: Create firewall rule for application category with ID + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application_category + application: + id: meraki:layer7/category/24 + register: application_category_rule_id + + - assert: + that: + - application_category_rule_id is changed + + - name: Create firewall rule for host + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: host + host: asdf.com + register: host_rule + + - assert: + that: + - host_rule is changed + + - name: Create firewall rule for port + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: port + port: 1234 + register: port_rule + + - assert: + that: + - port_rule is changed + + - name: Create firewall rule for denied countries + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: blocked_countries + countries: + - CA + - AX + register: blocked_countries + + - assert: + that: + - blocked_countries is changed + + - name: Create firewall rule for allowed countries + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: blocked_countries + countries: + - US + - FR + register: allowed_countries + + - assert: + that: + - allowed_countries is changed + + - name: Create firewall rule for allowed countries with idempotency + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: blocked_countries + countries: + - US + - FR + register: allowed_countries_idempotent + + - assert: + that: + - allowed_countries_idempotent is not changed + + - name: Create multiple firewall rules + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application_category + application: + id: meraki:layer7/category/27 + - type: blocked_countries + countries: + - CN + - policy: deny + type: port + port: 8080 + register: multiple_rules + + - debug: + var: multiple_rules + + - assert: + that: + - multiple_rules.data.rules | length == 3 + - multiple_rules is changed + + ######################################### + ## Tests for argument completeness ## + ######################################### + + - name: Test blocked_countries incomplete arguments + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: blocked_countries + register: error_allowed + ignore_errors: yes + + - assert: + that: + - 'error_allowed.msg == "countries argument is required when type is blocked_countries."' + + - name: Test blocked_countries incomplete arguments + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: blocked_countries + register: error_denied + ignore_errors: yes + + - assert: + that: + - 'error_denied.msg == "countries argument is required when type is blocked_countries."' + + - name: Test application_category incomplete arguments + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application_category + register: error_app_cat + ignore_errors: yes + + - assert: + that: + - 'error_app_cat.msg == "application argument is required when type is application_category."' + + - name: Test application incomplete arguments + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: application + register: error_app_cat + ignore_errors: yes + + - assert: + that: + - 'error_app_cat.msg == "application argument is required when type is application."' + + - name: Test host incomplete arguments + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: host + register: error_app_cat + ignore_errors: yes + + - assert: + that: + - 'error_app_cat.msg == "host argument is required when type is host."' + + - name: Test port incomplete arguments + meraki_mx_l7_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + rules: + - type: port + register: error_app_cat + ignore_errors: yes + + - assert: + that: + - 'error_app_cat.msg == "port argument is required when type is port."' + + ################# + ## Cleanup ## + ################# + + # always: + # - name: Delete network + # meraki_network: + # auth_key: '{{ auth_key }}' + # org_name: '{{test_org_name}}' + # net_name: TestNetAppliance + # state: absent + # delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_site_to_site_firewall/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_site_to_site_firewall/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_site_to_site_firewall/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_site_to_site_firewall/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_site_to_site_firewall/tasks/main.yml new file mode 100644 index 00000000..df0b9164 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_site_to_site_firewall/tasks/main.yml @@ -0,0 +1,306 @@ +# 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Create network + meraki_network: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + type: appliance + delegate_to: localhost + + - name: Query firewall rules + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: query + delegate_to: localhost + register: query + + - debug: + var: query + + # - assert: + # that: + # - query.data|length == 1 + + - name: Set one firewall rule with check mode + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + delegate_to: localhost + check_mode: yes + register: create_one_check + + - debug: + var: create_one_check + + - assert: + that: + - create_one_check.data.rules|length == 2 + - create_one_check.data.rules.0.dest_cidr == '192.0.1.1/32' + - create_one_check.data.rules.0.protocol == 'tcp' + - create_one_check.data.rules.0.policy == 'deny' + - create_one_check is changed + - create_one_check.data is defined + + - name: Set one firewall rule + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + delegate_to: localhost + register: create_one + + - debug: + var: create_one + + - assert: + that: + - create_one.data.rules|length == 2 + - create_one.data.rules.0.dest_cidr == '192.0.1.1/32' + - create_one.data.rules.0.protocol == 'tcp' + - create_one.data.rules.0.policy == 'deny' + - create_one.changed == True + - create_one.data is defined + + - name: Check for idempotency + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + delegate_to: localhost + register: create_one_idempotent + + - debug: + msg: '{{create_one_idempotent}}' + + - assert: + that: + - create_one_idempotent.changed == False + - create_one_idempotent.data is defined + + - name: Update one existing rule + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + rules: + - comment: Deny all documentation addresses + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32,192.0.1.2/32 + protocol: tcp + policy: deny + delegate_to: localhost + register: update_one + + - debug: + msg: '{{update_one}}' + + - assert: + that: + - update_one.changed == True + - update_one.data is defined + + - name: Create syslog in network + meraki_syslog: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: present + servers: + - host: 192.0.2.10 + port: 514 + roles: + - Appliance event log + - Flows + delegate_to: localhost + + - name: Enable syslog for default rule with check mode + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + syslog_default_rule: yes + delegate_to: localhost + check_mode: yes + register: default_syslog_check + + - debug: + msg: '{{default_syslog_check}}' + + - assert: + that: + - default_syslog_check.data is defined + - default_syslog_check.data.rules.1.syslog_enabled == True + + - name: Enable syslog for default rule + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + syslog_default_rule: yes + delegate_to: localhost + register: default_syslog + + - debug: + msg: '{{default_syslog}}' + + - assert: + that: + - default_syslog.data is defined + + - name: Query firewall rules + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: query + delegate_to: localhost + register: query + + - debug: + msg: '{{query.data.rules.1}}' + + - assert: + that: + - query.data.rules.1.syslog_enabled == True + - default_syslog.changed == True + + - name: Disable syslog for default rule + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + rules: + - comment: Deny to documentation address + src_port: Any + src_cidr: Any + dest_port: 80,443 + dest_cidr: 192.0.1.1/32 + protocol: tcp + policy: deny + syslog_default_rule: no + delegate_to: localhost + register: disable_syslog + + - debug: + msg: '{{disable_syslog}}' + + - assert: + that: + - disable_syslog.data is defined + + - name: Query firewall rules + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: query + delegate_to: localhost + register: query + + - debug: + msg: '{{query}}' + + - name: Enable syslog for default rule with no rules and with check mode + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + syslog_default_rule: yes + delegate_to: localhost + check_mode: yes + register: enable_syslog_only_check + + - debug: + msg: '{{enable_syslog_only_check}}' + + - assert: + that: + - enable_syslog_only_check.data.rules.1.syslog_enabled == True + - enable_syslog_only_check is changed + + - name: Query firewall rules + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: query + delegate_to: localhost + register: query + + - debug: + msg: '{{query.data.rules.1}}' + + - assert: + that: + - query.data.rules.1.syslog_enabled == False + - disable_syslog.changed == True + + always: + - name: Delete all firewall rules + meraki_mx_site_to_site_firewall: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + state: present + rules: [] + delegate_to: localhost + register: delete_all + + - name: Delete network + meraki_network: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: TestNetAppliance + state: absent + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_uplink/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_uplink/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_uplink/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_uplink/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_uplink/tasks/main.yml new file mode 100644 index 00000000..1e055256 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_mx_uplink/tasks/main.yml @@ -0,0 +1,125 @@ +# Test code for the Meraki MX Uplink module +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# 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: Create test network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Uplink' + type: appliance + delegate_to: localhost + + - name: Set MX uplink settings with check mode + meraki_mx_uplink: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Uplink' + wan1: + bandwidth_limits: + limit_down: 1000000 + limit_up: 100 + cellular: + bandwidth_limits: + limit_down: 0 + limit_up: 0 + delegate_to: localhost + register: set_bw_check + check_mode: yes + + - debug: + var: set_bw_check + + - assert: + that: + - set_bw_check is changed + - set_bw_check.data is defined + - set_bw_check.diff is defined + + - name: Set MX uplink settings + meraki_mx_uplink_bandwidth: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Uplink' + wan1: + bandwidth_limits: + limit_down: 1000000 + limit_up: 1000 + cellular: + bandwidth_limits: + limit_down: 0 + limit_up: 0 + delegate_to: localhost + register: set_bw + + - debug: + var: set_bw + + - assert: + that: + - set_bw is changed + - set_bw.data is defined + + - name: Set MX uplink settings with idempotency + meraki_mx_uplink_bandwidth: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Uplink' + wan1: + bandwidth_limits: + limit_down: 1000000 + limit_up: 1000 + cellular: + bandwidth_limits: + limit_down: 0 + limit_up: 0 + delegate_to: localhost + register: set_bw_idempotent + + - debug: + var: set_bw_idempotent + + - assert: + that: + - set_bw_idempotent is not changed + - set_bw_idempotent.data is defined + + - name: Query MX uplink settings + meraki_mx_uplink: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Uplink' + delegate_to: localhost + register: query_all + + - debug: + var: query_all + + - assert: + that: + - query_all.data is defined + + always: + ############################################################################# + # Tear down starts here + ############################################################################# + + - name: Delete test network + meraki_network: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}} - Uplink' + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/tasks/main.yml new file mode 100644 index 00000000..721a9300 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/tasks/main.yml @@ -0,0 +1,7 @@ +# 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: Run test cases + include: tests.yml ansible_connection=local diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/tasks/tests.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/tasks/tests.yml new file mode 100644 index 00000000..11193d13 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_nat/tasks/tests.yml @@ -0,0 +1,363 @@ +# Test code for the Meraki NAT module +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create test network + meraki_network: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + type: appliance + + - name: Create 1:1 rule with check mode + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + one_to_one: + - name: Service behind NAT + public_ip: 1.2.1.2 + lan_ip: 192.168.128.1 + uplink: internet1 + allowed_inbound: + - protocol: tcp + destination_ports: + - 80 + allowed_ips: + - 10.10.10.10 + register: create_one_one_check + check_mode: yes + + - debug: + var: create_one_one_check + + - assert: + that: + - create_one_one_check is changed + + - name: Create 1:1 rule + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + one_to_one: + - name: Service behind NAT + public_ip: 1.2.1.2 + lan_ip: 192.168.128.1 + uplink: internet1 + allowed_inbound: + - protocol: tcp + destination_ports: + - 80 + allowed_ips: + - 10.10.10.10 + register: create_one_one + + - debug: + var: create_one_one + + - assert: + that: + - create_one_one is changed + + - name: Create 1:1 rule with idempotency + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + one_to_one: + - name: Service behind NAT + public_ip: 1.2.1.2 + lan_ip: 192.168.128.1 + uplink: internet1 + allowed_inbound: + - protocol: tcp + destination_ports: + - 80 + allowed_ips: + - 10.10.10.10 + register: create_one_one_idempotent + + - debug: + var: create_one_one_idempotent + + - assert: + that: + - create_one_one_idempotent is not changed + + - name: Create 1:many rule with check mode + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + one_to_many: + - public_ip: 1.1.1.1 + uplink: internet1 + port_rules: + - name: Test rule + protocol: tcp + public_port: 10 + local_ip: 192.168.128.1 + local_port: 11 + allowed_ips: + - any + register: create_one_many_check + check_mode: yes + + - debug: + var: create_one_many_check + + - assert: + that: + - create_one_many_check is changed + + - name: Create 1:many rule + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + one_to_many: + - public_ip: 1.1.1.1 + uplink: internet1 + port_rules: + - name: Test rule + protocol: tcp + public_port: 10 + local_ip: 192.168.128.1 + local_port: 11 + allowed_ips: + - any + register: create_one_many + + - debug: + var: create_one_many + + - assert: + that: + - create_one_many is changed + + - name: Create 1:many rule with idempotency + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + one_to_many: + - public_ip: 1.1.1.1 + uplink: internet1 + port_rules: + - name: Test rule + protocol: tcp + public_port: 10 + local_ip: 192.168.128.1 + local_port: 11 + allowed_ips: + - any + register: create_one_many_idempotent + + - debug: + var: create_one_many_idempotent + + - assert: + that: + - create_one_many_idempotent is not changed + + - name: Create port forwarding rule with check mode + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + port_forwarding: + - name: Test map + lan_ip: 192.168.128.1 + uplink: both + protocol: tcp + allowed_ips: + - 1.1.1.1 + public_port: 10 + local_port: 11 + register: create_pf_check + check_mode: yes + + - debug: + var: create_pf_check + + - assert: + that: + - create_pf_check is changed + + - name: Create port forwarding rule + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + port_forwarding: + - name: Test map + lan_ip: 192.168.128.1 + uplink: both + protocol: tcp + allowed_ips: + - 1.1.1.1 + public_port: 10 + local_port: 11 + register: create_pf + + - debug: + var: create_pf + + - assert: + that: + - create_pf is changed + + - name: Create port forwarding rule with idempotency + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + port_forwarding: + - name: Test map + lan_ip: 192.168.128.1 + uplink: both + protocol: tcp + allowed_ips: + - 1.1.1.1 + public_port: 10 + local_port: 11 + register: create_pf_idempotent + + - debug: + var: create_pf_idempotent + + - assert: + that: + - create_pf_idempotent is not changed + - create_pf_idempotent.data.port_forwarding is defined + + - name: Create multiple rules + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + port_forwarding: + - name: Test map + lan_ip: 192.168.128.1 + uplink: both + protocol: tcp + allowed_ips: + - 1.1.1.2 + public_port: 10 + local_port: 11 + one_to_many: + - public_ip: 1.1.1.3 + uplink: internet1 + port_rules: + - name: Test rule + protocol: tcp + public_port: 10 + local_ip: 192.168.128.1 + local_port: 11 + allowed_ips: + - any + register: create_multiple + + - debug: + var: create_multiple + + - assert: + that: + - create_multiple is changed + - create_multiple.data.one_to_many is defined + - create_multiple.data.port_forwarding is defined + + - assert: + that: + - create_multiple is changed + - create_multiple.data.one_to_many is defined + - create_multiple.data.port_forwarding is defined + - create_multiple.diff.before.one_to_many is defined + - create_multiple.diff.before.port_forwarding is defined + - create_multiple.diff.after.one_to_many is defined + - create_multiple.diff.after.port_forwarding is defined + + - name: Query all NAT rules + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + subset: all + register: query_all + + - debug: + var: query_all + + - name: Query 1:1 NAT rules + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + subset: '1:1' + register: query_1to1 + + - debug: + var: query_1to1 + + - name: Query 1:many NAT rules + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + subset: '1:many' + register: query_1tomany + + - debug: + var: query_1tomany + + - name: Query port forwarding rules + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + subset: port_forwarding + register: query_pf + + - debug: + var: query_pf + + - name: Query multiple rules + meraki_nat: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + subset: + - '1:1' + - '1:many' + register: query_multiple + + - debug: + var: query_multiple + + always: + - name: Delete test network + meraki_network: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: absent +
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_network/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_network/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_network/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_network/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_network/tasks/main.yml new file mode 100644 index 00000000..61bcb313 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_network/tasks/main.yml @@ -0,0 +1,453 @@ +# Test code for the Meraki modules +# Copyright: (c) 2018, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network without type + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + timezone: America/Chicago + delegate_to: localhost + register: create_net_no_type + ignore_errors: yes + + - assert: + that: + - create_net_no_type.msg == 'type parameter is required when creating a network.' + + - name: Create network without organization + meraki_network: + auth_key: '{{ auth_key }}' + state: present + net_name: IntTestNetwork + timezone: America/Chicago + delegate_to: localhost + register: create_net_no_org + ignore_errors: yes + + - name: Create network with type switch with check mode + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + type: switch + timezone: America/Chicago + delegate_to: localhost + check_mode: yes + register: create_net_switch_check + + - assert: + that: + - create_net_switch_check is changed + - create_net_switch_check.data is defined + - create_net_switch_check.data.organization_id == "{{test_org_id |string}}" + + - name: Create network with type switch + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + type: switch + timezone: America/Chicago + delegate_to: localhost + register: create_net_switch + + - name: Create network with type switch by org ID + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_id: '{{test_org_id}}' + net_name: IntTestNetworkSwitchOrgID + type: switch + timezone: America/Chicago + delegate_to: localhost + register: create_net_switch_org_id + + - name: Create network with type appliance and no timezone + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkAppliance + type: appliance + delegate_to: localhost + register: create_net_appliance_no_tz + + - name: Enable VLAN support on appliance network with check mode + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: yes + delegate_to: localhost + check_mode: yes + register: enable_vlan_check + + - assert: + that: + - enable_vlan_check.data.vlans_enabled == True + - enable_vlan_check is changed + + - name: Enable VLAN support on appliance network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: yes + delegate_to: localhost + register: enable_vlan + + - assert: + that: + - enable_vlan.data.vlans_enabled == True + + - name: Enable VLAN support on appliance network with idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: yes + delegate_to: localhost + register: enable_vlan_idempotent + + - assert: + that: + - enable_vlan_idempotent is not changed + - enable_vlan_idempotent.data is defined + + - name: Disable VLAN support on appliance network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: no + delegate_to: localhost + register: disable_vlan + + - assert: + that: + - disable_vlan.data.vlans_enabled == False + + - name: Disable VLAN support on appliance network with idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + enable_vlans: no + delegate_to: localhost + register: disable_vlan_idempotent + + - assert: + that: + - disable_vlan_idempotent is not changed + - disable_vlan_idempotent.data is defined + + - name: Change local page settings with check mode + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + local_status_page_enabled: False + delegate_to: localhost + check_mode: True + register: disable_local_page_check + + - assert: + that: + - disable_local_page_check is changed + + - name: Change local page settings + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + local_status_page_enabled: False + delegate_to: localhost + register: disable_local_page + + - assert: + that: + - disable_local_page is changed + - disable_local_page.data is defined + + - name: Change local page settings with idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkAppliance + local_status_page_enabled: False + delegate_to: localhost + register: disable_local_page_idempotent + + - assert: + that: + - disable_local_page_idempotent is not changed + - disable_local_page_idempotent.data is defined + + - name: Create network with type wireless + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + type: wireless + timezone: America/Chicago + delegate_to: localhost + register: create_net_wireless + + - assert: + that: + - '"IntTestNetworkWireless" in create_net_wireless.data.name' + + - name: Create network with type wireless and check for idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkWireless + type: wireless + timezone: America/Chicago + delegate_to: localhost + register: create_net_wireless_idempotent + + - assert: + that: + - create_net_wireless_idempotent.changed == False + - create_net_wireless_idempotent.data is defined + + - name: Create network with type combined + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{ test_org_name }}' + net_name: IntTestNetworkCombined + type: + - appliance + - switch + timezone: America/Chicago + delegate_to: localhost + register: create_net_combined + + - assert: + that: + - create_net_combined.data.product_types | length > 1 + + - name: Test status pages are mutually exclusive when on + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkCombined + local_status_page_enabled: yes + remote_status_page_enabled: no + delegate_to: localhost + register: status_exclusivity + ignore_errors: yes + + - assert: + that: + - '"must be true when setting" in status_exclusivity.msg' + + - name: Create network with one tag + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkTag + type: switch + timezone: America/Chicago + tags: first_tag + delegate_to: localhost + register: create_net_tag + + - name: Create network with two tags + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkTags + type: switch + timezone: America/Chicago + tags: + - first_tag + - second_tag + delegate_to: localhost + register: create_net_tags + + - set_fact: + tag_net_id: '{{create_net_tags.data.id}}' + + - name: Modify network by net_id + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_id: '{{tag_net_id}}' + type: switch + timezone: America/Chicago + tags: + - first_tag + - second_tag + - third_tag + delegate_to: localhost + register: create_net_modified + + - name: Modify network with idempotency + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetworkTags + type: switch + timezone: America/Chicago + tags: + - first_tag + - second_tag + - third_tag + delegate_to: localhost + register: create_net_modified_idempotent + + - assert: + that: + - create_net_modified_idempotent.data is defined + + - name: Present assertions + assert: + that: + - '"org_name or org_id parameters are required" in create_net_no_org.msg' + - '"IntTestNetworkAppliance" in create_net_appliance_no_tz.data.name' + - create_net_appliance_no_tz.changed == True + - '"IntTestNetworkSwitch" in create_net_switch.data.name' + - '"IntTestNetworkSwitchOrgID" in create_net_switch_org_id.data.name' + - '"first_tag" in create_net_tag.data.tags' + - '"second_tag" in create_net_tags.data.tags' + - '"third_tag" in create_net_modified.data.tags' + - create_net_modified.changed == True + - create_net_modified_idempotent.changed == False + - create_net_modified_idempotent.data is defined + + - name: Query network settings + meraki_network: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_template_name}}' + local_status_page_enabled: yes + delegate_to: localhost + register: query_settings + + - assert: + that: + - query_settings.data is defined + + - name: Query all networks + meraki_network: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + delegate_to: localhost + register: net_query_all + + - name: Query a configuration template + meraki_network: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_template_name}}' + delegate_to: localhost + register: query_config_template + + - name: Query one network + meraki_network: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_name: IntTestNetworkSwitch + delegate_to: localhost + register: net_query_one + + - name: Query assertions + assert: + that: + - 'net_query_one.data.name == "IntTestNetworkSwitch"' + - 'query_config_template.data.name == "{{ test_template_name }}"' + +############################################################################# +# Tear down starts here +############################################################################# + always: + - name: Delete network without org + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + net_name: IntTestNetworkSwitch + delegate_to: localhost + register: delete_all_no_org + ignore_errors: yes + + - name: Delete network by org ID and check mode + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_id: '{{test_org_id}}' + net_name: IntTestNetworkSwitchOrgID + delegate_to: localhost + check_mode: yes + register: delete_net_org_id_check + + - assert: + that: + - delete_net_org_id_check is changed + - delete_net_org_id_check.data is defined + + - name: Delete network by org ID + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_id: '{{test_org_id}}' + net_name: IntTestNetworkSwitchOrgID + delegate_to: localhost + register: delete_net_org_id + + - name: Query after delete with org ID + meraki_network: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + delegate_to: localhost + register: query_deleted_org_id + + - name: Delete all networks + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{ item }}' + delegate_to: localhost + register: delete_all + ignore_errors: yes + loop: + - IntTestNetworkSwitch + - IntTestNetworkWireless + - IntTestNetworkAppliance + - IntTestNetworkCombined + - IntTestNetworkTag + - IntTestNetworkTags + + - assert: + that: + - 'delete_all_no_org.msg == "org_name or org_id parameters are required"' diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/tasks/main.yml new file mode 100644 index 00000000..e7ad65b8 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/tasks/main.yml @@ -0,0 +1,8 @@ +# 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: Run test cases + include: tests.yml ansible_connection=local +
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/tasks/tests.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/tasks/tests.yml new file mode 100644 index 00000000..28ebce01 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_organization/tasks/tests.yml @@ -0,0 +1,149 @@ +# 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Create a new organization named IntTestOrg + meraki_organization: + auth_key: '{{ auth_key }}' + org_name: IntTestOrg + state: present + output_level: debug + register: new_org + + - debug: + msg: '{{new_org}}' + + - name: Clone IntTestOrg + meraki_organization: + auth_key: '{{ auth_key }}' + clone: IntTestOrg + org_name: IntTestOrgCloned + state: present + register: cloned_org + + - debug: + msg: '{{cloned_org}}' + + - set_fact: + cloned_net_id: '{{cloned_org.data.id}}' + + - name: Rename IntTestOrg + meraki_organization: + auth_key: '{{ auth_key }}' + org_name: IntTestOrgRenamed + org_id: '{{ new_org.data.id }}' + state: present + register: modify_org + + - debug: + msg: '{{ modify_org }}' + + - set_fact: + renamed_org_id: '{{modify_org.data.id}}' + + - name: Rename IntTestOrg idempotent + meraki_organization: + auth_key: '{{ auth_key }}' + org_name: IntTestOrgRenamed + org_id: '{{ new_org.data.id }}' + state: present + register: modify_org_idempotent + + - name: Present assertions + assert: + that: + - '"https" in new_org.url' + - new_org.changed == True + - new_org.data.id is defined + - cloned_org.changed == True + - cloned_org.data.id is defined + - modify_org.changed == True + - 'modify_org.data.name == "IntTestOrgRenamed"' + - modify_org_idempotent.changed == False + - modify_org_idempotent.data is defined + + - name: List all organizations + meraki_organization: + auth_key: '{{ auth_key }}' + state: query + register: query_all + + - name: Query information about a single organization named IntTestOrg + meraki_organization: + auth_key: '{{ auth_key }}' + org_name: IntTestOrgRenamed + state: query + register: query_org + + - name: Query information about IntTestOrg by organization ID + meraki_organization: + auth_key: '{{ auth_key }}' + org_id: '{{ query_org.data.id }}' + state: query + register: query_org_id + + - name: Query assertions + assert: + that: + - query_org.data.id is defined + - query_all.changed == False + - query_all.data | length >= 1 + - 'query_org.data.name == "IntTestOrgRenamed"' + - 'query_org_id.data.id == query_org.data.id' + + - name: Delete without confirmation code + meraki_organization: + auth_key: '{{ auth_key }}' + state: absent + org_name: IntTestOrgCloned + register: delete_no_confirm + ignore_errors: yes + + - assert: + that: + 'delete_no_confirm.msg == "delete_confirm must match the network ID of the network to be deleted."' + + always: + # - name: Pause playbook for more reliable deletion + # pause: + # minutes: 1 + + - name: Delete cloned organizations with check mode + meraki_organization: + auth_key: '{{ auth_key }}' + state: absent + org_name: IntTestOrgCloned + delete_confirm: '{{cloned_net_id}}' + register: deleted_org_check + check_mode: yes + + - assert: + that: + - deleted_org_check is changed + + - name: Delete cloned organizations + meraki_organization: + auth_key: '{{ auth_key }}' + state: absent + org_name: IntTestOrgCloned + delete_confirm: '{{cloned_net_id}}' + register: deleted_org + + - name: Delete renamed organization by id + meraki_organization: + auth_key: '{{ auth_key }}' + state: absent + org_id: '{{renamed_org_id}}' + delete_confirm: '{{renamed_org_id}}' + register: deleted_org_id + + - assert: + that: + - deleted_org_id is changed diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_site_to_site_vpn/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_site_to_site_vpn/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_site_to_site_vpn/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_site_to_site_vpn/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_site_to_site_vpn/tasks/main.yml new file mode 100644 index 00000000..d15a1b96 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_site_to_site_vpn/tasks/main.yml @@ -0,0 +1,140 @@ +# Test code for the Meraki Admin 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) +--- +- block: + + - name: Create hub network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_hub' + type: appliance + delegate_to: localhost + register: net_hub + + - name: Create spoke network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_spoke' + type: appliance + delegate_to: localhost + register: net_spoke + + - set_fact: + net_spoke_id: '{{net_spoke.data.id}}' + net_hub_id: '{{net_hub.data.id}}' + + - name: Set hub mode + meraki_site_to_site_vpn: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_hub' + mode: hub + subnets: + - local_subnet: '192.168.128.0/24' + use_vpn: no + delegate_to: localhost + register: set_hub + + - assert: + that: + - set_hub is changed + - set_hub.data is defined + + - name: Set hub mode with idempotency + meraki_site_to_site_vpn: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_hub' + mode: hub + delegate_to: localhost + register: set_hub_idempotent + + - assert: + that: + - set_hub_idempotent is not changed + - set_hub_idempotent.data is defined + + - name: Enable subnet on hub network + meraki_site_to_site_vpn: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_hub' + mode: hub + subnets: + - local_subnet: '192.168.128.0/24' + use_vpn: yes + delegate_to: localhost + register: enable_hub_subnet + + - assert: + that: + - enable_hub_subnet is changed + - enable_hub_subnet.data is defined + + - name: Set spoke mode + meraki_site_to_site_vpn: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_spoke' + mode: spoke + hubs: + - hub_id: '{{net_hub_id}}' + use_default_route: false + delegate_to: localhost + register: set_spoke + + - debug: + var: set_spoke + + - name: Set spoke configuration + meraki_site_to_site_vpn: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_spoke' + mode: spoke + hubs: + - hub_id: '{{net_hub_id}}' + use_default_route: false + subnets: + - local_subnet: '192.168.169.0/24' + use_vpn: true + delegate_to: localhost + register: set_spoke + + - debug: + var: set_spoke + + - name: Query rules for hub + meraki_site_to_site_vpn: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_hub' + delegate_to: localhost + register: query_all_hub + + - debug: + var: query_all_hub + + - name: Query rules for spoke + meraki_site_to_site_vpn: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}_spoke' + delegate_to: localhost + register: query_all_spoke + + - debug: + var: query_all_spoke diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_snmp/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_snmp/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_snmp/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_snmp/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_snmp/tasks/main.yml new file mode 100644 index 00000000..ed0868a4 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_snmp/tasks/main.yml @@ -0,0 +1,290 @@ +# 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Create SNMP network + meraki_network: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + type: appliance + delegate_to: localhost + register: new_net + + - set_fact: + net_id: new_net.data.id + + - 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}}' + + - 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: + - snmp_v2_enable.data.v2_community_string is defined + - snmp_v2_enable.data.v2c_enabled == true + + - 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: + - snmp_v2_disable.data.v2_community_string is not defined + - snmp_v2_disable.data.v2c_enabled == 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.v2_community_string is defined + - snmp_v2_enable_id.data.v2c_enabled == 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.v2_community_string is not defined + - snmp_v2_disable_id.data.v2c_enabled == False + + - name: Enable SNMPv3 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 + check_mode: yes + register: snmp_v3_enable_check + + - assert: + that: + - snmp_v3_enable_check.data.v3_enabled == True + - snmp_v3_enable_check.changed == True + + - 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: + - snmp_v3_enable.data.v3_enabled == True + - 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 + - snmp_idempotent.data is defined + + - 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: + - peers.data.peer_ips is defined + + - 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 + delegate_to: localhost + register: short_password + ignore_errors: yes + + - assert: + that: + - '"at least 8" in short_password.msg' + + - name: Set network access type to community string + meraki_snmp: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + access: community + community_string: abc123 + delegate_to: localhost + register: set_net_community + + - debug: + var: set_net_community + + - assert: + that: + - set_net_community is changed + - set_net_community.data is defined + + - name: Set network access type to username + meraki_snmp: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + access: users + users: + - username: ansibleuser + passphrase: ansiblepass + delegate_to: localhost + register: set_net_user + + - debug: + var: set_net_user + + - assert: + that: + - set_net_user is changed + - set_net_user.data is defined + + - name: Set network access type to none + meraki_snmp: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + access: none + delegate_to: localhost + register: set_net_none + + - debug: + var: set_net_none + + - assert: + that: + - set_net_none is changed + - set_net_none.data is defined + + - name: Query network SNMP settings + meraki_snmp: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + delegate_to: localhost + register: get_net + + - debug: + var: get_net + + - assert: + that: + - get_net.data is defined + + always: + - name: Disable SNMPv3 + meraki_snmp: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + state: present + v3_enabled: no + v3_auth_mode: SHA + v3_auth_pass: ansiblepass + v3_priv_mode: AES128 + v3_priv_pass: ansiblepass + delegate_to: localhost + + - name: Delete SNMP network + meraki_network: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: absent + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ssid/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ssid/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ssid/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ssid/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ssid/tasks/main.yml new file mode 100644 index 00000000..638bdf12 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_ssid/tasks/main.yml @@ -0,0 +1,551 @@ +# Test code for the Meraki SSID 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) +--- +- block: + + - set_fact: + wpa_enabled: false + + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - 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}}' + + - name: Add access points to network + meraki_device: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: TestNetSSID + serial: '{{serial_wireless}}' + delegate_to: localhost + + - 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: Enable and name SSID with check mode + 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_check + check_mode: yes + + - assert: + that: + - enable_name_ssid_check is changed + - enable_name_ssid_check.data is defined + + - 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 }}' + + - 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 + + - debug: + msg: '{{ enable_name_ssid_idempotent }}' + + - assert: + that: + - enable_name_ssid_idempotent.changed == False + - enable_name_ssid_idempotent.data is defined + + - 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}}' + + - assert: + that: + - query_one.data.name == 'AnsibleSSID' + + - name: Query one SSID with number + meraki_ssid: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: TestNetSSID + number: 1 + delegate_to: localhost + register: query_one_number + + - debug: + msg: '{{query_one_number}}' + + - assert: + that: + - query_one_number.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 + + - debug: + msg: '{{ disable_ssid.data.enabled }}' + + - 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 + + - debug: + msg: '{{ enable_ssid_number.data.enabled }}' + + - assert: + that: + - enable_ssid_number.data.enabled == True + + - name: Set VLAN arg spec + meraki_ssid: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: TestNetSSID + number: 1 + use_vlan_tagging: yes + ip_assignment_mode: Bridge mode + default_vlan_id: 1 + ap_tags_vlan_ids: + - tags: wifi + vlan_id: 2 + delegate_to: localhost + register: set_vlan_arg + + - debug: + var: set_vlan_arg + + - assert: + that: set_vlan_arg is changed + + - name: Set VLAN arg spec + meraki_ssid: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: TestNetSSID + number: 1 + use_vlan_tagging: yes + ip_assignment_mode: Bridge mode + default_vlan_id: 1 + ap_tags_vlan_ids: + - tags: wifi + vlan_id: 2 + delegate_to: localhost + register: set_vlan_arg_idempotent + + - debug: + var: set_vlan_arg_idempotent + + - assert: + that: set_vlan_arg_idempotent is not changed + + + - 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 }}' + + - assert: + that: + - psk.data.auth_mode == 'psk' + - psk.data.encryption_mode == 'wpa' + - psk.data.wpa_encryption_mode == 'WPA2 only' + + - name: Set PSK with idempotency + 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_idempotent + + - debug: + msg: '{{ psk_idempotent }}' + + - assert: + that: + - psk_idempotent is not changed + + # + # Check WPA3 Transition Mode + # + - name: Set WPA3 Transition Mode + 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 + wpa_encryption_mode: WPA3 Transition Mode + delegate_to: localhost + register: psk_wpa3_transition_mode + when: wpa_enabled == true + + - debug: + msg: '{{ psk_wpa3_transition_mode }}' + when: wpa_enabled == True + + - assert: + that: + - psk_wpa3_transition_mode.data.auth_mode == 'psk' + - psk_wpa3_transition_mode.data.encryption_mode == 'wpa' + - psk_wpa3_transition_mode.data.wpa_encryption_mode == 'WPA3 Transition Mode' + when: wpa_enabled == True + + - name: Set WPA3 Transition Mode with Idempotency + 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 + wpa_encryption_mode: WPA3 Transition Mode + delegate_to: localhost + register: psk_wpa3_transition_mode_idempotent + when: wpa_enabled == True + + - debug: + msg: '{{ psk_wpa3_transition_mode_idempotent }}' + when: wpa_enabled == True + + - assert: + that: + - psk_wpa3_transition_mode_idempotent is not changed + when: wpa_enabled == True + + - 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 }}' + + - assert: + that: + - splash_click.data.splash_page == 'Click-through splash page' + + - name: Set walled garden + meraki_ssid: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: TestNetSSID + name: AnsibleSSID + walled_garden_enabled: yes + walled_garden_ranges: + - 192.168.0.0/24 + - '*.ansible.com' + delegate_to: localhost + register: walled_garden + + - debug: + msg: '{{ walled_garden }}' + + - assert: + that: + - 'walled_garden.data.walled_garden_enabled == True' + - walled_garden is changed + + - name: Set walled garden with idempotency + meraki_ssid: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: TestNetSSID + name: AnsibleSSID + walled_garden_enabled: yes + walled_garden_ranges: + - 192.168.0.0/24 + - '*.ansible.com' + delegate_to: localhost + register: walled_garden_idempotent + + - debug: + msg: '{{ walled_garden_idempotent }}' + + - assert: + that: + - walled_garden_idempotent.data is defined + - walled_garden_idempotent is not changed + + - 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 }}' + + - assert: + that: + - set_radius_server.data.radius_servers.0.host == '192.0.1.200' + + - name: Configure RADIUS servers with idempotency + 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_idempotent + + - debug: + var: set_radius_server_idempotent + + - assert: + that: + - set_radius_server_idempotent is not changed + + ################# + # Error testing # + ################# + - 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 }}' + + - 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 + + - debug: + msg: '{{ psk_invalid_mode }}' + + - assert: + that: + - psk_invalid_mode.msg == 'PSK requires encryption_mode be set to wpa' + + - name: Error for PSK and RADIUS servers + meraki_ssid: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: TestNetSSID + name: AnsibleSSID + auth_mode: psk + radius_servers: + - host: 192.0.1.200 + port: 1234 + secret: abc98765 + delegate_to: localhost + register: err_radius_server_psk + ignore_errors: yes + + - debug: + var: err_radius_server_psk + + - assert: + that: + - 'err_radius_server_psk.msg == "radius_servers requires auth_mode to be open-with-radius or 8021x-radius"' + + - name: Set VLAN arg without default VLAN error + meraki_ssid: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: TestNetSSID + number: 1 + use_vlan_tagging: yes + ip_assignment_mode: Bridge mode + ap_tags_vlan_ids: + - tags: wifi + vlan_id: 2 + delegate_to: localhost + register: set_vlan_arg_err + ignore_errors: yes + + - debug: + var: set_vlan_arg_err + + - assert: + that: + - 'set_vlan_arg_err.msg == "default_vlan_id is required when use_vlan_tagging is True"' + + always: + - name: Delete SSID with check mode + meraki_ssid: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: TestNetSSID + name: AnsibleSSID + delegate_to: localhost + register: delete_ssid_check + check_mode: yes + + - assert: + that: + - delete_ssid_check is changed + - delete_ssid_check.data is defined + + - 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 + + - debug: + msg: '{{ delete_ssid }}' + + - 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}}' diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_static_route/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_static_route/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_static_route/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_static_route/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_static_route/tasks/main.yml new file mode 100644 index 00000000..6313c23c --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_static_route/tasks/main.yml @@ -0,0 +1,187 @@ +# Test code for the Meraki modules +# Copyright: (c) 2018, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create appliance network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + timezone: America/Chicago + type: appliance + delegate_to: localhost + register: net + + - set_fact: + net_id: '{{net.data.id}}' + + - name: Initialize static route id list + set_fact: + route_ids: [] + + - name: Create static_route + meraki_static_route: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + name: Test Route + subnet: 192.0.1.0/24 + gateway_ip: 192.168.128.1 + delegate_to: localhost + register: create_route + + - set_fact: + route_ids: "{{ route_ids + [create_route.data.id] }}" + + - name: Create static_route with idempotency + meraki_static_route: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + name: Test Route + subnet: 192.0.1.0/24 + gateway_ip: 192.168.128.1 + delegate_to: localhost + register: create_route_idempotent + + - assert: + that: + - create_route_idempotent is not changed + + - name: Create second static_route + meraki_static_route: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + name: Test Route 2 + subnet: 192.0.2.0/24 + gateway_ip: 192.168.128.1 + delegate_to: localhost + register: second_create + + - set_fact: + route_ids: "{{ route_ids + [second_create.data.id] }}" + + - assert: + that: + - create_route.changed == True + - create_route.data.id is defined + + - name: Update static route + meraki_static_route: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + route_id: '{{create_route.data.id}}' + subnet: 192.0.3.0/24 + enabled: yes + delegate_to: localhost + register: update + + - assert: + that: + - update is changed + - update.data.subnet == "192.0.3.0/24" + + - name: Query static routes + meraki_static_route: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + delegate_to: localhost + register: query_all + + - debug: + var: query_all + + - assert: + that: + - query_all.data | length >= 2 + + - name: Update static route with idempotency + meraki_static_route: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + route_id: '{{create_route.data.id}}' + name: Test Route + gateway_ip: 192.168.128.1 + subnet: 192.0.3.0/24 + enabled: yes + delegate_to: localhost + register: update_idempotent + + - assert: + that: + - update_idempotent.changed == False + - update_idempotent.data is defined + + - name: Update static route with fixed IP assignment and reservation + meraki_static_route: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + route_id: '{{create_route.data.id}}' + fixed_ip_assignments: + - mac: aa:bb:cc:dd:ee:ff + ip: 192.0.3.11 + name: WebServer + reserved_ip_ranges: + - start: 192.168.3.2 + end: 192.168.3.10 + comment: Printers + delegate_to: localhost + register: fixed_ip + + - debug: + var: fixed_ip + + - assert: + that: + - fixed_ip.data.fixed_ip_assignments | length == 1 + - fixed_ip.data.reserved_ip_ranges | length == 1 + + + - name: Query single static route + meraki_static_route: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + route_id: '{{create_route.data.id}}' + delegate_to: localhost + register: query_one + + - assert: + that: + - query_one.data.name == "Test Route" + + - name: Delete static routes + meraki_static_route: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + route_id: '{{item}}' + delegate_to: localhost + loop: '{{route_ids}}' + register: delete_all + + always: + - name: Delete appliance network + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: IntTestNetwork + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/tasks/main.yml new file mode 100644 index 00000000..f671fc92 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/tasks/main.yml @@ -0,0 +1,7 @@ +# Test code for the Meraki Webhooks 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: Run test cases + include: tests.yml ansible_connection=local diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/tasks/tests.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/tasks/tests.yml new file mode 100644 index 00000000..cb0ac0be --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_access_list/tasks/tests.yml @@ -0,0 +1,123 @@ +# Test code for the Meraki Webhook module +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# 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: Create test network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + type: switch + + - name: Set access list in check mode + meraki_switch_access_list: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + rules: + - comment: Fake rule + policy: allow + ip_version: ipv4 + protocol: udp + src_cidr: 192.0.1.0/24 + src_port: "4242" + dst_cidr: 1.2.3.4/32 + dst_port: "80" + vlan: "100" + register: create_check + check_mode: yes + + - assert: + that: + - create_check is changed + - create_check.data is defined + + - debug: + var: create_check + + - name: Set access list + meraki_switch_access_list: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + rules: + - comment: Fake rule + policy: allow + ip_version: ipv4 + protocol: udp + src_cidr: 192.0.1.0/24 + src_port: "4242" + dst_cidr: 1.2.3.4/32 + dst_port: "80" + vlan: "100" + register: create + + - assert: + that: + - create is changed + - create.data is defined + + - debug: + var: create + + - name: Set access list with idempotency + meraki_switch_access_list: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + rules: + - comment: Fake rule + policy: allow + ip_version: ipv4 + protocol: udp + src_cidr: 192.0.1.0/24 + src_port: 4242 + dst_cidr: 1.2.3.4/32 + dst_port: 80 + vlan: 100 + register: create_idempotent + + - debug: + var: create_idempotent + + - assert: + that: + - create_idempotent is not changed + - create_idempotent.data is defined + + - name: Query access lists + meraki_switch_access_list: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + register: query + + - debug: + var: query + + - assert: + that: + - query.data is defined + + ############################################################################# + # Tear down starts here + ############################################################################# + always: + - name: Delete test network + meraki_network: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_stack/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_stack/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_stack/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_stack/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_stack/tasks/main.yml new file mode 100644 index 00000000..853cbbe7 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_stack/tasks/main.yml @@ -0,0 +1,198 @@ +# Test code for the Meraki Switch Stack module +# Copyright: (c) 2020, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create network with type switch + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + type: switch + timezone: America/Chicago + delegate_to: localhost + register: create_net_switch + + - set_fact: + net_id: '{{create_net_switch.data.id}}' + + - name: Claim devices into network + meraki_device: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_id: '{{net_id}}' + serial: '{{item}}' + state: present + delegate_to: localhost + register: claim_device + loop: + - "QBSB-BPR6-PRER" + - "QBSB-VLNE-E299" + - "QBSB-D75G-PXCG" + + - name: Create new stack + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + name: Test stack + serials: + - "QBSB-BPR6-PRER" + - "QBSB-VLNE-E299" + register: create + + - debug: + var: create + + - set_fact: + stack_id: '{{create.data.id}}' + + - assert: + that: + - create.data is defined + - create is changed + + - name: Add switch to stack + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + stack_id: '{{stack_id}}' + serials: + - "QBSB-D75G-PXCG" + register: add_stack + + - assert: + that: + - add_stack.data is defined + - add_stack.data.serials | length == 3 + - add_stack is changed + + - name: Add switch to stack idempotent + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + stack_id: '{{stack_id}}' + serials: + - "QBSB-D75G-PXCG" + register: add_stack_idempotent + + - assert: + that: + - add_stack_idempotent.data is defined + - add_stack_idempotent.data.serials | length == 3 + - add_stack_idempotent is not changed + + - name: Remove switch from stack + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + stack_id: '{{stack_id}}' + serials: + - "QBSB-D75G-PXCG" + register: remove_from_stack + + - debug: + var: remove_from_stack + + - assert: + that: + - remove_from_stack.data is defined + - remove_from_stack.data.serials | length == 2 + - remove_from_stack is changed + + - name: Remove switch from stack idempotent + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + stack_id: '{{stack_id}}' + serials: + - "QBSB-D75G-PXCG" + register: remove_from_stack_idempotent + + - debug: + var: remove_from_stack_idempotent + + - assert: + that: + - remove_from_stack_idempotent.data is defined + - remove_from_stack_idempotent.data.serials | length == 2 + - remove_from_stack_idempotent is not changed + + - name: Query all stacks in the network + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + register: query_all + + - debug: + var: query_all + + - assert: + that: + - query_all.data is defined + - query_all is not changed + + - name: Query one stack + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + stack_id: '{{stack_id}}' + register: query_one + + - debug: + var: query_one + + - assert: + that: + - query_one.data is defined + - query_one is not changed + + - name: Query one stack using name + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + name: Test stack + register: query_one_name + + - debug: + var: query_one_name + + - assert: + that: + - query_one_name.data is defined + - query_one_name is not changed + + always: + - name: Delete stack + meraki_switch_stack: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + stack_id: '{{stack_id}}' + register: delete + + - name: Delete network + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_switch_net_name}}' + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_storm_control/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_storm_control/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_storm_control/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_storm_control/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_storm_control/tasks/main.yml new file mode 100644 index 00000000..e4f9fc10 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switch_storm_control/tasks/main.yml @@ -0,0 +1,107 @@ +# Test code for the Meraki modules +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) +--- +- block: + - name: Create switch network + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: Home - Switch + timezone: America/Chicago + type: switch + delegate_to: localhost + register: net + + - set_fact: + net_id: '{{net.data.id}}' + + - name: Add device to network + meraki_device: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: Home - Switch + serial: '{{serial_switch_l3}}' + delegate_to: localhost + + - name: Reset data + meraki_switch_storm_control: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: Home - Switch + broadcast_threshold: 100 + multicast_threshold: 100 + unknown_unicast_threshold: 100 + delegate_to: localhost + + - name: Set broadcast settings + meraki_switch_storm_control: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: Home - Switch + broadcast_threshold: 75 + multicast_threshold: 70 + unknown_unicast_threshold: 65 + delegate_to: localhost + register: set_all + + - assert: + that: + - set_all is changed + - set_all.data is defined + - set_all.diff is defined + - set_all.diff.before is defined + - set_all.diff.after is defined + - '{{set_all.data.broadcast_threshold}} == 75' + - '{{set_all.data.multicast_threshold}} == 70' + - '{{set_all.data.unknown_unicast_threshold}} == 65' + + - name: Set broadcast settings with idempotency + meraki_switch_storm_control: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: Home - Switch + broadcast_threshold: 75 + multicast_threshold: 70 + unknown_unicast_threshold: 65 + delegate_to: localhost + register: set_all_idempotent + + - assert: + that: + - set_all_idempotent is not changed + - set_all_idempotent.data is defined + - '{{set_all_idempotent.data.broadcast_threshold}} == 75' + - '{{set_all_idempotent.data.multicast_threshold}} == 70' + - '{{set_all_idempotent.data.unknown_unicast_threshold}} == 65' + + - name: Query storm control settings + meraki_switch_storm_control: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: Home - Switch + delegate_to: localhost + register: query_all + + - debug: + var: query_all + + - assert: + that: + - query_all.data is defined + + # always: + # - name: Delete switch network + # meraki_network: + # auth_key: '{{ auth_key }}' + # state: absent + # org_name: '{{test_org_name}}' + # net_name: Home - Switch + # delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switchport/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switchport/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switchport/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switchport/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switchport/tasks/main.yml new file mode 100644 index 00000000..06f0dcfe --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_switchport/tasks/main.yml @@ -0,0 +1,354 @@ +# 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 switchports + meraki_switchport: + auth_key: '{{auth_key}}' + state: query + serial: '{{ serial_switch }}' + delegate_to: localhost + register: query_all + +- debug: + msg: '{{query_all}}' + +- name: Query one switchport + meraki_switchport: + auth_key: '{{auth_key}}' + state: query + serial: '{{ serial_switch }}' + number: 1 + delegate_to: localhost + register: query_one + +- debug: + msg: '{{query_one}}' + +- name: Enable switchport with check mode + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + delegate_to: localhost + check_mode: yes + register: update_port_true_check + +- debug: + msg: '{{update_port_true_check}}' + +- assert: + that: + - update_port_true_check is changed + - update_port_true_check.data is defined + +- name: Enable switchport + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + delegate_to: localhost + register: update_port_true + +- debug: + msg: '{{update_port_true}}' + +- assert: + that: + - update_port_true.data.enabled == True + +- name: Disable switchport + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: false + delegate_to: localhost + register: update_port_false + +- debug: + msg: '{{update_port_false}}' + +- assert: + that: + - update_port_false.data.enabled == False + + +- name: Name switchport + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + name: Test Port + delegate_to: localhost + register: update_port_name + +- debug: + msg: '{{update_port_name}}' + +- assert: + that: + - update_port_name.data.name == 'Test Port' + +- name: Configure access port with check mode + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Test Port + tags: desktop + type: access + vlan: 10 + delegate_to: localhost + check_mode: yes + register: update_access_port_changed + +- debug: + msg: '{{update_access_port_changed}}' + +- assert: + that: + - update_access_port_changed is changed + - update_access_port_changed.data is defined + +- name: Configure access port + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Test Port + tags: desktop + type: access + vlan: 10 + delegate_to: localhost + register: update_access_port + +- debug: + msg: '{{update_access_port}}' + +- assert: + that: + - update_access_port.data.vlan == 10 + +- name: Configure port as trunk + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 8 + enabled: true + name: Test Port + type: trunk + vlan: 10 + allowed_vlans: 10, 100, 200 + delegate_to: localhost + +- name: Convert trunk port to access + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 8 + enabled: true + name: Test Port + type: access + vlan: 10 + delegate_to: localhost + +- name: Test converted port for idempotency + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 8 + enabled: true + name: Test Port + type: access + vlan: 10 + delegate_to: localhost + register: convert_idempotent + +- assert: + that: + - convert_idempotent.changed == False + +- name: Change voice VLAN for next task + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Test Port + tags: desktop + type: access + vlan: 10 + voice_vlan: 12 + delegate_to: localhost + register: update_port_vvlan + +- name: Configure access port with voice VLAN + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Test Port + tags: desktop + type: access + vlan: 10 + voice_vlan: 11 + delegate_to: localhost + register: update_port_vvlan + +- debug: + msg: '{{update_port_vvlan}}' + +- assert: + that: + - update_port_vvlan.data.voice_vlan == 11 + - update_port_vvlan.changed == True + +- name: Check access port for idempotenty + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Test Port + tags: desktop + type: access + vlan: 10 + voice_vlan: 11 + delegate_to: localhost + register: update_port_access_idempotent + +- debug: + msg: '{{update_port_access_idempotent}}' + +- assert: + that: + - update_port_access_idempotent.changed == False + - update_port_access_idempotent.data is defined + +- name: Configure trunk port + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Server port + tags: server + type: trunk + allowed_vlans: all + vlan: 8 + delegate_to: localhost + register: update_trunk + +- debug: + msg: '{{update_trunk}}' + +- assert: + that: + - update_trunk.data.tags.0 == 'server' + - update_trunk.data.type == 'trunk' + - update_trunk.data.allowed_vlans == 'all' + +- name: Configure trunk port with specific VLANs + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Server port + tags: server + type: trunk + vlan: 8 + allowed_vlans: + - 10 + - 15 + - 20 + delegate_to: localhost + register: update_trunk + +- debug: + msg: '{{update_trunk}}' + +- assert: + that: + - update_trunk.data.tags.0 == 'server' + - update_trunk.data.type == 'trunk' + - update_trunk.data.allowed_vlans == '8,10,15,20' + +- name: Configure trunk port with specific VLANs and native VLAN + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Server port + tags: server + type: trunk + vlan: 2 + allowed_vlans: + - 10 + - 15 + - 20 + delegate_to: localhost + register: update_trunk + +- debug: + msg: '{{update_trunk}}' + +- assert: + that: + - update_trunk.data.tags.0 == 'server' + - update_trunk.data.type == 'trunk' + - update_trunk.data.allowed_vlans == '2,10,15,20' + +- name: Check for idempotency on trunk port + meraki_switchport: + auth_key: '{{auth_key}}' + state: present + serial: '{{ serial_switch }}' + number: 7 + enabled: true + name: Server port + tags: server + type: trunk + vlan: 2 + allowed_vlans: + - 10 + - 15 + - 20 + delegate_to: localhost + register: update_trunk_idempotent + +- debug: + msg: '{{update_trunk_idempotent}}' + +- assert: + that: + - update_trunk_idempotent.changed == False + - update_trunk_idempotent.data is defined diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_syslog/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_syslog/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_syslog/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_syslog/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_syslog/tasks/main.yml new file mode 100644 index 00000000..397d1d72 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_syslog/tasks/main.yml @@ -0,0 +1,153 @@ +# 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - set_fact: + syslog_test_net_name: 'syslog_{{test_net_name}}' + + - name: Create network with type appliance and no timezone + meraki_network: + auth_key: '{{ auth_key }}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + type: appliance + delegate_to: localhost + register: new_net + + - set_fact: + net_id: '{{new_net.data.id}}' + + - name: Query syslog settings + meraki_syslog: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + delegate_to: localhost + register: query_all + + - name: Set syslog server + meraki_syslog: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + servers: + - host: 192.0.1.2 + port: 514 + roles: + - Appliance event log + delegate_to: localhost + register: create_server + + - assert: + that: + - create_server['data']['servers'][0]['host'] == "192.0.1.2" + + - name: Set syslog server with idempotency + meraki_syslog: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + servers: + - host: 192.0.1.2 + port: 514 + roles: + - Appliance event log + delegate_to: localhost + register: create_server_idempotency + + - assert: + that: + - create_server_idempotency.changed == False + - create_server_idempotency.data is defined + + - name: Set multiple syslog servers + meraki_syslog: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_id: '{{net_id}}' + state: present + servers: + - host: 192.0.1.3 + port: 514 + roles: + - Appliance event log + - host: 192.0.1.4 + port: 514 + roles: + - Appliance event log + - Flows + - host: 192.0.1.5 + port: 514 + roles: + - Flows + delegate_to: localhost + register: create_multiple_servers + + - assert: + that: + - create_multiple_servers['data']['servers'][0]['host'] == "192.0.1.3" + - create_multiple_servers['data']['servers'][1]['host'] == "192.0.1.4" + - create_multiple_servers['data']['servers'][2]['host'] == "192.0.1.5" + - create_multiple_servers['data']['servers'] | length == 3 + + - name: Create syslog server with bad name + meraki_syslog: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + servers: + - host: 192.0.1.6 + port: 514 + roles: + - Invalid role + delegate_to: localhost + register: invalid_role + ignore_errors: yes + + - assert: + that: + - '"Invalid role found in servers" in invalid_role.msg' + + - name: Add role to existing syslog server # Adding doesn't work, just creation + meraki_syslog: + auth_key: '{{auth_key}}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: present + servers: + - host: 192.0.1.2 + port: 514 + roles: + - Flows + delegate_to: localhost + register: add_role + + - debug: + msg: '{{add_role.data}}' + + - assert: + that: + - add_role.data.servers.0.roles.0 == 'Flows' + + always: + - name: Delete syslog test network + meraki_network: + auth_key: '{{ auth_key }}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + delegate_to: localhost + register: delete_all + ignore_errors: yes diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_vlan/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_vlan/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_vlan/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_vlan/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_vlan/tasks/main.yml new file mode 100644 index 00000000..568ee680 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_vlan/tasks/main.yml @@ -0,0 +1,471 @@ +# Test code for the Meraki VLAN 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) +--- +- block: + - name: Test an API key is provided + fail: + msg: Please define an API key + when: auth_key is not defined + + - name: Create test network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + type: appliance + delegate_to: localhost + + - name: Enable VLANs on network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + enable_vlans: yes + delegate_to: localhost + + - name: Create VLAN in check mode + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.1 + delegate_to: localhost + register: create_vlan_check + check_mode: yes + + - debug: + var: create_vlan_check + + - assert: + that: + - create_vlan_check is changed + + - name: Create VLAN + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.1 + delegate_to: localhost + register: create_vlan + environment: + ANSIBLE_MERAKI_FORMAT: camelcase + + - debug: + msg: '{{create_vlan}}' + + - assert: + that: + - create_vlan.data.id == 2 + - create_vlan.changed == True + - create_vlan.data.networkId is defined + + - name: Update VLAN with check mode + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + fixed_ip_assignments: + - mac: "13:37:de:ad:be:ef" + ip: 192.168.250.10 + name: fixed_ip + reserved_ip_range: + - start: 192.168.250.10 + end: 192.168.250.20 + comment: reserved_range + dns_nameservers: opendns + delegate_to: localhost + register: update_vlan_check + check_mode: yes + + - debug: + var: update_vlan_check + + - assert: + that: + - update_vlan_check is changed + + - name: Update VLAN + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + fixed_ip_assignments: + - mac: "13:37:de:ad:be:ef" + ip: 192.168.250.10 + name: fixed_ip + reserved_ip_range: + - start: 192.168.250.10 + end: 192.168.250.20 + comment: reserved_range + dns_nameservers: opendns + delegate_to: localhost + register: update_vlan + + - debug: + msg: '{{update_vlan}}' + + - assert: + that: + - update_vlan.data.appliance_ip == '192.168.250.2' + - update_vlan.changed == True + + - name: Update VLAN with idempotency and check mode + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + fixed_ip_assignments: + - mac: "13:37:de:ad:be:ef" + ip: 192.168.250.10 + name: fixed_ip + reserved_ip_range: + - start: 192.168.250.10 + end: 192.168.250.20 + comment: reserved_range + dns_nameservers: opendns + delegate_to: localhost + register: update_vlan_idempotent_check + check_mode: yes + + - debug: + var: update_vlan_idempotent_check + + - assert: + that: + - update_vlan_idempotent_check is not changed + + - name: Update VLAN with idempotency + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + fixed_ip_assignments: + - mac: "13:37:de:ad:be:ef" + ip: 192.168.250.10 + name: fixed_ip + reserved_ip_range: + - start: 192.168.250.10 + end: 192.168.250.20 + comment: reserved_range + dns_nameservers: opendns + delegate_to: localhost + register: update_vlan_idempotent + + - debug: + msg: '{{update_vlan_idempotent}}' + + - assert: + that: + - update_vlan_idempotent.changed == False + - update_vlan_idempotent.data is defined + + - name: Add IP assignments and reserved IP ranges + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + fixed_ip_assignments: + - mac: "13:37:de:ad:be:ef" + ip: 192.168.250.10 + name: fixed_ip + - mac: "12:34:56:78:90:12" + ip: 192.168.250.11 + name: another_fixed_ip + reserved_ip_range: + - start: 192.168.250.10 + end: 192.168.250.20 + comment: reserved_range + - start: 192.168.250.100 + end: 192.168.250.120 + comment: reserved_range_high + dns_nameservers: opendns + delegate_to: localhost + register: update_vlan_add_ip + + - debug: + msg: '{{update_vlan_add_ip}}' + + - assert: + that: + - update_vlan_add_ip.changed == True + - update_vlan_add_ip.data.fixed_ip_assignments | length == 2 + - update_vlan_add_ip.data.reserved_ip_ranges | length == 2 + + - name: Remove IP assignments and reserved IP ranges + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + fixed_ip_assignments: + - mac: "13:37:de:ad:be:ef" + ip: 192.168.250.10 + name: fixed_ip + reserved_ip_range: + - start: 192.168.250.10 + end: 192.168.250.20 + comment: reserved_range + dns_nameservers: opendns + delegate_to: localhost + register: update_vlan_remove_ip + + - debug: + msg: '{{update_vlan_remove_ip}}' + + - assert: + that: + - update_vlan_remove_ip.changed == True + - update_vlan_remove_ip.data.fixed_ip_assignments | length == 1 + - update_vlan_remove_ip.data.reserved_ip_ranges | length == 1 + + - name: Update VLAN with idempotency + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + fixed_ip_assignments: + - mac: "13:37:de:ad:be:ef" + ip: 192.168.250.10 + name: fixed_ip + reserved_ip_range: + - start: 192.168.250.10 + end: 192.168.250.20 + comment: reserved_range + dns_nameservers: opendns + delegate_to: localhost + register: update_vlan_idempotent + + - debug: + msg: '{{update_vlan_idempotent}}' + + - assert: + that: + - update_vlan_idempotent.changed == False + - update_vlan_idempotent.data is defined + + - name: Update VLAN with list of DNS entries + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + fixed_ip_assignments: + - mac: "13:37:de:ad:be:ef" + ip: 192.168.250.10 + name: fixed_ip + reserved_ip_range: + - start: 192.168.250.10 + end: 192.168.250.20 + comment: reserved_range + dns_nameservers: 1.1.1.1;8.8.8.8 + delegate_to: localhost + register: update_vlan_dns_list + + - debug: + msg: '{{update_vlan_dns_list}}' + + - assert: + that: + - '"1.1.1.1" in update_vlan_dns_list.data.dns_nameservers' + - update_vlan_dns_list.changed == True + + - name: Enable DHCP Relay on VLAN + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + dhcp_handling: relay + dhcp_relay_server_ips: + - 192.168.100.1 + delegate_to: localhost + register: enable_relay + + - debug: + var: enable_relay + + - assert: + that: + - enable_relay is changed + - enable_relay.data.dhcp_handling == 'Relay DHCP to another server' + - enable_relay.data.dhcp_relay_server_ips[0] == '192.168.100.1' + + - name: Enable DHCP on VLAN + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + dhcp_handling: server + delegate_to: localhost + register: enable_dhcp + + - debug: + var: enable_dhcp + + - assert: + that: + - enable_dhcp is changed + - enable_dhcp.data.dhcp_handling == 'Run a DHCP server' + + - name: Enable DHCP on VLAN with options + meraki_vlan: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + name: TestVLAN + subnet: 192.168.250.0/24 + appliance_ip: 192.168.250.2 + dhcp_handling: server + dhcp_lease_time: 1 hour + dhcp_boot_options_enabled: false + dhcp_options: + - code: 5 + type: ip + value: 192.0.1.1 + delegate_to: localhost + register: enable_dhcp_options + + - assert: + that: + - enable_dhcp_options is changed + - enable_dhcp_options.data.dhcp_handling == 'Run a DHCP server' + - enable_dhcp_options.data.dhcp_options.0.code == '5' + + - name: Query all VLANs in network + meraki_vlan: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + state: query + delegate_to: localhost + register: query_vlans + + - debug: + msg: '{{query_vlans}}' + + - assert: + that: + - query_vlans.data | length >= 2 + - query_vlans.data.1.id == 2 + - query_vlans.changed == False + + - name: Query single VLAN + meraki_vlan: + auth_key: '{{ auth_key }}' + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + state: query + output_level: debug + delegate_to: localhost + register: query_vlan + + - debug: + msg: '{{query_vlan}}' + + - assert: + that: + - query_vlan.data.id == 2 + - query_vlan.changed == False + + always: + ############################################################################# + # Tear down starts here + ############################################################################# + - name: Delete VLAN with check mode + meraki_vlan: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + delegate_to: localhost + register: delete_vlan_check + check_mode: yes + + - assert: + that: + delete_vlan_check is changed + + - name: Delete VLAN + meraki_vlan: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + vlan_id: 2 + delegate_to: localhost + register: delete_vlan + + - debug: + msg: '{{delete_vlan}}' + + - name: Delete test network + meraki_network: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + delegate_to: localhost diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/aliases b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/aliases new file mode 100644 index 00000000..ad7ccf7a --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/aliases @@ -0,0 +1 @@ +unsupported diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/tasks/main.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/tasks/main.yml new file mode 100644 index 00000000..f671fc92 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/tasks/main.yml @@ -0,0 +1,7 @@ +# Test code for the Meraki Webhooks 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: Run test cases + include: tests.yml ansible_connection=local diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/tasks/tests.yml b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/tasks/tests.yml new file mode 100644 index 00000000..0791feaf --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/integration/targets/meraki_webhook/tasks/tests.yml @@ -0,0 +1,274 @@ +# Test code for the Meraki Webhook module +# Copyright: (c) 2019, Kevin Breit (@kbreit) + +# 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: Create test network + meraki_network: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + type: appliance + + - name: Create webhook with check mode + meraki_webhook: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + name: Test_Hook + url: https://webhook.site/8eb5b76f-b167-4cb8-9fc4-42621b724244 + shared_secret: shhhdonttellanyone + check_mode: yes + register: create_one_check + + - debug: + var: create_one_check + + - assert: + that: + - create_one_check is changed + - create_one_check.data is defined + + - name: Create webhook + meraki_webhook: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + name: Test_Hook + url: https://webhook.site/8eb5b76f-b167-4cb8-9fc4-42621b724244 + shared_secret: shhhdonttellanyone + register: create_one + + - debug: + var: create_one + + - assert: + that: + - create_one is changed + - create_one.data is defined + + - set_fact: + webhook_id: '{{create_one.data.id}}' + + # - name: Query one webhook + # meraki_webhook: + # auth_key: '{{auth_key}}' + # state: query + # org_name: '{{test_org_name}}' + # net_name: '{{test_net_name}}' + # name: Test_Hook + # register: query_one + + # - debug: + # var: query_one + + # - assert: + # that: + # - query_one.data is defined + + # - name: Query one webhook with id + # meraki_webhook: + # auth_key: '{{auth_key}}' + # state: query + # org_name: '{{test_org_name}}' + # net_name: '{{test_net_name}}' + # webhook_id: '{{webhook_id}}' + # register: query_one_id + + # - debug: + # var: query_one_id + + # - assert: + # that: + # - query_one_id.data is defined + + # - name: Update webhook with check mode + # meraki_webhook: + # auth_key: '{{auth_key}}' + # state: present + # org_name: '{{test_org_name}}' + # net_name: '{{test_net_name}}' + # name: Test_Hook + # url: https://webhook.site/8eb5b76f-b167-4cb8-9fc4-42621b724244 + # shared_secret: shhhdonttellanyonehere + # check_mode: yes + # register: update_check + + # - assert: + # that: + # - update_check is changed + # - update_check.data is defined + + - name: Update webhook + meraki_webhook: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + name: Test_Hook + url: https://webhook.site/8eb5b76f-b167-4cb8-9fc4-42621b724244 + shared_secret: shhhdonttellanyonehere + register: update + + - debug: + var: update + + - assert: + that: + - update is changed + - update.data is defined + - update.diff.before.shared_secret == 'VALUE_SPECIFIED_IN_NO_LOG_PARAMETER' + + - name: Update webhook with idempotency + meraki_webhook: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + name: Test_Hook + url: https://webhook.site/8eb5b76f-b167-4cb8-9fc4-42621b724244 + shared_secret: shhhdonttellanyonehere + register: update_idempotent + + - debug: + var: update_idempotent + + - assert: + that: + - update_idempotent is not changed + - update_idempotent.data is defined + + - name: Update webhook with id + meraki_webhook: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + webhook_id: '{{webhook_id}}' + name: Test_Hook + url: https://webhook.site/8eb5b76f-b167-4cb8-9fc4-42621b724244 + shared_secret: shhhdonttellanyonehereid + register: update_id + + - debug: + var: update_id + + - assert: + that: + - update_id is changed + - update_id.data is defined + + - name: Create test webhook + meraki_webhook: + auth_key: '{{auth_key}}' + state: present + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + name: Test_Hook + test: test + url: https://webhook.site/8eb5b76f-b167-4cb8-9fc4-42621b724244 + register: webhook_test + + - set_fact: + test_id: '{{webhook_test.data.id}}' + + - debug: + var: test_id + + - name: Get webhook status + meraki_webhook: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + test_id: '{{test_id}}' + register: webhook_test_status + + - debug: + var: webhook_test_status + + - assert: + that: + - webhook_test_status.data is defined + + - name: Query all webhooks + meraki_webhook: + auth_key: '{{auth_key}}' + state: query + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + register: query_all + + - debug: + var: query_all + + - name: Delete webhook invalid webhook + meraki_webhook: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + name: Test_Hook_Invalid + check_mode: yes + register: delete_invalid + ignore_errors: yes + + - debug: + var: delete_invalid + + - assert: + that: + - 'delete_invalid.msg == "There is no webhook with the name Test_Hook_Invalid"' + + - name: Delete webhook in check mode + meraki_webhook: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + name: Test_Hook + check_mode: yes + register: delete_check + + - debug: + var: delete_check + + - assert: + that: + - delete_check is changed + + - name: Delete webhook + meraki_webhook: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' + name: Test_Hook + register: delete + + - debug: + var: delete + + - assert: + that: + - delete is changed + + ############################################################################# + # Tear down starts here + ############################################################################# + always: + - name: Delete test network + meraki_network: + auth_key: '{{auth_key}}' + state: absent + org_name: '{{test_org_name}}' + net_name: '{{test_net_name}}' diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.10.txt new file mode 100644 index 00000000..e15daac0 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.10.txt @@ -0,0 +1,2 @@ +plugins/modules/meraki_mx_intrusion_prevention.py validate-modules:invalid-argument-name +plugins/modules/meraki_mx_intrusion_prevention.py validate-modules:nonexistent-parameter-documented
\ No newline at end of file diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.11.txt b/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.11.txt new file mode 100644 index 00000000..f6906e11 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.11.txt @@ -0,0 +1,2 @@ +plugins/modules/meraki_mx_intrusion_prevention.py validate-modules:invalid-argument-name +plugins/modules/meraki_mx_intrusion_prevention.py validate-modules:nonexistent-parameter-documented diff --git a/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.9.txt b/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.9.txt new file mode 100644 index 00000000..00914499 --- /dev/null +++ b/collections-debian-merged/ansible_collections/cisco/meraki/tests/sanity/ignore-2.9.txt @@ -0,0 +1,2 @@ +plugins/modules/meraki_intrusion_prevention.py invalid-argument-name # ignore missing argument +plugins/modules/meraki_intrusion_prevention.py nonexistent-parameter-documented # ignore missing argument |