QuestionQ89
VerifiedController-Based Network AutomationAn engineer needs to authenticate to Cisco SD-WAN vManage and export the current device inventory with Ansible. The engineer must sign in, retrieve the XSRF token, query the inventory endpoint, and save the JSON to disk. Drag the code snippets into the boxes to complete the artifact. Not every option is used.
Drag & Drop
- name: Login to vManage and collect inventory : localhost gather_facts: false vars: vmanage_host: 198.51.100.10 username: netops password: C1sco12345 base: "https://{{vmanage_host}}:8443" : - name: Authenticate to vManage : : "{{base}}/j_security_check" method: POST headers: Content-Type: "application/x-www-form-urlencoded" body: "j_username={{username}}&j_password={{password}}" status_code: 200 validate_certs: false register: login - name: Get XSRF token uri: url: "{{base}}/dataservice/client/token" method: GET headers: Cookie: "{{ login.set_cookie }}" return_content: true validate_certs: false register: token - name: Fetch device inventory uri: url: "{{base}}/dataservice/device" method: GET headers: Cookie: "{{ login.set_cookie }}" X-XSRF-TOKEN: "{{ token.content }}" return_content: true validate_certs: false register: inventory - name: Save inventory to file copy: dest: "inventory.json" content: "{{ inventory.content | to_nice_json }}"
Community Discussion