Skip to content

Commit

Permalink
Ensure that doctext blocks end with a blank line
Browse files Browse the repository at this point in the history
  • Loading branch information
Mab879 committed May 10, 2023
1 parent b8e1f10 commit 8e19742
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 10 deletions.
9 changes: 8 additions & 1 deletion shared/macros/01-general.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Therefore, you need to use a tool that can query the OCP API, retrieve the follo

{{#
Macro which generates a unique identifier for Compliance Operator, this will hide the rule from ComplianceCheckResult

#}}
{{% macro hide_rule() -%}}
This rule will be a hidden rule
Expand Down Expand Up @@ -693,6 +694,7 @@ substituting the correct package management software.
{{#
Outputs a command for removing a package, substituting the correct package
management software.

#}}
{{%- macro package_remove(package) -%}}
{{% if pkg_manager is defined %}}
Expand Down Expand Up @@ -762,6 +764,7 @@ substituting the correct package management software.
:type file: str
:param group: The group owner for the file
:type group: str

#}}
{{%- macro describe_file_group_owner(file, group) %}}
To properly set the group owner of <code>{{{ file }}}</code>, run the command:
Expand All @@ -776,6 +779,7 @@ substituting the correct package management software.
:type file: str
:param perms: The permissions for the file
:type perms: str

#}}
{{%- macro check_file_permissions(file, perms) %}}
To check the permissions of <code>{{{ file }}}</code>, run the command:
Expand Down Expand Up @@ -914,6 +918,7 @@ substituting the correct package management software.

{{#
An openssl config file with strong entropy.

#}}
{{% macro openssl_strong_entropy_config_file() -%}}
# provide a default -rand /dev/random option to openssl commands that
Expand Down Expand Up @@ -950,6 +955,7 @@ openssl()

{{#
A note about an item need be done for each :code:`MachineConfigPool`.

#}}
{{% macro machineconfig_description_footer() -%}}
<p>
Expand Down Expand Up @@ -980,6 +986,7 @@ Operator see
{{#
Describe how to configure Grub2 to add an argument to the default kernel command line.
The parameter should be in form `parameter=value`.

#}}
{{%- macro describe_grub2_argument(arg_name_value) -%}}
{{%- if product in ["ol7", "ol8", "ol9", "rhel7", "rhel8", "rhel9"] or 'ubuntu' in product -%}}
Expand Down Expand Up @@ -1023,8 +1030,8 @@ Configure the default Grub2 kernel command line to contain {{{ arg_name_value }}
{{%- endmacro %}}

{{#

Adds a default "no easy remediation" warning for kernel_build_config warning.

#}}
{{% macro kernel_build_config_warning() %}}
- general: |-
Expand Down
17 changes: 17 additions & 0 deletions shared/macros/10-ansible.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ value: :code:`Setting={{ varname1 }}`
calling the ansible_only_lineinfile macro to handle deduplication of values.

Note that all string-like parameters are single quoted in the YAML.

#}}
{{%- macro ansible_lineinfile(msg='', path='', mode='', regex='', new_line='', create='no', state='present', with_items='', register='', when='', validate='', insert_after='', insert_before='', check_mode=False) -%}}
- name: "{{{ msg or rule_title }}}"
Expand Down Expand Up @@ -90,6 +91,7 @@ value: :code:`Setting={{ varname1 }}`

{{#
Find files matching a particular value. Not a full implementation.

#}}
{{%- macro ansible_find(msg='', paths='', recurse='yes', follow='no', contains='', register='', when='') %}}
- name: '{{{ msg or rule_title }}}'
Expand All @@ -115,6 +117,7 @@ value: :code:`Setting={{ varname1 }}`
a single configuration parameter might have multiple values, but only one
value is approved. All lines matching the regex are first removed and then
the new line is appended to the file.

#}}
{{%- macro ansible_only_lineinfile(msg, path, line_regex, new_line, create='no', block=False, validate='', insert_after='', insert_before='', mode='') -%}}
{{%- if block %}}
Expand All @@ -136,6 +139,7 @@ value: :code:`Setting={{ varname1 }}`
key-seperator-value files with no sense of structure. In particular,
ini configuration files are best served with the ini Ansible module
instead of lineinfile-based solutions.

#}}
{{%- macro ansible_set_config_file(msg, file, parameter, separator=' ', separator_regex='\s+', value='', prefix_regex='^\s*', create='no', validate='', insert_after='', insert_before='', escape_regex=False, mode='') %}}
{{{ ansible_only_lineinfile(msg, file, prefix_regex + parameter + separator_regex, parameter + separator + value, create=create, block=True, validate=validate, insert_after=insert_after, insert_before=insert_before, mode=mode) }}}
Expand All @@ -148,6 +152,7 @@ value: :code:`Setting={{ varname1 }}`
files with no sense of structure. In particular, ini configuration files are
best served with the ini Ansible module instead of lineinfile-based
solutions.

#}}
{{%- macro ansible_set_config_file_dir(msg, config_file, config_dir, set_file, parameter, separator=' ', separator_regex='\s+', value='', prefix_regex='^\s*', create='no', validate='', insert_after='', insert_before='') %}}
{{%- set var_dir = config_dir | replace("/", "_") | replace("-", "_") | replace(".", "_") -%}}
Expand Down Expand Up @@ -262,6 +267,7 @@ value: :code:`Setting={{ varname1 }}`
files. Note this is only suitable for calling a single command once with the
correct arguments and not for calling the same command multiple times with
different arguments. This includes setting an environment variable once.

#}}
{{%- macro ansible_etc_profile_set(msg='', parameter='', value='') %}}
{{{ ansible_set_config_file_dir(msg, "/etc/profile", "/etc/profile.d", "/etc/profile", parameter, separator='=', separator_regex='=', value=value, create='yes', validate="bash -n %s") }}}
Expand Down Expand Up @@ -323,6 +329,7 @@ value: :code:`Setting={{ varname1 }}`
:type filepath: str
:param contents: contents that should be in the file
:type contents: str

#}}
{{%- macro ansible_file_contents(filepath='', contents='') %}}
- name: "Put contents into {{{ filepath }}} according to policy"
Expand All @@ -339,6 +346,7 @@ value: :code:`Setting={{ varname1 }}`

:param banner_var_name: name of ansible variable with the banner regex
:type banner_var_name: str

#}}
{{% macro ansible_deregexify_banner_etc_issue(banner_var_name) -%}}
{{ {{{ banner_var_name }}} |
Expand All @@ -356,6 +364,7 @@ wordwrap() }}

:param banner_var_name: name of ansible variable with the banner regex
:type banner_var_name: str

#}}
{{% macro ansible_deregexify_banner_dconf_gnome(banner_var_name) -%}}
''{{ {{{ banner_var_name }}} |
Expand Down Expand Up @@ -719,6 +728,7 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
:param package: package name
:param op: version comparison operator ("<", "<=", "==", "!=", ">", ">=")
:param ver: package version (optional argument, use together with "op")

#}}
{{%- macro ansible_pkg_conditional(package, op=None, ver=None) -%}}
{{%- if package in platform_package_overrides -%}}
Expand All @@ -741,6 +751,7 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
Macro used to check if authselect files are intact. When used, it will exit the respective
script if any authselect file was modified without proper use of authselect tool and
respective profiles.

#}}
{{% macro ansible_check_authselect_integrity() -%}}
- name: '{{{ rule_title }}} - Check integrity of authselect current profile'
Expand Down Expand Up @@ -791,6 +802,7 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
{{#
Enable authselect feature if the authselect current profile is intact or inform that its
integrity check failed.

#}}
{{%- macro ansible_enable_authselect_feature(feature) -%}}
{{{ ansible_check_authselect_integrity() }}}
Expand Down Expand Up @@ -820,6 +832,7 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
{{#
Used to identify if authselect is present or not in the system.
Some macros can change the remediation behavior based on the presence of authselect.

#}}
{{%- macro ansible_check_authselect_presence() -%}}
- name: '{{{ rule_title }}} - Check if system relies on authselect tool'
Expand All @@ -839,6 +852,7 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
:param after_match: Regex used as reference to append a line, if necessary. Optional parameter.
Note: For this macro, there is a special value used to include a line at
the beginning of the file: "BOF"

#}}
{{%- macro ansible_pam_pwhistory_enable(pam_file, control, after_match='') -%}}
{{{ ansible_check_authselect_presence() }}}
Expand Down Expand Up @@ -918,6 +932,7 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
{{#
This macro ensures the pam_faillock.so PAM module is enabled.
It is enabled using the authselect tool or editing the PAM files, only if authselect tool is not available.

#}}
{{%- macro ansible_pam_faillock_enable() -%}}

Expand Down Expand Up @@ -1178,6 +1193,7 @@ Part of the grub2_bootloader_argument_absent template.

{{#
Macro to restrict permissions in home directories of interactive users

#}}
{{%- macro ansible_restrict_permissions_home_directories(recursive=false) -%}}
- name: Get all local users from /etc/passwd
Expand Down Expand Up @@ -1375,6 +1391,7 @@ Part of the grub2_bootloader_argument_absent template.
new custom profile will be created based on the current profile and preserving the already
enabled features. Custom profiles are only recommeded if an authselect feature for the same
purpose is not available.

#}}
{{% macro ansible_ensure_authselect_custom_profile() -%}}
- name: '{{{ rule_title }}} - Get authselect current profile'
Expand Down
Loading

0 comments on commit 8e19742

Please sign in to comment.