Juniper / ansible-junos-stdlib

Junos modules for Ansible
Apache License 2.0
302 stars 156 forks source link

juniper_junos_software - install on other RE prevented by version check #540

Open pwlodawi opened 3 years ago

pwlodawi commented 3 years ago

Issue Type

juniper_junos_software

Summary

I'm trying to upgrade sw on dual RE box that doesn't use fxp0 interfaces for management. Because fxp0s are not used I connect to loopback interface i.e. always to master RE. To specify RE to install on I use re0 or re1 in kwargs.

Procedure is as follows (let's assume re0 is a master and both REs have version X installed):

  1. install version Y on re1 and reboot re1
  2. wait for re1 to reboot
  3. perform RE switch (got disconnected here, re1 becomes the master)
  4. reconnect (now connected to re1 which is master now)
  5. install version Y on re0. This install fails because of version check. Version check is performed on re1 which is already Y and doesn't check kwargs so it can't know that install should be on re0 which is still X

The workaround could be to make version check aware of kwargs e.g. software.py:652

for re in facts['junos_info']:                     
    if re in kwargs:                                                
        current_version = facts['junos_info'][re]['text']
        re_name = re                                                

The other option could be to to add a new option to install on re other than one connection is made to. It could be for instance other_re similar to all_re (of course all_re and other_re being mutually exclusive).

chidanandpujar commented 3 months ago

Hi @pwlodawi Above operations are similar ISSU upgrade, could you please refer the following playbook for ISSU upgrade of the device and let us know the results.

---
- 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.3
    OS_package: junos-x86-64-24.3.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 
        issu: True
        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

Thanks Chidanand