mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Add support for host restriction in sudoers module (#5703)
* Add support to restrict privileges by host * Missing comma * Making linter happy. * Add version 6.2.0 as when sudoers host parameter added Co-authored-by: Felix Fontein <felix@fontein.de> * Changelog fragment for PR #5703 * Test for sudoers host-based restriction Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -131,6 +131,19 @@
|
||||
src: "{{ sudoers_path }}/my-sudo-rule-6"
|
||||
register: rule_6_contents
|
||||
|
||||
- name: Create rule to allow user to sudo just on host-1
|
||||
community.general.sudoers:
|
||||
name: my-sudo-rule-7
|
||||
state: present
|
||||
user: alice
|
||||
host: host-1
|
||||
commands: /usr/local/bin/command
|
||||
register: rule_7
|
||||
|
||||
- name: Grab contents of my-sudo-rule-7
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ sudoers_path }}/my-sudo-rule-7"
|
||||
register: rule_7_contents
|
||||
|
||||
- name: Revoke rule 1
|
||||
community.general.sudoers:
|
||||
@@ -229,6 +242,7 @@
|
||||
- "rule_4_contents['content'] | b64decode == '%students ALL=NOPASSWD: /usr/local/bin/command\n'"
|
||||
- "rule_5_contents['content'] | b64decode == 'alice ALL=NOPASSWD: /usr/local/bin/command\n'"
|
||||
- "rule_6_contents['content'] | b64decode == 'alice ALL=(bob)NOPASSWD: /usr/local/bin/command\n'"
|
||||
- "rule_7_contents['content'] | b64decode == 'alice host-1=NOPASSWD: /usr/local/bin/command\n'"
|
||||
|
||||
- name: Check revocation stat
|
||||
ansible.builtin.assert:
|
||||
|
||||
Reference in New Issue
Block a user