List of switch port configurations.
Device serial number.
The state of the resource.
A template task showing all available parameters with their defaults or example values.
- name: Meraki Switch Ports task cisco.meraki_rm.meraki_switch_ports: serial: "serial_value" config: - access_policy_number: 0 access_policy_type: "access_policy_type_value" adaptive_policy_group_id: "root" allowed_vlans: 100 dai_trusted: true enabled: true flexible_stacking_enabled: true isolation_enabled: true link_negotiation: "link_negotiation_value" name: "example_name" peer_sgt_capable: true poe_enabled: true port_id: 22 port_schedule_id: 22 profile: {} rstp_enabled: true sticky_mac_allow_list: - "sticky_mac_allow_list_item" sticky_mac_allow_list_limit: 0 storm_control_enabled: true stp_guard: disabled tags: - "tags_item" type: access udld: Alert only vlan: 0 voice_vlan: 0 state: merged
- name: Meraki Switch Ports task cisco.meraki_rm.meraki_switch_ports: serial: "serial_value" config: # optional - access_policy_number: 0 # optional access_policy_type: "access_policy_type_value" # optional adaptive_policy_group_id: "root" # optional allowed_vlans: 100 # optional dai_trusted: true # optional enabled: true # optional flexible_stacking_enabled: true # optional isolation_enabled: true # optional link_negotiation: "link_negotiation_value" # optional name: "example_name" # optional peer_sgt_capable: true # optional poe_enabled: true # optional port_id: 22 # optional port_schedule_id: 22 # optional profile: {} # optional rstp_enabled: true # optional sticky_mac_allow_list: # optional - "sticky_mac_allow_list_item" sticky_mac_allow_list_limit: 0 # optional storm_control_enabled: true # optional stp_guard: disabled # optional tags: # optional - "tags_item" type: access # optional udld: Alert only # optional vlan: 0 # optional voice_vlan: 0 # optional state: merged # optional
- name: Meraki Switch Ports task cisco.meraki_rm.meraki_switch_ports: serial: "serial_value" # (str, required) Device serial number. config: # (list, optional) List of switch port configurations. - access_policy_number: 0 # (int, optional) Access policy number. access_policy_type: "access_policy_type_value" # (str, optional) Access policy type. adaptive_policy_group_id: "root" # (str, optional) Adaptive policy group ID. allowed_vlans: 100 # (str, optional) Allowed VLANs (for trunk ports). dai_trusted: true # (bool, optional) DAI trusted. enabled: true # (bool, optional) Whether the port is enabled. flexible_stacking_enabled: true # (bool, optional) Flexible stacking enabled. isolation_enabled: true # (bool, optional) Port isolation enabled. link_negotiation: "link_negotiation_value" # (str, optional) Link speed negotiation. name: "example_name" # (str, optional) Port name. peer_sgt_capable: true # (bool, optional) Peer SGT capable. poe_enabled: true # (bool, optional) Power over Ethernet enabled. port_id: 22 # (str, optional) Port number/ID. port_schedule_id: 22 # (str, optional) Port schedule ID. profile: {} # (dict, optional) Port profile. rstp_enabled: true # (bool, optional) RSTP enabled. sticky_mac_allow_list: # (list, optional) Sticky MAC allow list. - "sticky_mac_allow_list_item" sticky_mac_allow_list_limit: 0 # (int, optional) Sticky MAC allow list limit. storm_control_enabled: true # (bool, optional) Storm control enabled. stp_guard: disabled # (str, optional) STP guard setting. tags: # (list, optional) Tags for the port. - "tags_item" type: access # (str, optional) Port type. udld: Alert only # (str, optional) Unidirectional Link Detection action. vlan: 0 # (int, optional) VLAN number. voice_vlan: 0 # (int, optional) Voice VLAN number. state: merged # (str, optional) The state of the resource.
- name: Define expected configuration ansible.builtin.set_fact: expected_config: port_id: "1" name: Test-Config tags: - ansible - test enabled: true type: access vlan: 1 voice_vlan: 100 allowed_vlans: all
- name: Create switch_ports with merged state cisco.meraki_rm.meraki_switch_ports: serial: "Q2XX-XXXX-XXXX" state: merged config: - "{{ expected_config }}" register: merge_result
- name: Assert resource was created ansible.builtin.assert: that: - merge_result is changed - merge_result.config | length == 1
- name: Compare expected paths to result (subset check) ansible.builtin.set_fact: path_check: "{{ expected_paths | cisco.meraki_rm.path_contained_in(result_paths) }}" vars: expected_paths: "{{ expected_config | ansible.utils.to_paths }}" result_paths: "{{ merge_result.config[0] | ansible.utils.to_paths }}"
- name: Assert all expected fields are present and match ansible.builtin.assert: that: path_check.contained | bool success_msg: "{{ success_msg }}" fail_msg: "{{ fail_msg }}" vars: success_msg: "All expected fields match. Extras: {{ path_check.extras }}" fail_msg: "Missing or mismatch: {{ path_check.missing }}. Extras: {{ path_check.extras }}"
- name: Define replacement configuration ansible.builtin.set_fact: expected_config: port_id: "1" name: Replaced-Config tags: - ansible - replaced enabled: false type: trunk vlan: 20 voice_vlan: 100 allowed_vlans: all
- name: Replace switch_ports configuration cisco.meraki_rm.meraki_switch_ports: serial: "Q2XX-XXXX-XXXX" state: replaced config: - "{{ expected_config }}" register: replace_result
- name: Assert resource was replaced ansible.builtin.assert: that: - replace_result is changed - replace_result.config | length == 1
- name: Compare expected paths to result (subset check) ansible.builtin.set_fact: path_check: "{{ expected_paths | cisco.meraki_rm.path_contained_in(result_paths) }}" vars: expected_paths: "{{ expected_config | ansible.utils.to_paths }}" result_paths: "{{ replace_result.config[0] | ansible.utils.to_paths }}"
- name: Assert all expected fields are present and match ansible.builtin.assert: that: path_check.contained | bool success_msg: "{{ success_msg }}" fail_msg: "{{ fail_msg }}" vars: success_msg: "All expected fields match. Extras: {{ path_check.extras }}" fail_msg: "Missing or mismatch: {{ path_check.missing }}. Extras: {{ path_check.extras }}"
- name: Gather current switch_ports configuration cisco.meraki_rm.meraki_switch_ports: serial: "Q2XX-XXXX-XXXX" state: gathered register: gathered
- name: Assert gathered config is not empty ansible.builtin.assert: that: - gathered.config is defined - gathered.config | length > 0 fail_msg: "Gathered config is empty — expected at least one resource"
- name: Display gathered configuration ansible.builtin.debug: var: gathered.config
--- # Manage Meraki switch port configuration — create or update - name: Define expected configuration ansible.builtin.set_fact: expected_config: port_id: "1" name: Test-Config tags: - ansible - test enabled: true type: access vlan: 1 voice_vlan: 100 allowed_vlans: all - name: Create switch_ports with merged state cisco.meraki_rm.meraki_switch_ports: serial: "Q2XX-XXXX-XXXX" state: merged config: - "{{ expected_config }}" register: merge_result - name: Assert resource was created ansible.builtin.assert: that: - merge_result is changed - merge_result.config | length == 1 - name: Compare expected paths to result (subset check) ansible.builtin.set_fact: path_check: "{{ expected_paths | cisco.meraki_rm.path_contained_in(result_paths) }}" vars: expected_paths: "{{ expected_config | ansible.utils.to_paths }}" result_paths: "{{ merge_result.config[0] | ansible.utils.to_paths }}" - name: Assert all expected fields are present and match ansible.builtin.assert: that: path_check.contained | bool success_msg: "{{ success_msg }}" fail_msg: "{{ fail_msg }}" vars: success_msg: "All expected fields match. Extras: {{ path_check.extras }}" fail_msg: "Missing or mismatch: {{ path_check.missing }}. Extras: {{ path_check.extras }}" # Manage Meraki switch port configuration — full resource replacement - name: Define replacement configuration ansible.builtin.set_fact: expected_config: port_id: "1" name: Replaced-Config tags: - ansible - replaced enabled: false type: trunk vlan: 20 voice_vlan: 100 allowed_vlans: all - name: Replace switch_ports configuration cisco.meraki_rm.meraki_switch_ports: serial: "Q2XX-XXXX-XXXX" state: replaced config: - "{{ expected_config }}" register: replace_result - name: Assert resource was replaced ansible.builtin.assert: that: - replace_result is changed - replace_result.config | length == 1 - name: Compare expected paths to result (subset check) ansible.builtin.set_fact: path_check: "{{ expected_paths | cisco.meraki_rm.path_contained_in(result_paths) }}" vars: expected_paths: "{{ expected_config | ansible.utils.to_paths }}" result_paths: "{{ replace_result.config[0] | ansible.utils.to_paths }}" - name: Assert all expected fields are present and match ansible.builtin.assert: that: path_check.contained | bool success_msg: "{{ success_msg }}" fail_msg: "{{ fail_msg }}" vars: success_msg: "All expected fields match. Extras: {{ path_check.extras }}" fail_msg: "Missing or mismatch: {{ path_check.missing }}. Extras: {{ path_check.extras }}" # Manage Meraki switch port configuration — gather current configuration - name: Gather current switch_ports configuration cisco.meraki_rm.meraki_switch_ports: serial: "Q2XX-XXXX-XXXX" state: gathered register: gathered - name: Assert gathered config is not empty ansible.builtin.assert: that: - gathered.config is defined - gathered.config | length > 0 fail_msg: "Gathered config is empty — expected at least one resource" - name: Display gathered configuration ansible.builtin.debug: var: gathered.config