0
votes

I'm using Ansible to push configs onto some Juniper devices. To get going, I'm trying to tweak the fact-gathering Playbook from the official demo here. I've modified the hosts file to use one of my actual Juniper devices. It appears that Ansible knows where all the Module libraries are, but for some reason it throws an error which seems to have no documentation: Netconf::OpenError

Other than using a hosts file with my own hosts, I also changed port 22 in tasks/nc_check.yml instead of port 830. This is because (so far as i know), all I have available to get into the switches is SSH (port 22)

The Juniper Modules are all written in Ruby. Here are the versions of all the dependencies I have installed:

junos-ez-stdlib (0.1.2)
mini_portile (0.5.2)
net-scp (1.1.2)
net-ssh (2.7.0)
netconf (0.3.1)
nokogiri (1.6.0)
serialport (1.2.3)

Below is the output from running the same playbook provided by the demo. My questions are:

  1. What seems to be causing the Netconf::OpenError error?
  2. Should I expect to use a different port for Netconf on a Juniper switch? What would I look at in the Juniper config to know what port to use? (EX4200 and EX4500)

    ansible-playbook junos/get_junos_facts.yml -i hosts -vvv

    PLAY [Display Junos Facts, make sure you use -v] ****************

    TASK: [Checking NETCONF reachablility to device] **************** <10.113.7.002> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-1384993979.41-2345029032433 && chmod a+rx $HOME/.ansible/tmp/ansible-1384993979.41-2345029032433 && echo $HOME/.ansible/tmp/ansible-1384993979.41-2345029032433'] <10.113.7.002> REMOTE_MODULE wait_for host="10.113.7.002" port=22 timeout="1" <10.113.7.002> PUT /tmp/tmpwhWU6X TO /home/gateway/.ansible/tmp/ansible-1384993979.41-2345029032433/wait_for <10.113.7.002> EXEC ['/bin/sh', '-c', '/usr/bin/python /home/gateway/.ansible/tmp/ansible-1384993979.41-2345029032433/wait_for; rm -rf /home/gateway/.ansible/tmp/ansible-1384993979.41-2345029032433/ >/dev/null 2>&1'] ok: [10.113.7.002] => {"changed": false, "elapsed": 0, "item": "", "port": 22, "state": "started"}

    TASK: [Contacting target to obtain Junos facts] ***************** <10.113.7.002> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-1384993979.48-89494360697375 && chmod a+rx $HOME/.ansible/tmp/ansible-1384993979.48-89494360697375 && echo $HOME/.ansible/tmp/ansible-1384993979.48-89494360697375'] <10.113.7.002> REMOTE_MODULE junos_get_facts host=10.113.7.002 user=viasat <10.113.7.002> PUT /tmp/tmpB4jBDM TO /home/gateway/.ansible/tmp/ansible-1384993979.48-89494360697375/junos_get_facts <10.113.7.002> PUT /tmp/tmp28DLzs TO /home/gateway/.ansible/tmp/ansible-1384993979.48-89494360697375/arguments <10.113.7.002> EXEC ['/bin/sh', '-c', '/usr/local/bin/ruby /home/gateway/.ansible/tmp/ansible-1384993979.48-89494360697375/junos_get_facts /home/gateway/.ansible/tmp/ansible-1384993979.48-89494360697375/arguments; rm -rf /home/gateway/.ansible/tmp/ansible-1384993979.48-89494360697375/ >/dev/null 2>&1'] failed: [10.113.7.002] => {"failed": true, "parsed": false} invalid output was: /var/lib/gems/1.9.1/gems/netconf-0.3.1/lib/net/netconf/transport.rb:49:in open': Netconf::OpenError (Netconf::OpenError) from /var/lib/gems/1.9.1/gems/netconf-0.3.1/lib/net/netconf/transport.rb:28:ininitialize' from /var/lib/gems/1.9.1/gems/netconf-0.3.1/lib/net/netconf/ssh.rb:21:in initialize' from /home/gateway/.ansible/tmp/ansible-1384993979.48-89494360697375/junos_get_facts:46:innew' from /home/gateway/.ansible/tmp/ansible-1384993979.48-89494360697375/junos_get_facts:46:in `'

    FATAL: all hosts have already failed -- aborting

    PLAY RECAP ************************************** to retry, use: --limit @/home/gateway/get_junos_facts.retry

    10.113.7.002 : ok=1 changed=0 unreachable=0 failed=1

1

1 Answers

1
votes

Here's the answer: the Juniper devices were not properly set up to listen for NETCONF connections on the normal SSH port 22. Changing this in the Juniper config made it all work. This implies the Netconf::OpenError means the device might be reachable, but the NETCONF connection is not available.