redhat-cop / infra.leapp

Collection of Ansible roles for automating RHEL in-place upgrades using Leapp.
MIT License
43 stars 33 forks source link

Destination /var/log/ripu/ripu.log does not exist #203

Open Siythrun opened 3 weeks ago

Siythrun commented 3 weeks ago

Hi I am running the playbook with an analysis and update step combined but at the end of the upgrade I am getting

"Destination /var/log/ripu/ripu.log does not exist"

I was getting this is the analysis stage before seeing mention of needing to flush Handlers and use tags I have started doing this however now once the update is complete I get the error at the end and it won't move on to my post steps it seems like it slups up the ripu log before adding the end time

TASK [fedora.linux_system_roles.crypto_policies : Set current policy fact] *******************************************************************
ok: [server.name]

TASK [infra.leapp.upgrade : Notify RIPU in-place OS upgrade is done handler] *****************************************************************
changed: [server.name]

RUNNING HANDLER [infra.leapp.common : Add end time to log file] ******************************************************************************
changed: [server.name]

RUNNING HANDLER [infra.leapp.common : Slurp ripu.log file] ***********************************************************************************
ok: [server.name]

RUNNING HANDLER [infra.leapp.common : Decode ripu.log file] **********************************************************************************

RUNNING HANDLER [infra.leapp.common : Rename log file] ***************************************************************************************changed: [server.name]

RUNNING HANDLER [infra.leapp.common : Add end time to log file] ******************************************************************************fatal: [server.name]: FAILED! => {"changed": false, "msg": "Destination /var/log/ripu/ripu.log does not exist !", "rc": 257}   

PLAY RECAP ***********************************************************************************************************************************server.name : ok=115  changed=33   unreachable=0    failed=1    skipped=38   rescued=0    ignored=
---
- name: Upgrade
  hosts: server.name
  strategy: free
  gather_facts: true
  become: true
  force_handlers: true
  vars_prompt:
    - name: "vcenter_username"
      prompt: "vcenter_username?"
      private: no
    - name: "vcenter_password"
      prompt: "vcenter_password?"
      private: yes
  vars:
    # By default the analysis role will use:
    # analysis_repos_el7: rhel-7-server-extras-rpms
    # Optionally override the default analysis_repos_el7 to use the upstream copr leapp repository:
    # analysis_repos_el7: copr:copr.fedorainfracloud.org:group_oamg:leapp
    leapp_upgrade_opts: --target 8.10
    update_grub_to_grub_2: true
    selinux_mode: enforcing
    kernel_modules_to_unload_before_upgrade:
      - floppy
      - pata_acpi
    leapp_answerfile: |
      [remove_pam_pkcs11_module_check]
      confirm = True
      [authselect_check]
      confirm = True
    os_path: $PATH
  # BEFORE the Update
  pre_tasks:
    - name: Create a snapshot
      community.vmware.vmware_guest_snapshot:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        datacenter: "{{ datacenter }}"
        uuid: "{{ config.uuid  }}"
        state: present
        snapshot_name: Pre_RHEL_Update
        description: Snap Shot taken before updating to RHEL 8 via Ansible
      delegate_to: localhost
      tags:
        - always
    - name: Remove unsupported drivers
      community.general.modprobe:
        name: "{{ item }}"
        state: absent
      loop:
        - floppy
        - pata_acpi
      tags:
        - always
      when: ansible_distribution_major_version == "7"

    - name: Remove Non Supported packages
      ansible.builtin.package:
        name:
          - docker-ce
          - docker-ce-cli
          - containerd.io
          - docker-buildx-plugin
          - docker-compose-plugin
          - docker-ce-rootless-extras
          - python2-pip
          - epel-release-7
        state: absent
      tags:
        - always
    - name: Delete unwanted repos repos
      file:
        path: "{{ item }}"
        state: absent
      loop:
        - "/etc/yum.repos.d/epel.repo"
        - "/etc/yum.repos.d/docker-ce.repo"
      tags:
        - always
      notify: yum-clean-metadata
    - name: Backup fstab
      ansible.builtin.copy:
        src:  /etc/fstab
        dest: "/etc/fstab.bak.rhel7-8.{{ ansible_date_time.date }}-{{ ansible_date_time.hour }}{{ ansible_date_time.minute }}{{ ansible_date_time.second }}"
        remote_src: true
      tags:
        - always
    - name: Unmount NFS and CIFS mounts
      mount:
        path: "{{ item.mount}}"
        state: unmounted
      when: "item.fstype == 'nfs' or item.fstype == 'cifs' or item.fstype == 'nfs4'"
      with_items: "{{ ansible_mounts }}"
      tags:
        - always
    - name: Comment out NFS and CIFS entries in /etc/fstab
      shell: "sed -i '/^[^#].*\\s\\(nfs\\|cifs\\)\\s/ s/^/# TEMP COMMENT FOR 7-8 /' /etc/fstab"
      tags:
        - always
      notify: daemon-reload

    - name: Unset Release Target
      community.general.rhsm_release:
#        release: "{{ upgrade_target }}"
        release: null
      when: ansible_distribution_major_version == "7"
      tags:
        - always

  tasks:
    - name: Generate preupgrade analysis report
      ansible.builtin.include_role:
        name: infra.leapp.analysis
        apply:
          tags:
            - analysis
      tags:
        - analysis
    # Flush the handlers
    - name: Flush Analysis Handlers
      ansible.builtin.meta: flush_handlers
      tags:
        - analysis
    # UPDATE STARTS HERE
    - name: Perform OS upgrade
      ansible.builtin.include_role:
        name: infra.leapp.upgrade
        apply:
          tags:
            - upgrade
      tags:
        - upgrade
    # Flush the handlers
    - name: Flush Upgraode Handlers
      ansible.builtin.meta: flush_handlers
      tags:
        - upgrade

  # AFTER THE UPDATE
  post_tasks:
    - name: Remove previously commented NFS and CIFS entries in /etc/fstab
      replace:
        path: /etc/fstab
        regexp: "^# TEMP COMMENT FOR 7-8 (.*)"
        replace: "\\1"
      tags:
        - always
      notify: daemon-reload
    - name: Run mount -a
      ansible.builtin.command:
        cmd: mount -a
      tags:
        - always
      changed_when: true
    - name: Install Python 3.11 and reset selection to auto
      community.general.alternatives:
        name: python
        path: /usr/bin/python3.11
        link: /usr/bin/python
        state: auto
      tags:
        - always
    - name: Install podman
      ansible.builtin.package:
        name: podman
        state: present
      tags:
        - always

  handlers:
    - name: daemon-reload
      ansible.builtin.systemd:
        daemon_reload: true
      tags:
        - always

    - name: yum-clean-metadata
      ansible.builtin.command: yum clean metadata
      tags:
        - always

Is this something im doing wrong or an issue with the adding of end time

djdanielsson commented 3 weeks ago

the one thought I have is it might be because you flush handlers which I think one of the handlers would remove the log file. I'm wondering if we should tweak something to allow a playbook like this but I would have to think about it a bit.

Siythrun commented 3 weeks ago

I tested by removing the second handler flush but no dice, it seems like it's running the handlers twice after this step

- name: Notify RIPU in-place OS upgrade is done handler
  ansible.builtin.assert:
    that: true
    quiet: true
  changed_when: true
  notify: RIPU in-place OS upgrade is done

Is this caused by this step triggering both the analysis import and the update import?

Anson-CMC commented 1 week ago

I face the same issue as well. Look like analysis and update role cannot be run in same playbook. Try to separate it.

djdanielsson commented 1 week ago

something to try as well would be make it another play in the playbook vs a task, that might be all you need to do to make this work. let me know if that solves the issue.

djdanielsson commented 1 week ago

any updates?

Siythrun commented 1 week ago

Haven't had the chance to run this all in 1 file as I have been away from my stack on leave, but I did test in separate playbooks, and it works fine, the core of my problem is wanting to run them as close together as possible as I thought I needed a passed analysis to run the update, but I didn't want to unmount my disks until I was about to run the update (to reduce as much downtime as possible)

turns out, I can add the following vars to enable it to bypass the errors in the initial analysis check_leapp_analysis_results: false leapp_known_inhibitors: []

I would imagine that running them as separate plays might work, but it would mean defining the vars for every play and defining the host in more than one place

I think the go here since they don't run is to just have 2 separate plays 1 to analysis and review to fix the issues then the actual upgrade after bypassing the results with the stance that they should be fixed now...its interesting that the upgrade since is needs an analysis to be run doesn't just run one instead.