Skip to content
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

Build, find, and test Ansible per-rule playbooks #221

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/util/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ def _find_playbooks(root):
build_content(user_content)
return user_content / 'build' / 'ansible'
else:
return root / Path('/usr/share/scap-security-guide/ansible')
return root / Path('usr/share/scap-security-guide/ansible')


def _find_per_rule_playbooks(root):
if user_content:
build_content(user_content)
return user_content / 'build' / f'rhel{rhel.major}' / 'playbooks' / 'all'
else:
return root / Path(
f'usr/share/scap-security-guide/ansible/rule_playbooks/rhel{rhel.major}/all'
)


def get_playbook(profile, root='/'):
Expand All @@ -65,9 +75,12 @@ def get_playbook(profile, root='/'):


def iter_playbooks(root='/'):
for file in _find_playbooks(root).rglob('*'):
for file in _find_playbooks(root).iterdir():
if file.suffix == '.yml':
yield file
per_rule_dir = _find_per_rule_playbooks(root)
if per_rule_dir.exists():
yield from per_rule_dir.iterdir()


def get_kickstart(profile):
Expand Down Expand Up @@ -98,7 +111,7 @@ def build_content(path):
cmd = ['dnf', '-y', 'builddep', '--spec', 'scap-security-guide.spec']
util.subprocess_run(cmd, check=True, cwd=path)
# build content
cmd = ['./build_product', f'rhel{rhel.major}']
cmd = ['./build_product', '--playbook-per-rule', f'rhel{rhel.major}']
util.subprocess_run(cmd, check=True, cwd=path)


Expand Down Expand Up @@ -139,6 +152,6 @@ def get_content(build=True):
raise FileNotFoundError(f"{extracted} not in extracted/patched SRPM")
# build content
if build:
cmd = ['./build_product', f'rhel{rhel.major}']
cmd = ['./build_product', '--playbook-per-rule', f'rhel{rhel.major}']
util.subprocess_run(cmd, check=True, cwd=extracted)
yield extracted
1 change: 1 addition & 0 deletions plans/errata.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ discover:
# just some basic smoke testing that should never fail
- /scanning/oscap-eval
- /static-checks
- /static-checks/ansible/syntax-check
exclude:
# often fails on temporary retrieval issues
- /static-checks/html-links
Expand Down