volker.raschekandCopilot f665e0044a
Lint Markdown files / markdown-lint (push) Successful in 6s
Ansible Linter / ansible-lint (push) Canceled after 1h1m39s
Molecule / Molecule (push) Successful in 6m18s
refactor: use the yml extension for every yaml file
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>
2026-09-10 21:57:15 +02:00
2025-04-14 22:31:30 +02:00
2022-05-10 13:40:31 +02:00
2025-04-14 22:31:30 +02:00
2022-05-10 13:40:31 +02:00

volker-raschek.sudo

Ansible Role

With following role can be created sudoers files in /etc/sudoers.d. For example to grant a user special perimssions to execute a program as root.

Supported distributions

  • Arch Linux
  • Debian
  • Fedora
  • RHEL
  • Ubuntu 20.04

Features

  • Installing sudo
  • Configuring drop-on files in /etc/sudoers.d

Tests

The role is tested with Molecule. The scenario starts one docker container per supported distribution family, applies the role, asserts that a second run reports no change and finally verifies the created drop-in files, their permissions and content, that a rule declared as absent is gone again and that visudo accepts the resulting configuration.

Molecule ships only its default driver, therefore docker is required beside molecule itself. The collections are declared in molecule/default/collections.yml and installed by molecule.

pip install molecule docker

The complete sequence creates the containers, tests them and removes them afterwards.

molecule test

While working on the role the containers are better kept alive.

# create the containers and apply the role
molecule converge

# run the assertions of molecule/default/verify.yml against the running containers
molecule verify

# open a shell in one of the containers
molecule login --host sudo-debian

# remove the containers
molecule destroy

Configuring

In the default directory are examples how to configure the network stack. Copy the defaults into your host_vars or group_vars and adapt the examples.

S
Description
Ansible role to create drop-in files for sudoers.d
Readme MIT
158 KiB