Device configuration (one device per task).
Device serial number.
The state of the resource.
A template task showing all available parameters with their defaults or example values.
- name: Meraki Device task cisco.meraki_rm.meraki_device: serial: "serial_value" config: - address: "192.168.1.1" floor_plan_id: "floor_plan_id_value" lat: 0.0 lng: 0.0 move_map_marker: true name: "example_name" notes: "notes_value" switch_profile_id: "switch_profile_id_value" tags: - "tags_item" state: merged
- name: Meraki Device task cisco.meraki_rm.meraki_device: serial: "serial_value" config: # optional - address: "192.168.1.1" # optional floor_plan_id: "floor_plan_id_value" # optional lat: 0.0 # optional lng: 0.0 # optional move_map_marker: true # optional name: "example_name" # optional notes: "notes_value" # optional switch_profile_id: "switch_profile_id_value" # optional tags: # optional - "tags_item" state: merged # optional
- name: Meraki Device task cisco.meraki_rm.meraki_device: serial: "serial_value" # (str, required) Device serial number. config: # (list, optional) Device configuration (one device per task). - address: "192.168.1.1" # (str, optional) Physical address of the device. floor_plan_id: "floor_plan_id_value" # (str, optional) Floor plan to associate with the device. lat: 0.0 # (float, optional) Latitude of the device. lng: 0.0 # (float, optional) Longitude of the device. move_map_marker: true # (bool, optional) Set lat/lng from address. name: "example_name" # (str, optional) Name of the device. notes: "notes_value" # (str, optional) Notes for the device (max 255 chars). switch_profile_id: "switch_profile_id_value" # (str, optional) Switch template ID to bind to the device. tags: # (list, optional) List of tags for the device. - "tags_item" state: merged # (str, optional) The state of the resource.
- name: Define expected configuration ansible.builtin.set_fact: expected_config: name: Test-Config tags: - ansible - test lat: 37.7749 lng: -122.4194 address: 500 Terry Francine Street notes: example move_map_marker: true floor_plan_id: example
- name: Create device with merged state cisco.meraki_rm.meraki_device: 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: name: Replaced-Config tags: - ansible - replaced lat: 37.7749 lng: -122.4194 address: 500 Terry Francine Street notes: example move_map_marker: true floor_plan_id: example
- name: Replace device configuration cisco.meraki_rm.meraki_device: 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 device configuration cisco.meraki_rm.meraki_device: 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 device attributes — create or update - name: Define expected configuration ansible.builtin.set_fact: expected_config: name: Test-Config tags: - ansible - test lat: 37.7749 lng: -122.4194 address: 500 Terry Francine Street notes: example move_map_marker: true floor_plan_id: example - name: Create device with merged state cisco.meraki_rm.meraki_device: 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 device attributes — full resource replacement - name: Define replacement configuration ansible.builtin.set_fact: expected_config: name: Replaced-Config tags: - ansible - replaced lat: 37.7749 lng: -122.4194 address: 500 Terry Francine Street notes: example move_map_marker: true floor_plan_id: example - name: Replace device configuration cisco.meraki_rm.meraki_device: 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 device attributes — gather current configuration - name: Gather current device configuration cisco.meraki_rm.meraki_device: 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