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

Fix tests for sudo_require_authentication #11315

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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ echo "Defaults !authenticate" >> /etc/sudoers
chmod 440 /etc/sudoers

mkdir -p /etc/sudoers.d
echo "%wheel ALL=(ALL) !authenticate ALL" >> /etc/sudoers.d/sudoers
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/sudoers
echo "Defaults !authenticate" >> /etc/sudoers.d/sudoers
chmod 440 /etc/sudoers.d/sudoers
12 changes: 10 additions & 2 deletions shared/macros/10-ansible.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -721,17 +721,25 @@ The following macro remediates Audit syscall rule in :code:`/etc/audit/audit.rul
mode: 0644
{{%- endmacro %}}

{{#
This macro comments out a given line of the sudoers and then validates it before saving.

:param parameter: The parameter to remove
:type parameter: str
:param pattern: The pattern to remove
:type pattern: str

#}}
{{%- macro ansible_sudo_remove_config(parameter, pattern) -%}}

- name: Find /etc/sudoers.d/ files
find:
ansible.builtin.find:
paths:
- /etc/sudoers.d/
register: sudoers

- name: "Remove lines containing {{{ parameter }}} from sudoers files"
replace:
ansible.builtin.replace:
regexp: '(^(?!#).*[\s]+{{{ pattern }}}.*$)'
replace: '# \g<1>'
path: "{{ item.path }}"
Expand Down
Loading