Not able to push playbook to Juniper Switch

I am unable to push playbook tasks to our Juniper switch. If I just create a simple playbook for gathering the facts, I am getting below error “[Errno -2] Name or service not known”. and this error is same for every module.
Connectivity is fine as I am able to ssh the Juniper switch from the Ansible server.
I am pasting the playbook below as well as the error with -vvvv.

Please find my Playbook.

Playbook:
- hosts: juniperswitch
  gather_facts: no
  vars:
     ansible_command_timeout: 1800

  tasks:
    - name: get the facts
      junipernetworks.junos.junos_facts:
      register: value1

    - name: Print in screen
      debug:
        var: value1

error after adding -vvvv.

The full traceback is:
  File "/root/.ansible/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/network.py", line 215, in get_capabilities
    capabilities = Connection(module._socket_path).get_capabilities()
  File "/usr/local/lib/python3.8/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [57.4.62.33]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "available_network_resources": false,
            "config_format": "text",
            "gather_network_resources": null,
            "gather_subset": [
                "min"
            ]
        }
    },
    "msg": "[Errno -2] Name or service not known"
}

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

Hey @G24joshi can you provide an inventory so I can see how you setup your ansible_network_os?

Hi @IPvSean

Thanks, Please find below hosts file and group_vars file for my juniper switch.

[root@lonans01 juniperymls]# cat /etc/ansible/hosts
[juniperswitch]
57.3.62.21
-----------------
[root@lonans01 juniperymls]# cat /etc/ansible/group_vars/juniperswitch
ansible_network_os: junos
ansible_user: admin.b1
ansible_password: Pass@#$$
ansible_connection: netconf
ansible_become: yes
ansible_become_method: enable
ansible_become_password: Pass@#$$
[root@lonans01 juniperymls]#

Two question/requests:

  1. Is netconf enabled on the Juniper device? You can use the junos_netconf module to enable it: junipernetworks.junos.junos_netconf module – Configures the Junos Netconf system service — Ansible Documentation

You can see how I use it here: https://github.com/ansible/workshops/blob/4c1bce058c55c435766a99dc5528b4fa1e1b1d3f/roles/configure_routers/tasks/juniper_default.yml#L19

  1. Can you re-run your playbook with -vvvv (4 vs) so I can see what it is doing for the connection?
5 Likes

After enabling netconf in Juniper Device it now working. Thanks a lot. I run below command in juniper device to enable Netconf

set system services netconf ssh port 830

2 Likes

Hi G24joshi,

Thanks for posting an update indicating that the issue was solved, if @IPvSean 's post helped you, please make sure to check the tick in his comment as the solution.

I’m sharing a small guide on how to do it below:

Solutions

If you get to a point where you consider a post by someone helped you to solve the issue, please tick :white_check_mark: the check-box below their message:

image

This will mark the message as the solution and show it in the first post for easy access, as well as recognize the person that helped:

image

Thank you again and let us know if you have any questions or doubts!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.