Skip to content

Instantly share code, notes, and snippets.

@ntwrkguru
Last active June 7, 2019 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ntwrkguru/16fdde046ac2e7bc4563361a16fe9fcd to your computer and use it in GitHub Desktop.
Save ntwrkguru/16fdde046ac2e7bc4563361a16fe9fcd to your computer and use it in GitHub Desktop.

Inventory

---
all:
  hosts:
    switch1:
      ansible_ssh_host: 192.168.1.202
  vars:
    ansible_port: 22
    ansible_connection: netconf
    ansible_network_os: junos
    ansible_python_interpreter: "/usr/local/opt/python/libexec/bin/python"

Failing scenario

Playbook

---
- hosts: all
  connection: netconf
  gather_facts: no
  tasks:
  - name: Enabling NETCONF if not enabled
    vars:
      ansible_connection: network_cli
    junos_netconf:
      netconf_port: 22
      state: present

Output

$ ansible-playbook -i inventory.yaml upgrade.yaml 

PLAY [all] ****************************************************************************************************************************

TASK [Enabling NETCONF if not enabled] ************************************************************************************************
fatal: [switch1]: FAILED! => {"changed": false, "msg": "Connection type 'netconf' is not valid for 'junos_netconf' module. Please see https://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html"}

PLAY RECAP ****************************************************************************************************************************
switch1                    : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Passing scenario

Playbook

---
- hosts: all
  connection: netconf
  gather_facts: no
  tasks:
  - name: Enabling NETCONF if not enabled
    connection: network_cli
    junos_netconf:
      netconf_port: 22
      state: present

Output

$ ansible-playbook -i inventory.yaml upgrade.yaml 

PLAY [all] ****************************************************************************************************************************

TASK [Enabling NETCONF if not enabled] ************************************************************************************************
ok: [switch1]

PLAY RECAP ****************************************************************************************************************************
switch1                    : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment