Skip to content

Commit

Permalink
Fix for Pathing issue with analysis (#117)
Browse files Browse the repository at this point in the history
* Fix for Pathing issue with analysis
- Added default variable "os_path"
- Added extra parameter to the leapp analysis shell command to override
  or add to the default $PATH on the target node

* Fix for Pathing issues for shell commands
- Added extra parameter to the shell commands to override or add to the default $PATH on the target node
  • Loading branch information
scott-vick authored Aug 29, 2023
1 parent a367880 commit 78f8520
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions roles/analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Activation keys provide a method to identify content views available from Red Ha
| leapp_answerfile | Multi-line String | | If defined, this s written to `/var/log/leapp/answerfile` before generating the pre-upgrade report. |
| leapp_preupg_opts | String | | Optional string to define command line options to be passed to the `leapp` command when running the pre-upgrade. |
| post_reboot_delay | Int | 120 | Optional integer to pass to the reboot post_reboot_delay option. |
| os_path | String | Option string to override the $PATH variable used on the target node |

## Example playbook

Expand Down
1 change: 1 addition & 0 deletions roles/analysis/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ leapp_repos_enabled: []

post_reboot_delay: 120

os_path: $PATH
...
1 change: 1 addition & 0 deletions roles/analysis/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# TODO: Having issues with community.general.redhat_subscription and subscription-manager on RHEL 6.
- name: Register to pre leapp activation key RHEL 6
ansible.builtin.shell: >
export PATH={{ os_release }};
subscription-manager register
--org="{{ satellite_organization }}"
--activationkey="{{ satellite_activation_key_pre_leapp }}"
Expand Down
1 change: 1 addition & 0 deletions roles/analysis/tasks/analysis-leapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

- name: Leapp preupgrade report
ansible.builtin.shell: >
export PATH={{ os_path }}
set -o pipefail;
leapp preupgrade
{{ leapp_preupg_opts }}
Expand Down
3 changes: 3 additions & 0 deletions roles/analysis/tasks/analysis-preupg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TODO: Having issues with community.general.redhat_subscription and subscription-manager on RHEL 6.
- name: Register to upgrade activation key
ansible.builtin.shell: >
export PATH={{ os_release }};
subscription-manager register
--org="{{ satellite_organization }}"
--activationkey="{{ satellite_activation_key_pre_leapp }}"
Expand All @@ -16,6 +17,7 @@

- name: Enable requisite RHUI repos
ansible.builtin.shell: |
export PATH={{ os_release }}
set -o pipefail
yum-config-manager --enable {{ item }}
loop: "{{ analysis_repos_el6 }}"
Expand Down Expand Up @@ -48,6 +50,7 @@

- name: Run preupg
ansible.builtin.shell: >
export PATH={{ os_release }};
set -o pipefail;
preupg --force --text
2>&1 | tee -a {{ log_file }}
Expand Down
1 change: 1 addition & 0 deletions roles/analysis/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- name: Capture a list of non-rhel versioned packages
ansible.builtin.shell:
cmd: >-
export PATH={{ os_release }};
set -o pipefail;
rpm -qa | grep -ve '[\.|+]el{{ ansible_distribution_major_version }}' |
grep -vE '^(gpg-pubkey|libmodulemd|katello-ca-consumer)' |
Expand Down
1 change: 1 addition & 0 deletions roles/common/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

- name: Rename log file
ansible.builtin.shell: |
export PATH={{ os_release }}
mv {{ log_file }} {{ log_file }}-{{ ansible_date_time.iso8601_basic_short }}
listen: Archive log file
...
1 change: 1 addition & 0 deletions roles/upgrade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Additionally a list of any non-Red Hat RPM packages that were installed on the s
| crypto_policy | "DEFAULT" | System-wide cryptographic to set, e.g., "FUTURE", "DEFAULT:SHA1", etc. Refer to the crypto-policies (7) man page for more information. |
| post_reboot_delay | 120 | Optional integer to pass to the reboot post_reboot_delay option. |
| update_grub_to_grub_2 | false | Boolean to control whether grub gets upgraded to grub 2 in post RHEL 6 to 7 upgrade. |
| os_path | $PATH | Variable used to override the default $PATH environmental variable on the target node

## Example playbook

Expand Down
1 change: 1 addition & 0 deletions roles/upgrade/tasks/check-for-old-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- name: Search for old packages and packages not versioned by rhel release
ansible.builtin.shell:
cmd: >-
export PATH={{ os_release }};
set -o pipefail;
rpm -qa |
grep -ve '[\.|+]el{{ ansible_distribution_major_version }}' |
Expand Down
5 changes: 4 additions & 1 deletion roles/upgrade/tasks/grub2-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@
grub_boot_device: "{{ boot_device_dict.device | regex_replace('[1-9]$', '') }}"

- name: Run grub2-install
ansible.builtin.shell: grub2-install {{ grub_boot_device }}
ansible.builtin.shell: |
export PATH={{ os_release }}
grub2-install {{ grub_boot_device }}
- name: Run grub2-mkconfig
ansible.builtin.shell: |
export PATH={{ os_release }}
set -o pipefail
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Expand Down
1 change: 1 addition & 0 deletions roles/upgrade/tasks/leapp-post-upgrade-selinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TODO: Relocate to validation and compare to previous selinux state.
# - name: Ensure there are no SELinux denials
# ansible.builtin.shell: >
# export PATH={{ os_release }};
# ausearch -m AVC,USER_AVC -ts boot 2>&1
# register: ausearch_results
# changed_when: false
Expand Down
11 changes: 9 additions & 2 deletions roles/upgrade/tasks/leapp-post-upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
# /etc/dnf/dnf.conf is an ini file and could be parsed to check if exclude has value and run this conditionally.
- name: Clean dnf exclude list
ansible.builtin.shell: dnf config-manager --save --setopt exclude=''
ansible.builtin.shell: >
export PATH={{ os_release }};
dnf config-manager --save --setopt exclude=''
# leapp 7 to 8 documentation cleans up old kernels
- name: Block for RHEL 7 kernel cleanup
Expand All @@ -17,13 +19,15 @@

- name: Remove weak modules from old kernels
ansible.builtin.shell: |
export PATH={{ os_release }}
set -o pipefail
[ -x /usr/sbin/weak-modules ] && /usr/sbin/weak-modules --remove-kernel {{ item.path | basename }}
loop: "{{ old_kernels.files }}"
failed_when: false

- name: Remove the old kernels from the boot loader entry
ansible.builtin.shell: |
export PATH={{ os_release }}
set -o pipefail
/bin/kernel-install remove {{ item.path | basename }} {{ item.path }}/vmlinuz
loop: "{{ old_kernels.files }}"
Expand Down Expand Up @@ -54,7 +58,9 @@
var: result

- name: Unset subscription-manager release
ansible.builtin.shell: subscription-manager release --unset
ansible.builtin.shell: >
export PATH={{ os_release }};
subscription-manager release --unset
when: leapp_upgrade_type == 'satellite' or leapp_upgrade_type == 'cdn'

# TODO: Unset rhui release.
Expand All @@ -78,6 +84,7 @@
# Only found in RHEL 7 to 8 documentation
- name: Old kernels have been removed from the bootloader entry for RHEL 7 to 8
ansible.builtin.shell: |
export PATH={{ os_release }}
grubby --info=ALL | grep "\.el7" || echo "Old kernels are not present in the bootloader."
register: grubby_check
when: ansible_facts.ansible_local.pre_ripu.distribution_major_version | int == 7
Expand Down
5 changes: 4 additions & 1 deletion roles/upgrade/tasks/leapp-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

- name: Start Leapp OS upgrade
ansible.builtin.shell: >
export PATH={{ os_release }};
set -o pipefail;
leapp upgrade
{{ leapp_upgrade_opts }}
Expand Down Expand Up @@ -61,7 +62,9 @@
when: grub_boot_device is defined
block:
- name: Run grub2-install
ansible.builtin.shell: grub2-install {{ grub_boot_device }}
ansible.builtin.shell: >
export PATH={{ os_release }};
grub2-install {{ grub_boot_device }}
- name: Reboot to pickup grub update
ansible.builtin.reboot:
Expand Down
1 change: 1 addition & 0 deletions roles/upgrade/tasks/redhat-upgrade-tool-post-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

- name: "Register to post upgrade activation key"
ansible.builtin.shell: >
export PATH={{ os_path }};
subscription-manager register
--org="{{ satellite_organization }}"
--activationkey="{{ satellite_activation_key_post_leapp }}"
Expand Down
6 changes: 5 additions & 1 deletion roles/upgrade/tasks/redhat-upgrade-tool-upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- name: Run preupg --riskcheck
ansible.builtin.shell: preupg --riskcheck
ansible.builtin.shell: >
export PATH={{ os_release }};
preupg --riskcheck
register: preupg
changed_when: false
failed_when: false
Expand All @@ -13,6 +15,7 @@
# TODO: Having issues with community.general.redhat_subscription and subscription-manager on RHEL 6.
- name: Register to leapp activation key
ansible.builtin.shell: >
export PATH={{ os_release }};
subscription-manager register
--org_id: "{{ satellite_organization }}"
activationkey: "{{ satellite_activation_key_leapp }}"
Expand Down Expand Up @@ -48,6 +51,7 @@
# --cleanup-post removes Red Hat signed RHEL 6 packages and in theory should be safe.
- name: Run redhat-upgrade-tool
ansible.builtin.shell: >
export PATH={{ os_release }};
set -o pipefail;
redhat-upgrade-tool --network 7.9 --instrepo {{ rhel_7_network_install_repo_url }} --force --cleanup-post
2>&1 | tee -a {{ log_file }}
Expand Down

0 comments on commit 78f8520

Please sign in to comment.