Skip to content

Commit b0054e8

Browse files
authored
Add support for RHEL 7 remediate (#237)
* Add support for RHEL 7 remediate * Refactor to remove ansible.builtin.meta: end_host directives * changing dnf to package to work across both rhel 7 and 8+ * fix some shell command change statuses * Add additional playbook to resolve remote login with root issue * Update the checks for leapp_report_missing * Fixing issues with network scripts when no scripts defined * Add logic to prevent issues with undefined mount points * Avoiding an unnecessary reboot * Refactor remediate tasks that have undefined prerequisites * Removing unnecessary sudo commands * Updating fail conditions for better error handling * rewrite tar command to use archive * Rewrite openssl_config remediation to follow support guidance
1 parent 63ddceb commit b0054e8

31 files changed

+319
-110
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,6 @@ dmypy.json
131131

132132
# Pyre type checker
133133
.pyre/
134+
135+
# Local collection testing builds
136+
*.tar.gz

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ These are the roles included in the collection. Follow the links below to see th
1616
- [`common`](./roles/common/) - used for local logging, mutex locking, and common vars
1717
- [`parse_leapp_report`](./roles/parse_leapp_report/) - reads pre-upgrade results and checks for inhibitors
1818
- [`upgrade`](./roles/upgrade/) - executes the Leapp OS upgrade
19-
- [`remediate`](./roles/remediate/) - assists in the remediation of a system (RHEL 8 only)
19+
- [`remediate`](./roles/remediate/) - assists in the remediation of a system (RHEL 7->8 and 8->9 only)
2020

2121
## Supported RHEL versions
2222

@@ -30,6 +30,13 @@ The collection may be used for the RHEL upgrade paths and minor versions support
3030

3131
The roles in this collection have been successfully used in a number of different environments including on-prem bare metal servers and VMs pulling RHEL packages from Red Hat CDN repos, Satellite content views, or mirrored repos internal to disconnected networks. Upgrading RHEL on Amazon EC2 instances pulling from bring-your-own-subscription CDN repos or pay-as-you-go RHUI repos have also been tested. Upgrading RHEL on other public clouds should be possible as well after setting the documented role variables as required.
3232

33+
> [!IMPORTANT]
34+
> Targeting RHEL 6 nodes requires an Ansible-core version <= 2.12
35+
>
36+
> Targeting RHEL 7 nodes requires an Ansible-core version <= 2.16
37+
>
38+
> See [this knowledgebase article](https://access.redhat.com/articles/6977724) for details
39+
3340
## Not in scope
3441

3542
Third-party products and packages are not upgraded by the `upgrade` role. To achieve a complete end-to-end server upgrade, you may need to implement custom automation beyond the scope of this collection to perform tasks required for the upgrade or removal/reinstall of any impacted third-party tools and agents, for example [Veritas Cluster](https://www.veritas.com/support/en_US/doc/infoscale_wp_upgradewithRedHat), [SAP HANA](https://access.redhat.com/solutions/5154031), etc. Likewise, the role does not upgrade packages installed from non-RHEL repositories such as [Red Hat Software Collections](https://access.redhat.com/support/policy/updates/rhscl), [EPEL](https://docs.fedoraproject.org/en-US/epel/), [RPM Fusion](https://rpmfusion.org/), etc.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
major_changes:
3+
- Added support for RHEL 7 -> 8 in the infra.leapp.remediate role
4+
- Rewrote the remediate playbooks to use conditional logic and skip tasks that do not need to run
5+
minor_changes:
6+
- Added pam_tally2 remediation for RHEL 7
7+
- Updated documentation in support of the extended remediate role

galaxy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace: infra
55
name: leapp
6-
version: 1.4.1
6+
version: 1.5.0
77
readme: README.md
88
authors:
99
- Bob Mader (github.com/swapdisk)

roles/remediate/README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Remediations
22

3-
**IMPORTANT:** This role is only supported for RHEL 8 systems.
3+
**IMPORTANT:** This role is only supported for RHEL 7 and 8 systems. Not all remediations are applicable to both, and are noted in the remediation playbooks list below.
44

55
The `remediation` role is to assist in the remediation of a system. This role contains multiple playbooks that can be used to remediate a system for a specific inhibitors that are found during the pre-upgrade analysis.
66

@@ -31,12 +31,16 @@ The list of available remediation playbooks with their corresponding inhibitors
3131
- `leapp_corrupted_grubenv_file`
3232
- **Solves:** Detected a corrupted grubenv file.
3333
- `leapp_custom_network_scripts_detected`
34+
- RHEL 8 Only
3435
- **Solves:** custom network-scripts detected. RHEL 9 does not support the legacy network-scripts package that was deprecated in RHEL 8.
3536
- `leapp_deprecated_sshd_directive`
37+
- RHEL 8 Only
3638
- **Solves:** A deprecated directive in the sshd configuration.
37-
- `leapp_firewalld_allowzonedrifting`:
39+
- `leapp_firewalld_allowzonedrifting`
40+
- RHEL 8 Only
3841
- **Solves:** Firewalld Configuration AllowZoneDrifting Is Unsupported.
3942
- `leapp_firewalld_unsupported_tftp_client`
43+
- RHEL 8 Only
4044
- **Solves:** Firewalld Service tftp-client Is Unsupported.
4145
- `leapp_loaded_removed_kernel_drivers`
4246
- **Solves:** Leapp detected loaded kernel drivers which have been removed in RHEL 8. Upgrade cannot proceed.
@@ -55,18 +59,27 @@ The list of available remediation playbooks with their corresponding inhibitors
5559
- `leapp_non_persistent_partitions`
5660
- **Solves:** Detected partitions mounted in a non-persistent fashion, preventing a successful in-place upgrade.
5761
- `leapp_non_standard_openssl_config`
62+
- RHEL 8 Only
5863
- **Solves:** Non-standard configuration of openssl.cnf.
5964
- `leapp_old_postgresql_data`
6065
- **Solves:** Old PostgreSQL data found in `/var/lib/pgsql/data`.
66+
- `leapp_pam_tally2`
67+
- RHEL 7 Only
68+
- **Solves:** The pam_tally2 pam module(s) no longer available
6169
- `leapp_partitions_with_noexec`
6270
- **Solves:** Detected partitions mounted with the `noexec` option, preventing a successful in-place upgrade.
6371
- `leapp_relative_symlinks`
6472
- **Solves:** Upgrade requires links in root directory to be relative
73+
- `leapp_remote_using_root`
74+
- RHEL 7 Only
75+
- **Solves:** Possible problems with remote login using root account
6576
- `leapp_rpms_with_rsa_sha1_detected`
77+
- RHEL 8 Only
6678
- **Solves:** Detected RPMs with RSA/SHA1 signature.
6779
- `leapp_unavailable_kde`
6880
- **Solves:** The installed KDE environment is unavailable on RHEL 8.
6981
- `leapp_vdo_check_needed`
82+
- RHEL 8 Only
7083
- **Solves:** Cannot perform the VDO check of block devices.
7184

7285
## Example playbook
@@ -75,7 +88,7 @@ See [`remediate.yml`](../../playbooks/remediate.yml).
7588

7689
## Authors
7790

78-
Peter Zdravecký
91+
Peter Zdravecký, Ryan Bontreger
7992

8093
## License
8194

roles/remediate/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ remediation_playbooks:
2121
- leapp_non_persistent_partitions
2222
- leapp_non_standard_openssl_config
2323
- leapp_old_postgresql_data
24+
- leapp_pam_tally2
2425
- leapp_partitions_with_noexec
2526
- leapp_relative_symlinks
27+
- leapp_remote_using_root
2628
- leapp_rpms_with_rsa_sha1_detected
2729
- leapp_unavailable_kde
2830
- leapp_vdo_check_needed

roles/remediate/handlers/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
# handlers file for remedations
33

44
# Keep this last so it's easy to find in the job output.
5+
- name: "Restart sshd"
6+
ansible.builtin.service:
7+
name: sshd
8+
state: restarted
9+
510
- name: The remediations are now complete
611
ansible.builtin.debug:
712
msg: The remediations are now complete.
13+
814
...

roles/remediate/meta/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
galaxy_info:
3-
author: Peter Zdravecký
3+
author: Peter Zdravecký, Ryan Bontreger
44
description: Remedetation part of the leapp process
55
company: Red Hat
66

@@ -31,6 +31,7 @@ galaxy_info:
3131
platforms:
3232
- name: EL
3333
versions:
34+
- "7"
3435
- "8"
3536
# - 25
3637
# - name: SomePlatform

roles/remediate/tasks/leapp_corrupted_grubenv_file.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
register: leapp_report_stat
1111

1212
- name: leapp_corrupted_grubenv_file | End play if no leapp report exists
13-
ansible.builtin.meta: end_host
13+
ansible.builtin.set_fact:
14+
leapp_report_missing: true
1415
when: leapp_report_stat.stat.exists is false
16+
failed_when: leapp_report_stat.stat.exists is false
1517

1618
- name: leapp_corrupted_grubenv_file | Read leapp report
1719
ansible.builtin.slurp:
@@ -29,8 +31,9 @@
2931
when: item.title is match(entry_title) and (item.detail.remediations | selectattr('type', 'eq', 'hint') | length > 0)
3032

3133
- name: leapp_corrupted_grubenv_file | End execution of playbook if no entry found in leapp report
32-
ansible.builtin.meta: end_host
33-
when: hint is not defined
34+
ansible.builtin.set_fact:
35+
leapp_report_missing: true
36+
failed_when: hint is not defined
3437

3538
- name: leapp_corrupted_grubenv_file | Extract file(s) using regex
3639
ansible.builtin.set_fact:
@@ -65,4 +68,9 @@
6568
register: grub_mkconfig
6669
changed_when: grub_mkconfig.rc == 0
6770

71+
rescue:
72+
- name: leapp_corrupted_grubenv_file | Continue when leapp report is missing
73+
ansible.builtin.debug:
74+
msg: "Leapp report missing or did not contain any matches. Skipping this task."
75+
when: leapp_report_missing is defined and leapp_report_missing is true
6876
...

roles/remediate/tasks/leapp_custom_network_scripts_detected.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
---
22
- name: leapp_custom_network_scripts_detected | Move custom network-scripts to NetworkManager dispatcher scripts
3+
when: ansible_distribution == 'RedHat' and ansible_distribution_major_version|int == 8
34
block:
4-
- name: leapp_custom_network_scripts_detected | Create /opt/network-scripts/ directory if it does not exist
5-
ansible.builtin.file:
6-
path: /opt/network-scripts/
7-
state: directory
8-
mode: "0755"
9-
105
- name: leapp_custom_network_scripts_detected | Check if pre up script exists
116
ansible.builtin.stat:
127
path: /sbin/ifup-pre-local
@@ -17,9 +12,23 @@
1712
path: /sbin/ifdown-pre-local
1813
register: pre_down
1914

15+
# If neither script exists, fail out and do not create unnecessary directories
16+
- name: leapp_custom_network_scripts_detected | Skip playbook if no custom scripts are found
17+
ansible.builtin.set_fact:
18+
leapp_report_missing: true
19+
when: pre_down.stat.exists is false and pre_up.stat.exists is false
20+
failed_when: pre_down.stat.exists is false and pre_up.stat.exists is false
21+
22+
- name: leapp_custom_network_scripts_detected | Create /opt/network-scripts/ directory if it does not exist
23+
ansible.builtin.file:
24+
path: /opt/network-scripts/
25+
state: directory
26+
mode: "0755"
27+
2028
- name: leapp_custom_network_scripts_detected | Move scripts in /sbin to /opt/network-scripts/, end playbook if this fails
2129
ansible.builtin.command: mv /sbin/if*-local /opt/network-scripts/
2230
register: move_scripts
31+
when: pre_up.stat.exists or pre_down.stat.exists
2332
changed_when: move_scripts.rc == 0
2433

2534
- name: leapp_custom_network_scripts_detected | Create /etc/NetworkManager/dispatcher.d/20-if-local
@@ -77,4 +86,10 @@
7786
state: link
7887
when: pre_down.stat.exists
7988

89+
rescue:
90+
- name: leapp_custom_network_scripts_detected | Continue when no custom scripts are found
91+
ansible.builtin.debug:
92+
msg: "No custom network scripts detected. Skipping this task."
93+
when: leapp_custom_scripts_missing is defined and leapp_custom_scripts_missing is true
94+
8095
...

0 commit comments

Comments
 (0)