The repository mixed both extensions, the molecule scenario used yml while the role itself used yaml. The yml
extension is the one ansible-galaxy and molecule generate and the one the sibling roles use, so it is applied
throughout.
The first_found lookups in tasks/main.yml name the candidate files explicitly and were adjusted accordingly, otherwise
the role would no longer find its distribution variables and its verification tasks.
Co-authored-by: Copilot <copilot@github.com>
The default filter only replaces undefined values unless its boolean flag is
enabled. An entry with 'filename: ""' - as documented in defaults/main.yaml -
therefore produced a sudoers drop-in file without a name. Enabling the flag
makes the role fall back to the user or group name for empty filenames as
well.
Co-authored-by: Copilot <copilot@github.com>
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>
The regular expression required a leading hash, but sudo 1.9.1 introduced @includedir and distributions such as
Debian 12, Ubuntu 22.04, RHEL 9 and Arch Linux ship /etc/sudoers with that syntax. Since the existing line was never
matched, lineinfile appended a second directive and /etc/sudoers.d was included twice.
The dot in sudoers.d is escaped as well, so the expression no longer matches unrelated paths.
Co-authored-by: Copilot <copilot@github.com>
Recreating /etc/sudoers.d on every run deleted every drop-in file on the host, not only the ones managed by this role.
That removes files shipped by packages or other tooling, such as 90-cloud-init-users on cloud instances, which can lock
out the remaining login paths. The task also reported changed on every run and therefore made check mode and CI runs
useless for detecting real drift.
The directory is now only ensured with its owner, group and permissions. To keep entries removable, each item of
sudo_users_sudoers accepts an optional state, which is passed to community.general.sudoers and defaults to present.
BREAKING CHANGE: Entries dropped from sudo_users_sudoers are no longer deleted implicitly. Set state: absent on the
entry to remove its drop-in file.
Co-authored-by: Copilot <copilot@github.com>
The variable verification was included via include_vars, which is meant for variable files only. Additionally the
first_found lookup had no paths defined, so it searched the files/ subdirectory and the role root instead of tasks/ and
failed with "No file was found". Switching to include_tasks and adding the tasks path makes the verification run at all.
The assertion itself was fully commented out and is now active, so a misconfigured entry fails early instead of being
silently skipped by all four sudoers tasks.
Co-authored-by: Copilot <copilot@github.com>