Juniper / ansible-junos-stdlib

Junos modules for Ansible
Apache License 2.0
304 stars 158 forks source link

All modules fail since Ansible 2.15.9 or >=2.16.3 ("missing required arguments") #644

Closed salfers closed 5 months ago

salfers commented 7 months ago

Issue Type

Module Name

for example juniper_junos_facts

ansible [core 2.16.4]
  config file = /var/tmp/network-automation/ansible.cfg
  configured module search path = ['/home/stefan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /var/tmp/network-automation/venv/lib/python3.11/site-packages/ansible
  ansible collection location = /home/stefan/.ansible/collections:/usr/share/ansible/collections
  executable location = /var/tmp/network-automation/venv/bin/ansible
  python version = 3.11.8 (main, Feb 12 2024, 14:50:05) [GCC 13.2.1 20230801] (/var/tmp/network-automation/venv/bin/python)
  jinja version = 3.1.3
  libyaml = True

ansible-core==2.16.4
ansible-pylibssh==1.1.0
bcrypt==4.1.2
cffi==1.16.0
cryptography==42.0.5
Jinja2==3.1.3
junos-eznc==2.7.0
jxmlease==1.0.3
lxml==5.1.0
MarkupSafe==2.1.5
ncclient==0.6.15
netaddr==1.2.1
packaging==24.0
paramiko==3.4.0
pycparser==2.21
PyNaCl==1.5.0
pyparsing==3.1.2
pyserial==3.5
pytz==2024.1
PyYAML==6.0.1
resolvelib==1.0.1
scp==0.14.5
six==1.16.0
transitions==0.9.0
yamlordereddictloader==0.4.2

# /home/stefan/.ansible/collections/ansible_collections
Collection            Version
--------------------- -------
ansible.netcommon     6.0.0  
ansible.utils         3.1.0  
junipernetworks.junos 6.0.2  
netbox.netbox         3.17.0

OS / Environment

n/a

Summary

After upgrading to ansible 2.15.9 or any version newer than 2.16.2 all junos related modules no longer work. The error message complains about "missing required arguments".

Steps to reproduce

---
- hosts: localhost
  connection: network_cli
  gather_facts: no
  roles:
    - Juniper.junos
  tasks:
    - set_fact:
        ansible_host: "0.0.0.0"
        ansible_network_os: "junos"
        ansible_user: "foo"
        ansible_pass: "bar"

    - juniper_junos_facts:

Expected results

[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not
match 'all'

PLAY [localhost] **************************************************************************************************

TASK [set_fact] ***************************************************************************************************
ok: [localhost]

TASK [juniper_junos_facts] ****************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to make a PyEZ connection: ConnectRefusedError(0.0.0.0)"}

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

Actual results

[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not
match 'all'

PLAY [localhost] **************************************************************************************************

TASK [set_fact] ***************************************************************************************************
ok: [localhost]

TASK [juniper_junos_facts] ****************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "missing required arguments: _inventory_hostname, _module_name, _module_utils_path"}

PLAY RECAP ********************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 
GiuffreLab commented 6 months ago

So I've been beating my head on why my Execution Environment upgrade of versions broke all of my juniper playbooks.

I was tired of all the vulnerability scans the base quay.io ansible runner image (no updates in 2 years) had and the lengths I had to go to to make it current enough to pass scans. I then realized v1 is depreciated for v3. v3 is a bit more of a headache to build with.

What best I could come up with is the following.

The role juniper.junos may be depreciated (no updates in 3 years).

I then tried to use the other juniper collections like junipernetworks.device and that one has various issues like this as well. It does appear to get updates.

I then tried the other juniper collection juniper.device. It didnt play well with the now required connection: ansible.netommon.netconf however it worked like a charm with connection: local (again, something that is supposedly going away).

I now sit here aggrivated that I will have to go through this all over again as this stuff depreciates. Why they stopped updating the "defacto" EE image I dont know.. Why Juniper has multiple galaxy roles and collections.. I dont know.. But this was the only workaround I found for this. Which means I now get to refactor a truckload of ansible playbooks with these changes..

madalinignisca commented 6 months ago

@GiuffreLab I'm trying to understand what other collections does Juniper has? In Ansible Galaxy, under the official Juniper namespace, there are 2 collections. The main one [device](https://galaxy.ansible.com/ui/repo/published/juniper/device/) and another empty one.

Probably many other collections belong to other people and not Juniper.

GiuffreLab commented 6 months ago

@madalinignisca It's trivially easy to search (or just reading what I put in the reply), but the main ones would be these.

Collections https://galaxy.ansible.com/ui/repo/published/juniper/device/

https://galaxy.ansible.com/ui/repo/published/junipernetworks/junos/

Roles https://galaxy.ansible.com/ui/standalone/roles/juniper/junos/documentation/

madalinignisca commented 6 months ago

@GiuffreLab

https://galaxy.ansible.com/ui/repo/published/junipernetworks/junos/ - this is part of Ansible community, not official Juniper effort.

The Role from Juniper has been deprecated, should work with some devices and older Juneos versions.

I'm not affiliated to Juniper, but it was very easy to understand all this information from all the repositories and their docs.

Maybe you should limit the issue only to error.

But from your description you are not using juniper.device collection, which is this repository. You are using the Ansible Community junipernetworks.junos which is for old Juniper devices, and it is maintained by Ansible.

GiuffreLab commented 6 months ago

@madalinignisca please... just actually READ what this thread is talking about. Just read it.

Everything you said... WE KNOW!

We're trying to point out, that with these collections or roles, you CANNOT use Ansible's recommended ansible.netcommon.netconf or network.cli as the connection type. You can only use local for the connection because it is not passing required arguments. That's it.. That's what this thread is about.

dineshbaburam91 commented 5 months ago

Could you use the Ansible collection instead of the Ansible role to run the playbook and let me know the result?

https://galaxy.ansible.com/ui/repo/published/juniper/device/

Sample playbook for juniper.device ansible collection mentioned below https://github.com/Juniper/ansible-junos-stdlib/tree/master/Samples

GiuffreLab commented 5 months ago

Could you use the Ansible collection instead of the Ansible role to run the playbook and let me know the result?

https://galaxy.ansible.com/ui/repo/published/juniper/device/

Sample playbook for juniper.device ansible collection mentioned below https://github.com/Juniper/ansible-junos-stdlib/tree/master/Samples

As previously mentioned, multiple times. The juniper.device collection is the only one that works. HOWEVER, it only works with connection: local as mentioned.

Your link of test scripts ALL use connection: local, hence the entire point of the issue, as connection: ansible.netcommon.netconf or connection: network.cli do not pass properly.

Without the local connection, all tasks fail due to missing facts like credentials and so on.

dineshbaburam91 commented 5 months ago

juniper.device ansible collection supports local and juniper.device.pyez.

https://www.juniper.net/documentation/us/en/software/junos-ansible/ansible/topics/topic-map/junos-ansible-connection-methods.html

In case, If you want to use ansible.netcommon.netconf and network.cli connection, you need to install core ansible junipernetworks.junos collection and use core ansible playbook.

https://docs.ansible.com/ansible/latest/network/user_guide/platform_junos.html https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/index.html

dineshbaburam91 commented 5 months ago

Fixed #664