Add support for setenv parameters (#5883)

This commit is contained in:
Renaud 2023-01-30 06:30:54 +01:00 committed by GitHub
commit dcc3d4f508
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 2 deletions

View file

@ -145,6 +145,20 @@
src: "{{ sudoers_path }}/my-sudo-rule-7"
register: rule_7_contents
- name: Create rule with setenv parameters
community.general.sudoers:
name: my-sudo-rule-8
state: present
user: alice
commands: /usr/local/bin/command
setenv: true
register: rule_8
- name: Grab contents of my-sudo-rule-8
ansible.builtin.slurp:
src: "{{ sudoers_path }}/my-sudo-rule-8"
register: rule_8_contents
- name: Revoke rule 1
community.general.sudoers:
name: my-sudo-rule-1
@ -202,7 +216,6 @@
when: ansible_os_family != 'Darwin'
register: edge_case_3
- name: Revoke non-existing rule
community.general.sudoers:
name: non-existing-rule
@ -243,6 +256,7 @@
- "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'"
- "rule_8_contents['content'] | b64decode == 'alice ALL=NOPASSWD:SETENV: /usr/local/bin/command\n'"
- name: Check revocation stat
ansible.builtin.assert: