Skip to content
tbotnz edited this page Aug 27, 2020 · 9 revisions

Welcome to the netpalm wiki!

Examples

Ansible

props to @brobare

---
- hosts: localhost
  gather_facts: false
  vars:
    device_ip: device_ip_here
    device_username: username_here
    device_password: password_here
    netpalm_ip: netpalm_ip_here
    netpalm_port: 9000
    netpalm_api_key: api_key_here
  tasks:
    - name: Test netpalm from ansible
      uri:
        url: http://{{ netpalm_ip }}:{{ netpalm_port }}/getconfig
        headers:
          x-api-key: "{{ netpalm_api_key }}"
        return_content: true
        method: POST
        status_code: 200,201
        body_format: json
        body:
          {
            "library": "napalm",
            "connection_args": {
              "device_type": "cisco_ios",
              "host": "{{ device_ip }}",
              "username": "{{ device_username }}",
              "password": "{{ device_password }}"
            },
            "command": "show version",
            "args": {
              "use_textfsm": true
            },
            "webhook": {
              "name": "default_webhook",
              "args": {
                "netpalm": "is neat"
              }
            },
           "queue_strategy": "fifo"
         }
      register: netpalm_response
    - name: setting a fact for the task_id
      set_fact:
        task_id: "{{ netpalm_response.json.data.task_id }}"
    - name: gather results
      uri:
        url: http://{{ netpalm_ip }}:{{ netpalm_port }}/task/{{ task_id }}
        headers:
          x-api-key: "{{ netpalm_api_key }}"
        return_content: true
        method: GET
        status_code: 200,201
        body_format: json
      register: netpalm_task_results
      until: netpalm_task_results.json.data.task_status == "finished"
      retries: 10
      delay: 3
Clone this wiki locally