Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions run-playbook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ if [ "$EUID" -eq 0 ]; then
ansible-playbook playbook.yml -e ansible_become=false "$@"
PLAYBOOK_EXIT=$?
else
ansible-playbook playbook.yml --ask-become-pass "$@"
PLAYBOOK_EXIT=$?
if sudo -n true 2>/dev/null; then
echo "Passwordless sudo detected. Running without become password prompt."
ansible-playbook playbook.yml "$@"
PLAYBOOK_EXIT=$?
else
echo "Sudo password required. Prompting for become password."
ansible-playbook playbook.yml --ask-become-pass "$@"
PLAYBOOK_EXIT=$?
fi
fi

# After playbook completes successfully, show instructions
Expand Down