refactor: Refactor remediations - extract common code into role main - do not use fail/rescue
There was a lot of code duplication in the remedation task files. This has been extracted into the remediation role main task file.
The remediation tasks were using fail/rescue for flow control, which makes looking at the
logs very confusing, as you really have to know which tasks to exclude when looking for errors.
Instead, use plain old conditionals with blocks for tasks to run conditionally. NOTE: The
old way of using rescue would essentially catch and ignore all errors - this seems
wrong to me, but perhaps there is a reason. This means that now, remediation may raise
errors where before it would not.
Use ansible good practices:
- Use
varsinstead ofset_factand keep the variables set at the lowest necessary scope - Use filters instead of loops
- Use conditional evaluation instead of comparing a value
== true - Use tests such as
is successrather than looking at the register rc value directly
Signed-off-by: Rich Megginson [email protected]
@amott-rh https://github.com/redhat-cop/infra.leapp/pull/300/files#diff-1788d33239b6df3604a4164252101a7700ac2aa672847c342d39992157f11b19R149 - not sure if rhel6 is relevant anymore
@Monnte or @bontreger https://github.com/redhat-cop/infra.leapp/pull/300/files#diff-a3d91dba9d061cfe847d2472205b2352f875c6bf7c9358d4cdd2cc1f149288c6R37 - can we remove the check for systemd mounts?
I have tested this with very few actual remediations - we need to have a way, in our testing, to configure the system beforehand needing all of the remediations. I have run tests on el8 and el9 with all remediations enabled and verified that they are run correctly, or are correctly skipped.
[citest]
@richm Hello, I am no longer working at RedHat and not maintaining this stuff, so I can't help you with that answer.
@richm Probably in general RHEL 6 has become less relevant, but I wrote that remediation precisely because I had customer engagements that were upgrading RHEL 6 servers and ran into the /usr issue. I also have colleagues in the same position, but agree it's generally rare.
[citest]
@spetrosi are these 7to8 and 9to10 errors expected?
[citest]
Any objection to merging this? We will be adding tests for remediations in upcoming PRs