Closed mactizzle closed 6 months ago
After much wringing of the hands, I tried a different approach using the Juniper.junos
role. From Understanding the Ansible for Junos OS Collections, Roles, and Modules, it says "In Ansible 2.9 and earlier, you can manage devices running Junos OS by using the modules provided in the Juniper Networks Juniper.junos role or by using the core modules provided as part of the Ansible base installation. Starting in Ansible 2.10, the Juniper.junos role and the Ansible core modules are superseded by the corresponding collection."
Nevertheless, I tried using the Juniper.junos
role and juniper_junos_software module
:
- name: Upgrade OS on Juniper Devices
hosts: juniper_upgrade
gather_facts: false
roles:
- Juniper.junos
collections:
- juniper.device
vars:
local_file_dir: /home/ansuser/ansible/files/software/juniper
network_util_dir: /home/juniper-backup/software
log_dir: "{{ playbook_dir }}/logs"
wait_time: 3600
ansible_user: network-ansible
ansible_ssh_key: /home/ansuser/.ssh/id_rsa
acx710_file: junos-install-acx-arm-64-21.4R1-S2.3.tgz
tasks:
- name: Verify NETCONF connectivity
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
timeout: 5
# ------------- ACX710 ---------------
- name: Transfer install file to Ansible machine
delegate_to: localhost
ansible.builtin.command:
cmd: "scp ansuser@172.16.201.50:{{ network_util_dir }}/acx710/{{ acx710_file }} {{ local_file_dir }}/{{ acx710_file }}"
when: "'ACX71' in inventory_hostname"
- name: Upgrade software on ACX710
juniper_junos_software:
local_package: "{{ local_file_dir }}/{{ acx710_file }}"
validate: false
checksum_timeout: 420
cleanfs_timeout: 600
install_timeout: 2000
logfile: "{{ log_dir }}/{{ inventory_hostname }}.log"
when: "'ACX71' in inventory_hostname"
register: upgrade_response
notify:
- Wait_for_reboot
- name: Print the response
ansible.builtin.debug:
msg: "{{ upgrade_response }}"
when: "'ACX71' in inventory_hostname"
- name: Delete the temporary installation file from Ansible host
delegate_to: localhost
ansible.builtin.file:
path: "{{ local_file_dir }}/{{ acx710_file }}"
state: absent
when: "'ACX71' in inventory_hostname"
# ------------- ( END OF JUNIPER MODELS ) ---------------
handlers:
- name: Wait_for_reboot
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
timeout: "{{ wait_time }}"
when: not upgrade_response.check_mode
This was successful, leading me to believe something is missing from junipernetworks.junos
and juniper.device
collections (I get a separate issue while using juniper.device
)
I know that this type of error "You must provide either 'host' or 'sock_fd' value" can be mitigated setting paramiko as ssh_type. Maybe you can give it a try.
Can see the same issue, tried setting paramiko, in multiple ways but none worked out.
In other attempts I hit either https://github.com/ansible/ansible/issues/68034 or netconf will not be working as in https://github.com/ansible/ansible/issues/50162 and the non-deprecated [put module[(https://docs.ansible.com/ansible/latest/collections/ansible/netcommon/net_put_module.html#ansible-collections-ansible-netcommon-net-put-module) also doesn't work.
I'm at a loss and do hope Juniper can throw sufficient resources at this - so there will again a clear path that works well.
For the record, I intentionally broke stuff with the above tests and my own playbooks, removing ansible_network_os
and ansible_connection
from hosts
and it triggered this:
"ssh_config": null,
"ssh_private_key_file": null
}
},
"item": "/Users/floh/training/junos/scripts/roles/junos_day1/files/stp.slax",
"msg": "junos-eznc is required but does not appear to be installed. It can be installed using `pip install junos-eznc`"
}
Installing it had absolutely no effect, putting me back at with the ACX example from above and mine.
"msg": "You must provide either 'host' or 'sock_fd' value"
It'll always be the SCP affected, I have not found a workaround yet.
In my experience juniper.device modules ONLY work with local connection type. So try setting local connection type. Either for the whole play or for a single tasks, which is using juniper.device modules.
Hi @mactizzle Please try to verify the JUNOS upgrade using juniper.device collections and share the results .
https://github.com/Juniper/ansible-junos-stdlib/blob/master/tests/pb.juniper_junos_software.yml
Thanks
Hi @chidanandpujar , since opening this we have manually upgraded all of the 710s in our network so I no longer have any to test on. I do have quite a few ACX2100s that are currently in an upgrade cycle (15.1R3.6 > 21.2R3-S6.11). If you think testing on those will prove useful for this issue then I'll give it a shot. Otherwise I can see about getting a spare 710 from our warehouse to bench-test.
I do foresee hitting PR1568757 (must use no-validate when upgrading Pre 21.2 to 21.2 and onward), so I will need to add validate: False
to the juniper.device.software stanza.
Will this work for your test?
EDIT: disregard... lapse of memory. We can only upgrade the ACX2100s via USB since the version jump is so big. I'll post back if I can bench-test a 710, otherwise hopefully someone else can chime in here.
Hi @mactizzle Thanks very much for sharing the information . Please give me some time , I will check if I can borrow a ACX710s and test the upgrade scenario 20.2R1.10 to 21.4R1-S2.3 .
Thanks
Hi @mactizzle , I have verified the software installation on ACX710 with connection: local and connection: juniper.device.pyez, both looks to be working fine with following versions . Please check and confirm, if it is working fine, shall we close this issue for now .
ansible --version
ansible [core 2.16.6]
config file = /root/ansible_release_v216_test/ansible-junos-stdlib/tests/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /root/ansible_release_v216_test/venv/lib/python3.10/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /root/ansible_release_v216_test/venv/bin/ansible
python version = 3.10.8 (main, Dec 2 2022, 10:56:46) [GCC 7.5.0] (/root/ansible_release_v216_test/venv/bin/python)
jinja version = 3.1.4
libyaml = True
# /root/.ansible/collections/ansible_collections
Collection Version
---------------------------------------- -------
ansible.netcommon 4.1.0
ansible.utils 2.8.0
juniper.device 1.0.4
---
- name: Test juniper.device.software module
hosts: all
collections:
- juniper.device
gather_facts: no
vars:
wait_time: 3600
pkg_dir: /var/tmp/
OS_version: 24.2
OS_package: junos-install-acx-arm-64-24..2.tgz
log_dir: /var/log/
tasks:
- name: Checking NETCONF connectivity
wait_for: host={{ ansible_ssh_host }} port=830 timeout=5
- name: Install Junos OS package
software:
reboot: False
no_copy: True
all_re: True
version: "{{ OS_version }}"
package: "{{ pkg_dir }}/{{ OS_package }}"
logfile: "{{ log_dir }}/software.log"
register: test1
notify:
- wait_reboot
- name: Print response
debug:
var: test1
- name: Check TEST - 1
assert:
that:
- test1.failed == false
handlers:
- name: wait_reboot
wait_for: host={{ ansible_ssh_host }} port=830 timeout={{ wait_time }}
when: not test1.check_mode
ansible-playbook pb.juniper_junos_software.yml
PLAY [Test juniper.device.software module] ********************************************************************************************************************************
TASK [Checking NETCONF connectivity] **************************************************************************************************************************************
ok: [local_connection_testcases]
TASK [Install Junos OS package] *******************************************************************************************************************************************
changed: [local_connection_testcases]
TASK [Print response] *****************************************************************************************************************************************************
ok: [local_connection_testcases] => {
"test1": {
"changed": true,
"check_mode": false,
"failed": false,
"msg": "Package /var/tmp/junos-install-acx-arm-64-24.2.tgz successfully installed. Response from device is: \nVerified junos-install-acx-arm-64-24.2I-20240330.0.1659 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified auto-snapshot signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified deebe signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified dsa signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified fips-mode signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jail-runtime signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jdocs signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jinsight signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jpfe-acx-arm signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jsd-jet-1 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified jsdn signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-daemons-mx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-daemons signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-dp-crypto-support-mtx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-l2-rsi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-libs-compat32-mx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-libs-compat32 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-libs-mx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-libs signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-modules-acx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-modules signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-net-mtx-prd signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-net-prd signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-openconfig signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-platform signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-probe signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-aggregated signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-controller-external signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-lsys signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-mpls-oam-advanced signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-mpls-oam-basic signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-routing-scripts signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-rpd-telemetry-application signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-runtime-acx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified junos-runtime signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified na-telemetry signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified oam-efi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-boot-efi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-boot-junos-efi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-compat32 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-crypto signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-efi signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-forward-compat-11 signed by PackageDevelopmentECP256_2023 method ECDSA256+SHA256\nVerified os-kernel-prd signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-libs-compat32 signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-libs signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-modules-net signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-package signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-runtime signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified os-zoneinfo signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified py-base signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified py-extensions signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nVerified sflow-mx signed by PackageDevelopmentECP256_2024 method ECDSA256+SHA256\nNOTICE: 'pending' set will be activated at next reboot...\n"
}
}
TASK [Check TEST - 1] *****************************************************************************************************************************************************
ok: [local_connection_testcases] => {
"changed": false,
"msg": "All assertions passed"
}
RUNNING HANDLER [wait_reboot] *********************************************************************************************************************************************
ok: [local_connection_testcases]
PLAY RECAP ****************************************************************************************************************************************************************
local_connection_testcases : ok=5 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Thanks Chidanand
Hi @mactizzle , We have verified the software installation on ACX710, it looks to be working fine. I have already provided the pass logs above. We are closing the issue as of now , please feel to re-open or submit new one .
Thanks Chidanand
Issue Type
Module Name
junipernetworks.junos.junos_package
juniper.device collection and Python libraries version
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.
Expected results
Output similar to the example playbook
Actual results