ansible-junos-stdlib
ansible-junos-stdlib copied to clipboard
Software update fails with "You must provide either 'host' or 'sock_fd' value"
Issue Type
- Bug Report
Module Name
junipernetworks.junos.junos_package
juniper.device collection and Python libraries version
ansible [core 2.14.1]
config file = /home/ansuser/.ansible.cfg
configured module search path = ['/home/ansuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ansuser/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/ansuser/.ansible/collections:/usr/share/ansible/collections
executable location = /home/ansuser/.local/bin/ansible
python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
aiohttp==3.8.3
aiosignal==1.3.1
ansible-base==2.10.8
ansible-compat==2.2.7
ansible-core==2.14.1
ansible-lint==6.11.0
apache-libcloud==3.2.0
argcomplete==1.8.1
async-timeout==4.0.2
attrs==21.2.0
Automat==20.2.0
Babel==2.8.0
bcrypt==3.2.0
black==22.12.0
blinker==1.4
bracex==2.3.post1
certifi==2020.6.20
cffi==1.15.1
chardet==4.0.0
charset-normalizer==2.1.1
click==8.0.3
cloud-init==22.4.2
colorama==0.4.4
command-not-found==0.3
commonmark==0.9.1
configobj==5.0.6
configparser==5.3.0
constantly==15.1.0
cryptography==3.4.8
dbus-python==1.2.18
distro==1.7.0
distro-info===1.1build1
dnspython==2.1.0
filelock==3.9.0
frozenlist==1.3.3
future==0.18.2
gpg===1.16.0-unknown
httplib2==0.20.2
hyperlink==21.0.0
icdiff==1.9.1
idna==3.3
importlib-metadata==4.6.4
incremental==21.3.0
jeepney==0.7.1
Jinja2==3.0.3
jmespath==0.10.0
jsnapy==1.3.7
jsonpatch==1.32
jsonpointer==2.0
jsonschema==4.17.3
junos-eznc==2.6.6
jxmlease==1.0.3
keyring==23.5.0
launchpadlib==1.10.16
lazr.restfulclient==0.14.4
lazr.uri==1.0.6
lockfile==0.12.2
lxml==4.9.2
MarkupSafe==2.0.1
more-itertools==8.10.0
multidict==6.0.4
mypy-extensions==0.4.3
ncclient==0.6.13
netaddr==0.8.0
netifaces==0.11.0
ntlm-auth==1.4.0
oauthlib==3.2.0
packaging==21.3
paramiko==2.12.0
pathspec==0.10.3
pexpect==4.8.0
platformdirs==2.6.2
ptyprocess==0.7.0
pyasn1==0.4.8
pyasn1-modules==0.2.1
pycparser==2.21
pycryptodomex==3.11.0
Pygments==2.14.0
PyGObject==3.42.1
PyHamcrest==2.0.2
PyJWT==2.3.0
pykerberos==1.1.14
PyNaCl==1.5.0
pynetbox==7.0.0
pyOpenSSL==21.0.0
pyparsing==2.4.7
pyrsistent==0.18.1
pyserial==3.5
python-apt==2.4.0
python-debian===0.1.43ubuntu1
python-magic==0.4.24
pytz==2022.1
pyvmomi==8.0.0.1.1
pywinrm==0.3.0
PyYAML==5.4.1
requests==2.25.1
requests-kerberos==0.12.0
requests-ntlm==1.1.0
requests-toolbelt==0.9.1
resolvelib==0.8.1
rich==13.1.0
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.7
scp==0.14.4
SecretStorage==3.3.1
selinux==3.3
service-identity==18.1.0
simplejson==3.17.6
six==1.16.0
sos==4.4
ssh-import-id==5.11
subprocess-tee==0.4.1
systemd-python==234
tomli==2.0.1
transitions==0.9.0
Twisted==22.1.0
ubuntu-advantage-tools==27.12
ubuntu-drivers-common==0.0.0
ufw==0.36.1
unattended-upgrades==0.1
urllib3==1.26.5
wadllib==1.3.6
wcmatch==8.4.1
xkit==0.0.0
xmltodict==0.12.0
yamllint==1.29.0
yamlordereddictloader==0.4.0
yarl==1.8.2
zipp==1.0.0
zope.interface==5.4.0
OS / Environment
ACX710 (JUNOS 20.2R1.10)
Summary
While attempting an upgrade from 20.2R1.10 to 21.4R1-S2.3 on an ACX-710, junipernetworks.junos.junos_package fails with "You must provide either 'host' or 'sock_fd' value"
Steps to reproduce
Please see playbook below.
---
- name: Upgrade OS on Juniper Devices
hosts: juniper_upgrade
gather_facts: false
collections:
- junipernetworks.junos
- ansible.builtin
vars:
- acx710_file: /home/ansuser/ansible/files/software/juniper/junos-install-acx-arm-64-21.4R1-S2.3.tgz
- reboot_wait_time: 3600
- ansible_connection: ansible.netcommon.netconf
tasks:
- name: Verify NETCONF connectivity
ansible.builtin.wait_for:
timeout: 10
- name: Upgrade software on ACX710
junipernetworks.junos.junos_package:
src: "{{ acx710_file }}"
validate: true
when: "'ACX71' in inventory_hostname"
register: acx710_response
- name: Print the response
ansible.builtin.debug:
msg: "{{ acx710_response }}"
handlers:
- name: Wait for the device to come online
ansible.builtin.wait_for:
timeout: "{{ reboot_wait_time }}"
when: not response.check_mode
Expected results
Output similar to the example playbook
TASK [Print response] ******************************************************
ok: [mx1a.example.com] => {
"response": {
"changed": true,
"check_mode": false,
"failed": false,
"msg": "Package /home/user/ansible/software/junos-install-mx-x86-64-20.3R1.8.tgz successfully installed. Response from device is: \nVerified junos-install-mx-x86-64-20.3R1.8 signed by PackageProductionECP256_2020 method ECDSA256+SHA256\nVerified manifest signed by PackageProductionECP256_2020 method ECDSA256+SHA256\n
[...output truncated...]
NOTICE: 'pending' set will be activated at next reboot... Reboot successfully initiated. Reboot message: Shutdown NOW! [pid 83918]"
}
}
Actual results
ansuser@network-ansible:~/ansible$ ansible-playbook playbooks/junos/junos-release-upgrade.yaml --ask-vault-pass -vvvv
ansible-playbook [core 2.14.1]
config file = /home/ansuser/.ansible.cfg
configured module search path = ['/home/ansuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ansuser/.local/lib/python3.10/site-packages/ansible
ansible collection location = /home/ansuser/.ansible/collections:/usr/share/ansible/collections
executable location = /home/ansuser/.local/bin/ansible-playbook
python version = 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
Using /home/ansuser/.ansible.cfg as config file
Vault password:
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
yaml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
ini declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Skipping due to inventory source not existing or not being readable by the current user
toml declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
setting up inventory plugins
host_list declined parsing /home/ansuser/ansible/hosts as it did not pass its verify_file() method
script declined parsing /home/ansuser/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /home/ansuser/ansible/hosts as it did not pass its verify_file() method
Skipping empty key (hosts) in group (all)
Skipping empty key (children) in group (all)
Parsed /home/ansuser/ansible/hosts inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/ansuser/ansible/inventory/juniper.yaml as it did not pass its verify_file() method
script declined parsing /home/ansuser/ansible/inventory/juniper.yaml as it did not pass its verify_file() method
Parsed /home/ansuser/ansible/inventory/juniper.yaml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/ansuser/ansible/inventory/linux.yaml as it did not pass its verify_file() method
script declined parsing /home/ansuser/ansible/inventory/linux.yaml as it did not pass its verify_file() method
Parsed /home/ansuser/ansible/inventory/linux.yaml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/ansuser/ansible/inventory/other.yaml as it did not pass its verify_file() method
script declined parsing /home/ansuser/ansible/inventory/other.yaml as it did not pass its verify_file() method
Parsed /home/ansuser/ansible/inventory/other.yaml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/ansuser/ansible/inventory/windows.yaml as it did not pass its verify_file() method
script declined parsing /home/ansuser/ansible/inventory/windows.yaml as it did not pass its verify_file() method
Parsed /home/ansuser/ansible/inventory/windows.yaml inventory source with yaml plugin
Loading collection junipernetworks.junos from /home/ansuser/.ansible/collections/ansible_collections/junipernetworks/junos
redirecting (type: action) junipernetworks.junos.junos_package to junipernetworks.junos.junos
Loading callback plugin default of type stdout, v2.0 from /home/ansuser/.local/lib/python3.10/site-packages/ansible/plugins/callback/default.py
Loading collection juniper.device from /home/ansuser/.ansible/collections/ansible_collections/juniper/device
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
Loading callback plugin jsnapy of type aggregate, v2.0 from /home/ansuser/.ansible/collections/ansible_collections/juniper/device/plugins/callback/jsnapy.py
PLAYBOOK: junos-release-upgrade.yaml *************************************************************************************************************************************************************
Positional arguments: playbooks/junos/junos-release-upgrade.yaml
verbosity: 4
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/hosts', '/home/ansuser/ansible/hosts', '/home/ansuser/ansible/inventory')
ask_vault_pass: True
forks: 5
1 plays in playbooks/junos/junos-release-upgrade.yaml
PLAY [Upgrade OS on Juniper Devices] *************************************************************************************************************************************************************
Trying secret <ansible.parsing.vault.PromptVaultSecret object at 0x7f32a430ed10> for vault_id=default
TASK [Verify NETCONF connectivity] ***************************************************************************************************************************************************************
task path: /home/ansuser/ansible/playbooks/junos/junos-release-upgrade.yaml:13
Loading collection ansible.netcommon from /home/ansuser/.ansible/collections/ansible_collections/ansible/netcommon
<10.0.5.171> attempting to start connection
<10.0.5.171> using connection plugin ansible.netcommon.netconf
Found ansible-connection at path /home/ansuser/.local/bin/ansible-connection
<10.0.5.171> local domain socket does not exist, starting it
<10.0.5.171> control socket path is /home/ansuser/.ansible/pc/ce32ca3339
<10.0.5.171> Loading collection ansible.netcommon from /home/ansuser/.ansible/collections/ansible_collections/ansible/netcommon
<10.0.5.171> Loading collection junipernetworks.junos from /home/ansuser/.ansible/collections/ansible_collections/junipernetworks/junos
<10.0.5.171> local domain socket listeners started successfully
<10.0.5.171> loaded netconf plugin ansible_collections.junipernetworks.junos.plugins.netconf.junos from path /home/ansuser/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/netconf/junos.py for network_os junipernetworks.junos.junos
<10.0.5.171>
<10.0.5.171> local domain socket path is /home/ansuser/.ansible/pc/ce32ca3339
<10.0.5.171> ESTABLISH LOCAL CONNECTION FOR USER: ansuser
<10.0.5.171> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7 `"&& mkdir "` echo /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7/ansible-tmp-1674759167.30492-593645-57349455010063 `" && echo ansible-tmp-1674759167.30492-593645-57349455010063="` echo /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7/ansible-tmp-1674759167.30492-593645-57349455010063 `" ) && sleep 0'
Using module file /home/ansuser/.local/lib/python3.10/site-packages/ansible/modules/wait_for.py
<10.0.5.171> PUT /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7/tmp0z62qdn8 TO /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7/ansible-tmp-1674759167.30492-593645-57349455010063/AnsiballZ_wait_for.py
<10.0.5.171> EXEC /bin/sh -c 'chmod u+x /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7/ansible-tmp-1674759167.30492-593645-57349455010063/ /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7/ansible-tmp-1674759167.30492-593645-57349455010063/AnsiballZ_wait_for.py && sleep 0'
<10.0.5.171> EXEC /bin/sh -c '/usr/bin/python3 /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7/ansible-tmp-1674759167.30492-593645-57349455010063/AnsiballZ_wait_for.py && sleep 0'
<10.0.5.171> EXEC /bin/sh -c 'rm -f -r /home/ansuser/.ansible/tmp/ansible-local-593626l3b3g9n7/ansible-tmp-1674759167.30492-593645-57349455010063/ > /dev/null 2>&1 && sleep 0'
ok: [ACX71-HDSC-0] => {
"changed": false,
"elapsed": 10,
"invocation": {
"module_args": {
"active_connection_states": [
"ESTABLISHED",
"FIN_WAIT1",
"FIN_WAIT2",
"SYN_RECV",
"SYN_SENT",
"TIME_WAIT"
],
"connect_timeout": 5,
"delay": 0,
"exclude_hosts": null,
"host": "127.0.0.1",
"msg": null,
"path": null,
"port": null,
"search_regex": null,
"sleep": 1,
"state": "started",
"timeout": 10
}
},
"match_groupdict": {},
"match_groups": [],
"path": null,
"port": null,
"search_regex": null,
"state": "started"
}
redirecting (type: action) junipernetworks.junos.junos_package to junipernetworks.junos.junos
Loading collection ansible.netcommon from /home/ansuser/.ansible/collections/ansible_collections/ansible/netcommon
TASK [Upgrade software on ACX710] ****************************************************************************************************************************************************************
task path: /home/ansuser/ansible/playbooks/junos/junos-release-upgrade.yaml:17
<10.0.5.171> attempting to start connection
<10.0.5.171> using connection plugin ansible.netcommon.netconf
Found ansible-connection at path /home/ansuser/.local/bin/ansible-connection
<10.0.5.171> found existing local domain socket, using it!
<10.0.5.171>
<10.0.5.171> local domain socket path is /home/ansuser/.ansible/pc/ce32ca3339
redirecting (type: action) junipernetworks.junos.junos_package to junipernetworks.junos.junos
redirecting (type: action) junipernetworks.junos.junos_package to junipernetworks.junos.junos
<10.0.5.171> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<10.0.5.171> ANSIBLE_NETWORK_IMPORT_MODULES: found junipernetworks.junos.junos_package at /home/ansuser/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_package.py
<10.0.5.171> ANSIBLE_NETWORK_IMPORT_MODULES: running junipernetworks.junos.junos_package
<10.0.5.171> ANSIBLE_NETWORK_IMPORT_MODULES: complete
fatal: [ACX71-HDSC-0]: FAILED! => {
"changed": false,
"module_stderr": "You must provide either 'host' or 'sock_fd' value",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"
}
PLAY RECAP ***************************************************************************************************************************************************************************************
ACX71-HDSC-0 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0