-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate profile oriented Ansible Playbooks in a different way #11033
Conversation
This commit converts some of the code to a class. Using class allows us to write cleaner code and avoids need to passing data as parameters.
In this commit, we extend the abilities of `generate_bash_scripts.py` to generate also profile oriented Ansible Playbooks. The script now can generate either profile oriented Bash remediation scripts or profile oriented Ansible Playbooks. Consequently, we need to rename this tool to a more generic name `generate_profile_remediations.py`. The profile oriented Ansible Playbooks generated by `generate_profile_remediations.py` are very similar to Playbooks generated by the `oscap xccdf generate fix` command.
We will generate the profile oriented Ansible Playbooks using the new script `generate_profile_remediations.py` which is faster than the current method that calls `oscap` under its hood.
Reduce the amout of parameters
Code Climate has analyzed commit 9546960 and detected 3 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 53.3% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the PR!
In ComplianceAsCode#11033, we have switched to a new script for generating profile oriented Ansible Playbooks. Unfortunately, when Python 2 is used the generated Ansible Playbooks don't preserve the order of Ansible Tasks in the order defined in the SCAP source data stream. The wrong order of Ansible Tasks in a Playbook might cause an unexpected conflict between them during the run, for example ComplianceAsCode#11104. The root cause of the problem is that dictionaries in Python 2 don't preserve order of elements but starting from Python 3.6 the dictionaries preserve order of its elements. Fixes: ComplianceAsCode#11104
Description:
Extend the abilities of
generate_bash_scripts.py
to generate also profile oriented Ansible Playbooks. The script now cangenerate either profile oriented Bash remediation scripts or profile oriented Ansible Playbooks. Consequently, we need to rename this tool to a more generic name
generate_profile_remediations.py
. The profile oriented Ansible Playbooks generated bygenerate_profile_remediations.py
are very similar to Playbooks generated by theoscap xccdf generate fix
command.The
generate_profile_remediations.py
will be used to generate profile oriented Ansible Playbooks during the build instead of using scripts that calloscap xccdf generate fix
command.The PR contains refactoring of the script.
Rationale:
Review Hints:
Build the content from master and from this branch. Then, compare contents of the
build/ansible
directory in the old and new build usingmeld
ordiff
.