-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from stackhpc/sudoers
Add sudoers element
- Loading branch information
Showing
5 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-installs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sudo: |