Ansible Network, junos_command.

407 views
Skip to first unread message

Oscar Bengtsson

unread,
Apr 7, 2016, 12:44:38 PM4/7/16
to Ansible Project, oscar.b...@networkservices.se
Hi,
I'm trying to get a playbook to connect to a juniper switch and do a 'show version'
I'm totally new to this and wanted to do this without the use of yaml files for username and password.
This is the code for the playbook:


---
- hosts: switches
  gather_facts: no
  connection: local

  tasks:
  - name: DEFINE PROVIDER
    set_fact:
      hostinfo:
        host: "{{ inventory_hostname }}"
        password: **************
        username: root
  - debug: var=hostvars[inventory_hostname]
  - name: show command
    junos_command:
      provider: "{{ hostinfo }}"
      commands:
        - show version
    register: version

The host file contains only 1 ip address to the switch.
I get this error for task "show command"

fatal: [172.18.10.25]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"commands": ["show version"], "host": "172.18.10.25", "interval": 1, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "port": 22, "provider": null, "retries": 10, "username": "root", "waitfor": null}, "module_name": "junos_command"}, "msg": "failed to connecto to 172.18.10.25:22 - "}

Is there something wrong with my code? I also tried specifying the username/password inside the task, didnt work either.
I can SSH to the switch from my server if not using ansible.

Thanks!
Oscar Bengtsson

Matt Hite

unread,
Apr 11, 2016, 1:33:25 PM4/11/16
to ansible...@googlegroups.com
Is netconf enabled under "system services"?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ec69eb29-19db-4eff-a17b-0c9513654c49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Oscar Bengtsson

unread,
Apr 13, 2016, 9:11:30 AM4/13/16
to Ansible Project
Hi,
From what I understood netconf is not needed for this module, but yes it is enabled from when i tried using junipers own-developed role from ansible-galaxy.
I don't want to use netconf as most vendors don't have it.

Mike Biancaniello

unread,
Apr 13, 2016, 9:59:11 AM4/13/16
to Ansible Project
might there be an application firewall between you and the switch that allows openssh, but not paramiko?

Oscar Bengtsson

unread,
Apr 13, 2016, 4:30:34 PM4/13/16
to Ansible Project
I will check it out tomorrow thanks!
Reply all
Reply to author
Forward
0 new messages