-
Notifications
You must be signed in to change notification settings - Fork 750
Add option to enable installation of individual ansible playbooks per rule #7039
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
Add option to enable installation of individual ansible playbooks per rule #7039
Conversation
|
Skipping CI for Draft Pull Request. |
CMakeLists.txt
Outdated
| option(SSG_SEPARATE_SCAP_FILES_ENABLED "If enabled, separate SCAP files (OVAL, XCCDF, CPE dict, ...) will be installed alongside the source data-streams" TRUE) | ||
| option(SSG_ANSIBLE_PLAYBOOKS_ENABLED "If enabled, Ansible Playbooks for each profile will be built and installed." TRUE) | ||
| option(SSG_BASH_SCRIPTS_ENABLED "If enabled, Bash remediation scripts for each profile will be built and installed." TRUE) | ||
| option(SSG_ANSIBLE_TASKS_ENABLED "If enabled, Ansible Tasks for each rule will be installed." FALSE) |
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.
What about guarding the call of the ssg_build_ansible_playbooks macro by this option?
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.
it makes sense
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.
can you please check if this is what you had in mind? 1ec2353
CMakeLists.txt
Outdated
| option(SSG_SEPARATE_SCAP_FILES_ENABLED "If enabled, separate SCAP files (OVAL, XCCDF, CPE dict, ...) will be installed alongside the source data-streams" TRUE) | ||
| option(SSG_ANSIBLE_PLAYBOOKS_ENABLED "If enabled, Ansible Playbooks for each profile will be built and installed." TRUE) | ||
| option(SSG_BASH_SCRIPTS_ENABLED "If enabled, Bash remediation scripts for each profile will be built and installed." TRUE) | ||
| option(SSG_ANSIBLE_TASKS_ENABLED "If enabled, Ansible Tasks for each rule will be installed." FALSE) |
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.
In fact, these files are Ansible Playbooks, so using the term "tasks" is misleading.
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.
I understand that... but how should I call them since SSG_ANSIBLE_PLAYBOOKS_ENABLED is already being used?
maybe SSG_ANSIBLE_INDIVIDUAL_PLAYBOOKS_ENABLED or SSG_ANSIBLE_PLAYBOOKS_PER_RULE_ENABLED?
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.
I've changed to SSG_ANSIBLE_PLAYBOOKS_PER_RULE_ENABLED, see: 81f9051#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR51
cmake/SSGCommon.cmake
Outdated
| if(SSG_ANSIBLE_TASKS_ENABLED) | ||
| install( | ||
| CODE " | ||
| file(GLOB ROLE_FILES \"${CMAKE_BINARY_DIR}/${PRODUCT}/playbooks/*.yml\") \n |
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.
In fact, these files are Ansible Playbooks and you also have used the misleading word "tasks" for it before so I think using the term "role" for them increases confusion.
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.
that's correct... it was a copy paste problem
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.
I have also changed the folder's name that holds all the ansible playbooks from tasks to playbooks. So files will be installed to ansible/playbooks/
fadda7a to
035fe7a
Compare
035fe7a to
b033813
Compare
|
/retest |
cmake/SSGCommon.cmake
Outdated
| CODE " | ||
| file(GLOB PLAYBOOK_PER_RULE_FILES \"${CMAKE_BINARY_DIR}/${PRODUCT}/playbooks/*\") \n | ||
| if(NOT IS_ABSOLUTE ${SSG_ANSIBLE_ROLE_INSTALL_DIR}/playbooks) | ||
| file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${SSG_ANSIBLE_ROLE_INSTALL_DIR}/playbooks/${PRODUCT}\" |
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.
I'm sorry, I had a comment but I apparently didn't submit it or I misclicked. My comment was that the ${SSG_ANSIBLE_ROLE_INSTALL_DIR} is already used to install profile playbooks. But the downstream Linux distributions will want to place the rule playbooks to a different subpackage than the profile playbooks. Therefore I think it might be better to put the rule playbooks to a different directory than ${SSG_ANSIBLE_ROLE_INSTALL_DIR}. What is your opinion on that?
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.
I understand your concern, but it would feel really strange to have ansible playbooks on a different folder than {SSG_ANSIBLE_ROLE_INSTALL_DIR} (which is usually scap-security-guide/ansible). That's why a created a subfolder called playbooks where this files would be installed. I guess the fact that downstream Linux distributions will use these files on a different subpackage doesn't necessarily mean we have to install these files on a different top-level directory.
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.
but it would feel really strange to have ansible playbooks on a different folder than {SSG_ANSIBLE_ROLE_INSTALL_DIR}
It depends, something like /usr/share/scap-security-guide/rule_ansible_playbooks/ could work.
I guess the fact that downstream Linux distributions will use these files on a different subpackage doesn't necessarily mean we have to install these files on a different top-level directory.
That's correct, it's certainly possible to pick the right items for the (sub)packages in spec file.
I mean I think it's fine in the current form, I was curious if we could come up with something possibly better or not.
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.
As the profile playbooks installed in ${SSG_ANSIBLE_ROLE_INSTALL_DIR}/ are actually playbooks (not roles), how about installing the rule playbooks in ${SSG_ANSIBLE_ROLE_INSTALL_DIR}/rule_playbooks/${PRODUCT}?
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.
I agree that the naming is a bit confusing here. I guess it's better to have explicit than some hidden meaning. I'll update it accordingly. Thanks
b033813 to
a705438
Compare
|
/retest |
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.
Just running cmake I get the following warning for each product:
CMake Warning (dev) at cmake/SSGCommon.cmake:804 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run "cmake --help-policy CMP0046" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
The dependency target "generate-chromium-ansible-playbooks" of target
"chromium-content" does not exist.
Call Stack (most recent call first):
chromium/CMakeLists.txt:6 (ssg_build_product)
This warning is for project developers. Use -Wno-dev to suppress it.
The problem is that SSG_ANSIBLE_PLAYBOOKS_PER_RULE_ENABLED being false by default, disables ssg_build_ansible_playbooks(${PRODUCT}) which would add the custom_target generate-${PRODUCT}-ansible-playbooks.
That's why I had initially an |
I think the Line 755 in a705438
|
hopefully that's what you had in mind :) f7bb68f |
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.
hopefully that's what you had in mind :) f7bb68f
Almost there, see my comments.
f7bb68f to
141dce8
Compare
Now I get warnings when doing this, :( @ggbecker I apologize, my suggestion doesn't work as expected. I think you'll need to have a better look on why this dependency is added here: Lines 805 to 808 in 141dce8
To me it looks like it should be moved closer to where it is defined. |
I brought the dependency definition closer to the target definition. That might fix the issue, although I'm not entirely sure if this would cause any undesired side effect. See: 02df119 |
605f4a3 to
f637c88
Compare
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, I just have one comment about the install path of rule playbooks.
cmake/SSGCommon.cmake
Outdated
| CODE " | ||
| file(GLOB PLAYBOOK_PER_RULE_FILES \"${CMAKE_BINARY_DIR}/${PRODUCT}/playbooks/*\") \n | ||
| if(NOT IS_ABSOLUTE ${SSG_ANSIBLE_ROLE_INSTALL_DIR}/playbooks) | ||
| file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/${SSG_ANSIBLE_ROLE_INSTALL_DIR}/playbooks/${PRODUCT}\" |
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.
As the profile playbooks installed in ${SSG_ANSIBLE_ROLE_INSTALL_DIR}/ are actually playbooks (not roles), how about installing the rule playbooks in ${SSG_ANSIBLE_ROLE_INSTALL_DIR}/rule_playbooks/${PRODUCT}?
A dependency on rule playbooks target was being added from a conditional branch related to profile playbooks. It caused issues when building profile playbooks but not rule playbooks, the rule playbooks target would not exist, but still be added as dependency. Co-authored-by: Watson Sato <[email protected]>
f637c88 to
8b99c9c
Compare
I have updated the installing directory. |
|
@JAORMX Hey man, I see a a lot of "didn't match expected results" in the rhcos e2e, are these somehow expected? |
|
/retest |
|
Test results look good now, :) |
Description: