# Not able to push playbook to Juniper Switch

**URL:** <https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778>\
**Category:** Get Help\
**Tags:** juniper, playbook, collections, network\
**Created:** [October 18, 2023, 9:09am UTC](https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778 "2023-10-18T09:09:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![G24joshi](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@G24joshi](https://forum.ansible.com/u/G24joshi)\
**Post date:** [October 18, 2023, 9:09am UTC](https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778/1 "2023-10-18T09:09:27Z")

</div>

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.

```yaml
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.

```sh
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

```

---

<div class="post-metadata">

**Author:** ![IPvSean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ipvsean/32/1153_2.png) [@IPvSean](https://forum.ansible.com/u/IPvSean)\
**Post date:** [October 18, 2023, 1:20pm UTC](https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778/3 "2023-10-18T13:20:15Z")

</div>

Hey @G24joshi can you provide an inventory so I can see how you setup your ansible\_network\_os?

---

<div class="post-metadata">

**Author:** ![G24joshi](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@G24joshi](https://forum.ansible.com/u/G24joshi)\
**Post date:** [October 18, 2023, 2:02pm UTC](https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778/4 "2023-10-18T14:02:42Z")

</div>

Hi @IPvSean

Thanks, Please find below hosts file and group\_vars file for my juniper switch.

```sh
[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]#

```

---

<div class="post-metadata">

**Author:** ![IPvSean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ipvsean/32/1153_2.png) [@IPvSean](https://forum.ansible.com/u/IPvSean)\
**Post date:** [October 18, 2023, 3:29pm UTC](https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778/5 "2023-10-18T15:29:33Z")

</div>

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](https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/junos_netconf_module.html)

You can see how I use it here: [https://github.com/ansible/workshops/blob/4c1bce058c55c435766a99dc5528b4fa1e1b1d3f/roles/configure\_routers/tasks/juniper\_default.yml#L19](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?

---

<div class="post-metadata">

**Author:** ![G24joshi](https://avatars.discourse-cdn.com/v4/letter/g/258eb7/32.png) [@G24joshi](https://forum.ansible.com/u/G24joshi)\
**Post date:** [October 19, 2023, 9:43am UTC](https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778/6 "2023-10-19T09:43:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Leo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/leo/32/23_2.png) [@Leo](https://forum.ansible.com/u/Leo)\
**Post date:** [October 30, 2023, 7:28pm UTC](https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778/7 "2023-10-30T19:28:31Z")

</div>

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 ✅ the check-box below their message:

![image](https://us1.discourse-cdn.com/ansible/original/1X/de4bda8ca15f48c52ff19f12b452d10c02126f7f.png)

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](https://us1.discourse-cdn.com/ansible/original/1X/8964a515490358701e2c80d4ab69712f980e764c.png)

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 29, 2023, 7:29pm UTC](https://forum.ansible.com/t/not-able-to-push-playbook-to-juniper-switch/1778/8 "2023-11-29T19:29:12Z")

</div>

Closed on November 29, 2023, 7:29pm UTC

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