QuestionQ44

Controller-Based Network Automation

An engineer needs to configure VLANs on a Meraki network through the Dashboard API. The engineer must enable VLANs and update VLAN 20 with the specified subnet and appliance IP by using two PUT requests. Drag the code snippets from the bottom into the boxes to build the artifact. Not all options are used.

Drag & Drop
---
- name: Configure Meraki VLANs
  hosts: localhost
  gather_facts: false
  vars:
    base: "https://api.meraki.com/api/v1"
    network_id: "N_1234567890"
    api_key: "abcd1234"
  tasks:
    - name: Enable VLANs
      :
        url: "{{base}}/networks/{{network_id}}/appliance/vlans/settings"
        : PUT
        headers:
          X-Cisco-Meraki-API-Key: "{{api_key}}"
          Accept: "application/json"
          Content-Type: "application/json"
        : json
        body: { vlansEnabled: true }

    - name: Configure VLAN 20
      uri:
        : "{{base}}/networks/{{network_id}}/appliance/vlans/20"
        method: PUT
        headers:
          X-Cisco-Meraki-API-Key: "{{api_key}}"
          Accept: "application/json"
          Content-Type: "application/json"
        body_format: json
        body: { name: "Mgmt", id: "20", subnet: "10.20.0.0/24", applianceIp: "10.20.0.1" }
Explanation

Ansible’s uri module performs HTTP requests. Its url parameter identifies the API endpoint, method: PUT selects the required update operation, and body_format: json serializes the request body as JSON. The Meraki VLAN settings and VLAN 20 endpoints are both updated with PUT requests.

Community Discussion

No comments yet. Be the first to start the discussion!