QuestionQ92

VerifiedController-Based Network Automation

An engineer must audit Cisco Catalyst Center-managed devices to verify configuration-sync status. The engineer must authenticate, GET the device list, and return the JSON content into a registered variable for later checks. Drag the code snippets into the boxes to construct the artifact. Not every option is used. Options can be used more than once.

Drag & Drop
---
- name: Get Catalyst Center devices
  hosts: localhost
  gather_facts: false
  vars:
    base: "https://198.51.100.10"
    user: "dnac"
    pass: "C1sco12345"
  tasks:
    - name: Token
      :
        url: "{{base}}/dna/system/api/v1/auth/token"
        : POST
        user: "{{user}}"
        password: "{{pass}}"
        force_basic_auth: true
        validate_certs: false
      register: tok

    - name: Inventory
      uri:
        url: "{{base}}/dna/intent/api/v1/network-device"
        : GET
        headers:
          X-Auth-Token: "{{ tok.json.Token }}"
        : true
        validate_certs: false
      : devices
Explanation

Ansible's uri module performs HTTP/HTTPS requests. method selects POST for authentication and GET for the device list. return_content: true includes the response body, and register: devices stores the task result for later checks.

Learn more

Community Discussion

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