Skip to content

juniper.device.junos_user PyEZ connection failure #798

@LordOfTheNeverThere

Description

@LordOfTheNeverThere

Is the junos_user module not compatible with juniper.device.pyez?

Issue Type

Bug Report
Module Name: junos_user

Control Node Env

/ansibleScripts # ansible --version
ansible [core 2.18.11]
  config file = /ansibleScripts/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.13/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.13.3 (main, May  9 2025, 23:41:23) [GCC 14.2.0] (/usr/local/bin/python3.13)
  jinja version = 3.1.6
  libyaml = True
/ansibleScripts # ansible-galaxy collection list

# /root/.ansible/collections/ansible_collections
Collection                               Version
---------------------------------------- -------
ansible.netcommon                        8.2.0  
juniper.device                           2.0.1  

# /usr/local/lib/python3.13/site-packages/ansible_collections
Collection                               Version
---------------------------------------- -------
amazon.aws                               9.4.0  
ansible.netcommon                        7.2.0  
ansible.posix                            1.6.2  
ansible.utils                            5.1.2  
ansible.windows                          2.8.0  
arista.eos                               10.1.1 
awx.awx                                  24.6.1 
azure.azcollection                       3.3.1  
check_point.mgmt                         6.4.0  
chocolatey.chocolatey                    1.5.3  
cisco.aci                                2.11.0 
cisco.asa                                6.1.0  
cisco.dnac                               6.31.3 
cisco.intersight                         2.0.20 
cisco.ios                                9.2.0  
cisco.iosxr                              10.3.1 
cisco.ise                                2.10.0 
cisco.meraki                             2.20.10
cisco.mso                                2.10.0 
cisco.nxos                               9.4.0  
cisco.ucs                                1.16.0 
cloud.common                             4.0.0  
cloudscale_ch.cloud                      2.4.1  
community.aws                            9.2.0  
community.ciscosmb                       1.0.10 
community.crypto                         2.26.0 
community.digitalocean                   1.27.0 
community.dns                            3.2.3  
community.docker                         4.5.2  
community.general                        10.6.0 
community.grafana                        2.1.0  
community.hashi_vault                    6.2.0  
community.hrobot                         2.2.0  
community.library_inventory_filtering_v1 1.1.1  
community.libvirt                        1.3.1  
community.mongodb                        1.7.9  
community.mysql                          3.13.0 
community.network                        5.1.0  
community.okd                            4.0.1  
community.postgresql                     3.14.0 
community.proxysql                       1.6.0  
community.rabbitmq                       1.4.0  
community.routeros                       3.6.0  
community.sap_libs                       1.4.2  
community.sops                           2.0.5  
community.vmware                         5.6.0  
community.windows                        2.4.0  
community.zabbix                         3.3.0  
containers.podman                        1.16.3 
cyberark.conjur                          1.3.3  
cyberark.pas                             1.0.30 
dellemc.enterprise_sonic                 2.5.1  
dellemc.openmanage                       9.11.0 
dellemc.powerflex                        2.6.0  
dellemc.unity                            2.0.0  
f5networks.f5_modules                    1.35.0 
fortinet.fortimanager                    2.9.1  
fortinet.fortios                         2.4.0  
google.cloud                             1.5.1  
grafana.grafana                          5.7.0  
hetzner.hcloud                           4.3.0  
hitachivantara.vspone_block              3.3.0  
ibm.qradar                               4.0.0  
ibm.spectrum_virtualize                  2.0.0  
ibm.storage_virtualize                   2.7.3  
ieisystem.inmanage                       3.0.0  
infinidat.infinibox                      1.4.5  
infoblox.nios_modules                    1.8.0  
inspur.ispim                             2.2.3  
junipernetworks.junos                    9.1.0  
kaytus.ksmanage                          2.0.0  
kubernetes.core                          5.2.0  
kubevirt.core                            2.1.0  
lowlydba.sqlserver                       2.6.0  
microsoft.ad                             1.8.1  
microsoft.iis                            1.0.2  
netapp.cloudmanager                      21.24.0
netapp.ontap                             22.14.0
netapp.storagegrid                       21.14.0
netapp_eseries.santricity                1.4.1  
netbox.netbox                            3.21.0 
ngine_io.cloudstack                      2.5.0  
openstack.cloud                          2.4.1  
ovirt.ovirt                              3.2.0  
purestorage.flasharray                   1.34.1 
purestorage.flashblade                   1.19.2 
sensu.sensu_go                           1.14.0 
splunk.es                                4.0.0  
telekom_mms.icinga_director              2.2.2  
theforeman.foreman                       4.2.0  
vmware.vmware                            1.11.0 
vmware.vmware_rest                       4.7.0  
vultr.cloud                              1.13.0 
vyos.vyos                                5.0.0  
wti.remote                               1.0.10 

/ansibleScripts # pip freeze
ansible==11.5.0
ansible-core==2.18.11
bcrypt==5.0.0
cffi==2.0.0
colorama==0.4.6
configparser==7.2.0
cryptography==46.0.3
future==1.0.0
icdiff==1.9.1
invoke==2.2.1
Jinja2==3.1.6
jsnapy==1.3.8
junos-eznc==2.7.5
jxmlease==1.0.3
lxml==6.0.2
MarkupSafe==3.0.3
ncclient==0.7.0
packaging==25.0
paramiko==4.0.0
passlib==1.7.4
pycparser==2.23
PyNaCl==1.6.1
pyparsing==3.2.5
pyserial==3.5
PyYAML==6.0.3
resolvelib==1.0.1
scp==0.15.0
six==1.17.0
transitions==0.9.3
xmltodict==1.0.2
yamlordereddictloader==0.4.2

Juniper Env

Model: srx220h2
JUNOS Software Release [12.3X48-D85.1]

Inventory

juniperRouter:
    ansible_host: 10.2.1.1 
    ansible_password: "{{ weakPassword }}"
    ansible_connection: juniper.device.pyez
    ansible_user: miguel
- name: Configure User miguel with Encrypted Password
  juniper.device.junos_user:
    name: miguel
    role: super-user
    encrypted_password: "{{ strongPassword | password_hash('sha512') }}"
    state: present


Summary

With the inventory and task an error occurs

Actual results

TASK [juniper.device.junos_user] *************************************************************************************************
task path: /ansibleScripts/provisioningNetworkDevices.yml:4
Using passlib to hash input with 'sha512_crypt'
<10.2.1.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<10.2.1.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-local-4461zdwf98d `"&& mkdir "` echo /root/.ansible/tmp/ansible-local-4461zdwf98d/ansible-tmp-1766143372.4463887-492-62651585714647 `" && echo ansible-tmp-1766143372.4463887-492-62651585714647="` echo /root/.ansible/tmp/ansible-local-4461zdwf98d/ansible-tmp-1766143372.4463887-492-62651585714647 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/juniper/device/plugins/modules/junos_user.py
<10.2.1.1> PUT /root/.ansible/tmp/ansible-local-4461zdwf98d/tmpvp3nw78x TO /root/.ansible/tmp/ansible-local-4461zdwf98d/ansible-tmp-1766143372.4463887-492-62651585714647/AnsiballZ_junos_user.py
<10.2.1.1> EXEC /bin/sh -c 'chmod u+rwx /root/.ansible/tmp/ansible-local-4461zdwf98d/ansible-tmp-1766143372.4463887-492-62651585714647/ /root/.ansible/tmp/ansible-local-4461zdwf98d/ansible-tmp-1766143372.4463887-492-62651585714647/AnsiballZ_junos_user.py && sleep 0'
<10.2.1.1> EXEC /bin/sh -c '/usr/local/bin/python3.13 /root/.ansible/tmp/ansible-local-4461zdwf98d/ansible-tmp-1766143372.4463887-492-62651585714647/AnsiballZ_junos_user.py && sleep 0'
<10.2.1.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-local-4461zdwf98d/ansible-tmp-1766143372.4463887-492-62651585714647/ > /dev/null 2>&1 && sleep 0'
fatal: [juniperRouter]: FAILED! => {
    "changed": false,
    "module_stderr": "",
    "module_stdout": "\n{\"failed\": true, \"msg\": \"Invalid connection type pyez\", \"invocation\": {\"module_args\": {\"name\": \"ansible\", \"role\": \"super-user\", \"encrypted_password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"state\": \"present\", \"purge\": false, \"active\": true, \"aggregate\": null, \"full_name\": null, \"sshkey\": null}}}\n\n{\"failed\": true, \"msg\": \"Invalid connection type pyez\", \"exception\": \"  File \\\"/tmp/ansible_juniper.device.junos_user_payload_1rx9kian/ansible_juniper.device.junos_user_payload.zip/ansible_collections/juniper/device/plugins/module_utils/network/junos/junos.py\\\", line 309, in locked_config\\n    lock_configuration(module)\\n    ~~~~~~~~~~~~~~~~~~^^^^^^^^\\n  File \\\"/tmp/ansible_juniper.device.junos_user_payload_1rx9kian/ansible_juniper.device.junos_user_payload.zip/ansible_collections/juniper/device/plugins/module_utils/network/junos/junos.py\\\", line 289, in lock_configuration\\n    conn = get_connection(module)\\n  File \\\"/tmp/ansible_juniper.device.junos_user_payload_1rx9kian/ansible_juniper.device.junos_user_payload.zip/ansible_collections/juniper/device/plugins/module_utils/network/junos/junos.py\\\", line 114, in get_connection\\n    module.fail_json(msg=\\\"Invalid connection type %s\\\" % network_api)\\n    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n  File \\\"/tmp/ansible_juniper.device.junos_user_payload_1rx9kian/ansible_juniper.device.junos_user_payload.zip/ansible/module_utils/basic.py\\\", line 1469, in fail_json\\n    sys.exit(1)\\n    ~~~~~~~~^^^\\n\", \"invocation\": {\"module_args\": {\"name\": \"ansible\", \"role\": \"super-user\", \"encrypted_password\": \"VALUE_SPECIFIED_IN_NO_LOG_PARAMETER\", \"state\": \"present\", \"purge\": false, \"active\": true, \"aggregate\": null, \"full_name\": null, \"sshkey\": null}}}\n",
    "msg": "MODULE FAILURE: Extra data: line 3 column 1 (char 298)\nSee stdout/stderr for the exact error",
    "rc": 1
}

Is this normal behaviour?
At https://galaxy.ansible.com/ui/repo/published/juniper/device/content/module/junos_user/#examples it does not mention that we can't use this type of connection and at https://www.juniper.net/documentation/us/en/software/junos-ansible/ansible/topics/topic-map/junos-ansible-connection-methods.html the suggestion is to use PyEZ in comparison with local

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions