Skip to content

Commit

Permalink
Merge pull request #42 from stackhpc/sudoers
Browse files Browse the repository at this point in the history
Add sudoers element
  • Loading branch information
markgoddard authored Aug 5, 2022
2 parents d1d7dcd + bed0a1b commit 696b975
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
18 changes: 18 additions & 0 deletions elements/sudoers/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
=======
sudoers
=======

This element allows for injecting sudoers configuration into an image.

Environment Variables
---------------------

DIB_SUDOERS_FILENAME
:Required: No
:Default: dib
:Description: Name of the sudoers file in /etc/sudoers.d/

DIB_SUDOERS_CONFIG
:Required: Yes
:Default: None
:Description: Sudoers configuration to inject
1 change: 1 addition & 0 deletions elements/sudoers/element-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-installs
2 changes: 2 additions & 0 deletions elements/sudoers/environment.d/sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export DIB_SUDOERS_FILENAME=${DIB_SUDOERS_FILENAME:-dib}
export DIB_SUDOERS_CONFIG=${DIB_SUDOERS_CONFIG:?Please set DIB_SUDOERS_CONFIG}
11 changes: 11 additions & 0 deletions elements/sudoers/install.d/50-sudoers
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail

echo "${DIB_SUDOERS_CONFIG}" > /etc/sudoers.d/${DIB_SUDOERS_FILENAME}
chmod 0440 /etc/sudoers.d/${DIB_SUDOERS_FILENAME}
visudo -c || (rm /etc/sudoers.d/${DIB_SUDOERS_FILENAME} && false)
1 change: 1 addition & 0 deletions elements/sudoers/package-installs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo:

0 comments on commit 696b975

Please sign in to comment.