fix(tasks): match entries with empty user, group or runas values
The conditions relied on 'is defined' and 'is not defined'. An entry which declares the unused key with an empty string - as documented in defaults/main.yaml - matched none of the four tasks, so the sudoers drop-in file was silently not created. Comparing the length of the defaulted values instead makes exactly one task apply to every entry accepted by the validation. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
+12
-12
@@ -59,9 +59,9 @@
|
|||||||
commands: "{{ item.commands | default('ALL') }}"
|
commands: "{{ item.commands | default('ALL') }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ sudo_users_sudoers }}"
|
- "{{ sudo_users_sudoers }}"
|
||||||
when: item.user is defined and item.user | length > 0 and
|
when: item.user | default('') | length > 0 and
|
||||||
item.group is not defined and
|
item.group | default('') | length == 0 and
|
||||||
item.runas is not defined
|
item.runas | default('') | length == 0
|
||||||
|
|
||||||
- name: "Create sudoers drop-in file to execute commands for specific unix users as specific unix user"
|
- name: "Create sudoers drop-in file to execute commands for specific unix users as specific unix user"
|
||||||
community.general.sudoers:
|
community.general.sudoers:
|
||||||
@@ -73,9 +73,9 @@
|
|||||||
commands: "{{ item.commands | default('ALL') }}"
|
commands: "{{ item.commands | default('ALL') }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ sudo_users_sudoers }}"
|
- "{{ sudo_users_sudoers }}"
|
||||||
when: item.user is defined and item.user | length > 0 and
|
when: item.user | default('') | length > 0 and
|
||||||
item.group is not defined and
|
item.group | default('') | length == 0 and
|
||||||
item.runas is defined and item.runas | length > 0
|
item.runas | default('') | length > 0
|
||||||
|
|
||||||
- name: "Create sudoers drop-in file to execute commands for specific unix groups"
|
- name: "Create sudoers drop-in file to execute commands for specific unix groups"
|
||||||
community.general.sudoers:
|
community.general.sudoers:
|
||||||
@@ -86,9 +86,9 @@
|
|||||||
commands: "{{ item.commands | default('ALL') }}"
|
commands: "{{ item.commands | default('ALL') }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ sudo_users_sudoers }}"
|
- "{{ sudo_users_sudoers }}"
|
||||||
when: item.user is not defined and
|
when: item.user | default('') | length == 0 and
|
||||||
item.group is defined and item.group | length > 0 and
|
item.group | default('') | length > 0 and
|
||||||
item.runas is not defined
|
item.runas | default('') | length == 0
|
||||||
|
|
||||||
- name: "Create sudoers drop-in file to execute commands for specific unix groups as specifix unix user"
|
- name: "Create sudoers drop-in file to execute commands for specific unix groups as specifix unix user"
|
||||||
community.general.sudoers:
|
community.general.sudoers:
|
||||||
@@ -100,6 +100,6 @@
|
|||||||
commands: "{{ item.commands | default('ALL') }}"
|
commands: "{{ item.commands | default('ALL') }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ sudo_users_sudoers }}"
|
- "{{ sudo_users_sudoers }}"
|
||||||
when: item.user is not defined and
|
when: item.user | default('') | length == 0 and
|
||||||
item.group is defined and item.group | length > 0 and
|
item.group | default('') | length > 0 and
|
||||||
item.runas is defined and item.runas | length > 0
|
item.runas | default('') | length > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user