Skip to content

Commit 40552d8

Browse files
committed
fix: sudo for validate
1 parent c0a1201 commit 40552d8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

ansible/files/cis_baseline_check.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# Baseline Validation Check
33
#
44
# This script validates that the machine matches the committed baseline
5-
# specifications using supascan (pre-installed via nix profile).
5+
# specifications using supascan (pre-installed via nix profile for ubuntu user).
6+
#
7+
# Must be run as ubuntu user with sudo access (supascan calls sudo goss internally).
68
#
79
# Usage: cis_baseline_check.sh [baselines-dir]
810

@@ -23,17 +25,16 @@ if [[ ! -d $BASELINES_DIR ]]; then
2325
exit 1
2426
fi
2527

26-
# Source nix environment
27-
if [[ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]]; then
28-
# shellcheck source=/dev/null
29-
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
30-
fi
28+
# Source nix environment (for ubuntu user's profile)
29+
# shellcheck source=/dev/null
30+
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
3131

3232
# Verify supascan is available
3333
if ! command -v supascan &>/dev/null; then
34-
echo "ERROR: supascan not found. It should be pre-installed via nix profile."
34+
echo "ERROR: supascan not found in PATH"
35+
echo "PATH: $PATH"
3536
exit 1
3637
fi
3738

38-
# Run supascan validate
39+
# Run supascan validate (it calls sudo goss internally for privileged checks)
3940
exec supascan validate --verbose "$BASELINES_DIR"

ansible/playbook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222

223223
- name: Run CIS baseline validation
224224
become: yes
225+
become_user: ubuntu
225226
shell: |
226227
/bin/bash /tmp/ansible-playbook/ansible/files/cis_baseline_check.sh /tmp/ansible-playbook/audit-specs/baselines
227228
when: stage2_nix

0 commit comments

Comments
 (0)