100%

meraki_appliance_vlans

module
Manage Meraki appliance VLANs
Added in version 0.1.0

Synopsis

  • Manage Meraki appliance VLANs for a network.
  • Supports merged, replaced, deleted, and gathered states.

Author

Cisco Meraki

Parameters

config (list/dict)

List of VLAN configurations.

appliance_ip (str)

Appliance IP on the VLAN.

cidr (str)

CIDR for template networks.

dhcp_boot_filename (str)

DHCP boot filename.

dhcp_boot_next_server (str)

DHCP boot next server.

dhcp_boot_options_enabled (bool)

Use DHCP boot options.

dhcp_handling (str)
do_not_respondrelayrun_server

How the appliance handles DHCP requests on this VLAN.

dhcp_lease_time (str)
30_minutes1_hour4_hours12_hours1_day1_week

DHCP lease term.

dhcp_options (list/dict)

DHCP options for responses.

dhcp_relay_server_ips (list/str)

IPs of DHCP servers to relay requests to.

dns_nameservers (str)

DNS nameservers for DHCP responses.

fixed_ip_assignments (dict)

Fixed IP assignments.

group_policy_id (str)

Group policy ID.

ipv6 (dict)

IPv6 configuration.

mandatory_dhcp (dict)

Mandatory DHCP configuration.

mask (int)

Mask for template networks.

name (str)

VLAN name.

reserved_ip_ranges (list/dict)

Reserved IP ranges on the VLAN.

comment (str)
end (str)
start (str)
subnet (str)

Subnet (e.g., '192.168.1.0/24').

template_vlan_type (str)
sameunique

Type of subnetting for template networks.

vlan_id (str)

VLAN ID (1-4094). Required for merged and deleted.

network_id (str) required

The network ID.

state (str)
mergedreplacedoverriddendeletedgathered

The state of the resource.

Sample Task

A template task showing all available parameters with their defaults or example values.

- name: Meraki Appliance Vlans task
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "192.168.1.0/24"
    config:
      - appliance_ip: "192.168.1.1"
        cidr: "cidr_value"
        dhcp_boot_filename: "example_name"
        dhcp_boot_next_server: "dhcp_boot_next_server_value"
        dhcp_boot_options_enabled: true
        dhcp_handling: do_not_respond
        dhcp_lease_time: 30_minutes
        dhcp_options:
          - {}
        dhcp_relay_server_ips:
          - "dhcp_relay_server_ips_item"
        dns_nameservers: "example_name"
        fixed_ip_assignments: {}
        group_policy_id: "root"
        ipv6: {}
        mandatory_dhcp: {}
        mask: 0
        name: "example_name"
        reserved_ip_ranges:
          - comment: "comment_value"
            end: "end_value"
            start: "start_value"
        subnet: "192.168.1.0/24"
        template_vlan_type: same
        vlan_id: 100
    state: merged
- name: Meraki Appliance Vlans task
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "192.168.1.0/24"
    config:  # optional
      - appliance_ip: "192.168.1.1"  # optional
        cidr: "cidr_value"  # optional
        dhcp_boot_filename: "example_name"  # optional
        dhcp_boot_next_server: "dhcp_boot_next_server_value"  # optional
        dhcp_boot_options_enabled: true  # optional
        dhcp_handling: do_not_respond  # optional
        dhcp_lease_time: 30_minutes  # optional
        dhcp_options:  # optional
          - {}
        dhcp_relay_server_ips:  # optional
          - "dhcp_relay_server_ips_item"
        dns_nameservers: "example_name"  # optional
        fixed_ip_assignments: {}  # optional
        group_policy_id: "root"  # optional
        ipv6: {}  # optional
        mandatory_dhcp: {}  # optional
        mask: 0  # optional
        name: "example_name"  # optional
        reserved_ip_ranges:  # optional
          - comment: "comment_value"  # optional
            end: "end_value"  # optional
            start: "start_value"  # optional
        subnet: "192.168.1.0/24"  # optional
        template_vlan_type: same  # optional
        vlan_id: 100  # optional
    state: merged  # optional
- name: Meraki Appliance Vlans task
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "192.168.1.0/24"  # (str, required) The network ID.
    config:  # (list, optional) List of VLAN configurations.
      - appliance_ip: "192.168.1.1"  # (str, optional) Appliance IP on the VLAN.
        cidr: "cidr_value"  # (str, optional) CIDR for template networks.
        dhcp_boot_filename: "example_name"  # (str, optional) DHCP boot filename.
        dhcp_boot_next_server: "dhcp_boot_next_server_value"  # (str, optional) DHCP boot next server.
        dhcp_boot_options_enabled: true  # (bool, optional) Use DHCP boot options.
        dhcp_handling: do_not_respond  # (str, optional) How the appliance handles DHCP requests on this VLAN.
        dhcp_lease_time: 30_minutes  # (str, optional) DHCP lease term.
        dhcp_options:  # (list, optional) DHCP options for responses.
          - {}
        dhcp_relay_server_ips:  # (list, optional) IPs of DHCP servers to relay requests to.
          - "dhcp_relay_server_ips_item"
        dns_nameservers: "example_name"  # (str, optional) DNS nameservers for DHCP responses.
        fixed_ip_assignments: {}  # (dict, optional) Fixed IP assignments.
        group_policy_id: "root"  # (str, optional) Group policy ID.
        ipv6: {}  # (dict, optional) IPv6 configuration.
        mandatory_dhcp: {}  # (dict, optional) Mandatory DHCP configuration.
        mask: 0  # (int, optional) Mask for template networks.
        name: "example_name"  # (str, optional) VLAN name.
        reserved_ip_ranges:  # (list, optional) Reserved IP ranges on the VLAN.
          - comment: "comment_value"  # (str, optional) 
            end: "end_value"  # (str, optional) 
            start: "start_value"  # (str, optional) 
        subnet: "192.168.1.0/24"  # (str, optional) Subnet (e.g., '192.168.1.0/24').
        template_vlan_type: same  # (str, optional) Type of subnetting for template networks.
        vlan_id: 100  # (str, optional) VLAN ID (1-4094). Required for merged and deleted.
    state: merged  # (str, optional) The state of the resource.

Notes

  • Canonical key: vlan_id — user-assigned, used for both identification and API routing.

Examples

Define Expected Configuration
- name: Define expected configuration
  ansible.builtin.set_fact:
    expected_config:
      vlan_id: "100"
      name: Test-Config
      subnet: 192.168.128.0/24
      appliance_ip: 192.168.128.1
      group_policy_id: example
      template_vlan_type: same
      cidr: 192.168.128.0/24
      mask: 24
Create Appliance_vlans With Merged State
- name: Create appliance_vlans with merged state
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    state: merged
    config:
      - "{{ expected_config }}"
  register: merge_result
Assert Resource Was Created
- name: Assert resource was created
  ansible.builtin.assert:
    that:
      - merge_result is changed
      - merge_result.config | length == 1
Compare Expected Paths To Result (subset Check)
- 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 }}"
Assert All Expected Fields Are Present And Match
- 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 }}"
Task Output:
# Manage Meraki appliance VLANs — full resource replacement
Define Replacement Configuration
- name: Define replacement configuration
  ansible.builtin.set_fact:
    expected_config:
      vlan_id: "100"
      name: Replaced-Config
      subnet: 10.20.0.0/24
      appliance_ip: 10.20.0.1
      group_policy_id: example
      template_vlan_type: unique
      cidr: 192.168.128.0/24
      mask: 24
Replace Appliance_vlans Configuration
- name: Replace appliance_vlans configuration
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    state: replaced
    config:
      - "{{ expected_config }}"
  register: replace_result
Assert Resource Was Replaced
- name: Assert resource was replaced
  ansible.builtin.assert:
    that:
      - replace_result is changed
      - replace_result.config | length == 1
Compare Expected Paths To Result (subset Check)
- 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 }}"
Assert All Expected Fields Are Present And Match
- 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 }}"
Task Output:
# Manage Meraki appliance VLANs — override all instances # Ensures ONLY these resources exist; any not listed are deleted.
Define Desired-state Configuration
- name: Define desired-state configuration
  ansible.builtin.set_fact:
    expected_config:
      vlan_id: "100"
      name: Replaced-Config
      subnet: 10.20.0.0/24
      appliance_ip: 10.20.0.1
      group_policy_id: example
      template_vlan_type: unique
      cidr: 192.168.128.0/24
      mask: 24
Override All Appliance_vlans — Desired State Only
- name: Override all appliance_vlans — desired state only
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    state: overridden
    config:
      - "{{ expected_config }}"
  register: override_result
Assert Resources Were Overridden
- name: Assert resources were overridden
  ansible.builtin.assert:
    that:
      - override_result is changed
      - override_result.config | length == 1
Compare Expected Paths To Result (subset Check)
- 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: "{{ override_result.config[0] | ansible.utils.to_paths }}"
Assert All Expected Fields Are Present And Match
- 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 }}"
Task Output:
# Manage Meraki appliance VLANs — gather current configuration
Gather Current Appliance_vlans Configuration
- name: Gather current appliance_vlans configuration
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    state: gathered
  register: gathered
Assert Gathered Config Is Not Empty
- 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"
Display Gathered Configuration
- name: Display gathered configuration
  ansible.builtin.debug:
    var: gathered.config
Task Output:
# Manage Meraki appliance VLANs — remove configuration
Define Resource To Delete
- name: Define resource to delete
  ansible.builtin.set_fact:
    expected_config:
      vlan_id: "100"
Delete Appliance_vlans Configuration
- name: Delete appliance_vlans configuration
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    state: deleted
    config:
      - "{{ expected_config }}"
  register: delete_result
Assert Resource Was Deleted
- name: Assert resource was deleted
  ansible.builtin.assert:
    that:
      - delete_result is changed
      - delete_result is not failed
---
# Manage Meraki appliance VLANs — create or update

- name: Define expected configuration
  ansible.builtin.set_fact:
    expected_config:
      vlan_id: "100"
      name: Test-Config
      subnet: 192.168.128.0/24
      appliance_ip: 192.168.128.1
      group_policy_id: example
      template_vlan_type: same
      cidr: 192.168.128.0/24
      mask: 24

- name: Create appliance_vlans with merged state
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    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 appliance VLANs — full resource replacement

- name: Define replacement configuration
  ansible.builtin.set_fact:
    expected_config:
      vlan_id: "100"
      name: Replaced-Config
      subnet: 10.20.0.0/24
      appliance_ip: 10.20.0.1
      group_policy_id: example
      template_vlan_type: unique
      cidr: 192.168.128.0/24
      mask: 24

- name: Replace appliance_vlans configuration
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    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 appliance VLANs — override all instances
# Ensures ONLY these resources exist; any not listed are deleted.

- name: Define desired-state configuration
  ansible.builtin.set_fact:
    expected_config:
      vlan_id: "100"
      name: Replaced-Config
      subnet: 10.20.0.0/24
      appliance_ip: 10.20.0.1
      group_policy_id: example
      template_vlan_type: unique
      cidr: 192.168.128.0/24
      mask: 24

- name: Override all appliance_vlans — desired state only
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    state: overridden
    config:
      - "{{ expected_config }}"
  register: override_result

- name: Assert resources were overridden
  ansible.builtin.assert:
    that:
      - override_result is changed
      - override_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: "{{ override_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 appliance VLANs — gather current configuration

- name: Gather current appliance_vlans configuration
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    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 appliance VLANs — remove configuration

- name: Define resource to delete
  ansible.builtin.set_fact:
    expected_config:
      vlan_id: "100"

- name: Delete appliance_vlans configuration
  cisco.meraki_rm.meraki_appliance_vlans:
    network_id: "N_123456789012345678"
    state: deleted
    config:
      - "{{ expected_config }}"
  register: delete_result

- name: Assert resource was deleted
  ansible.builtin.assert:
    that:
      - delete_result is changed
      - delete_result is not failed

Return Values

after
list — returned: when state is merged, replaced, overridden, or deleted
Resource configuration after the run.
before
list — returned: when state is merged, replaced, overridden, or deleted
Resource configuration before the run.
config
list — returned: always
Alias for C(after) (or C(gathered) when state=gathered).
gathered
list — returned: when state is gathered
Current resource configuration (read-only).