Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change usage of STRAP_INTERACTIVE to STRAP_SUDO_PROMPT #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions lib/ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ strap::lib::import exec || . exec.sh

STRAP_HOME="${STRAP_HOME:-}"; [[ -n "$STRAP_HOME" ]] || { echo "STRAP_HOME is not set" >&2; exit 1; }
STRAP_USER_HOME="${STRAP_USER_HOME:-}"; [[ -n "$STRAP_USER_HOME" ]] || { echo "STRAP_USER_HOME is not set" >&2; exit 1; }
STRAP_INTERACTIVE="${STRAP_INTERACTIVE:-}"; [[ -n "$STRAP_INTERACTIVE" ]] || STRAP_INTERACTIVE=true
STRAP_SUDO_PROMPT="${STRAP_SUDO_PROMPT:-}"; [[ -n "$STRAP_SUDO_PROMPT" ]] || STRAP_SUDO_PROMPT=true
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So one backwards compat option could be to change this to:

STRAP_SUDO_PROMPT="${STRAP_SUDO_PROMPT:-$STRAP_INTERACTIVE}"; [[ -n "$STRAP_SUDO_PROMPT" ]] || STRAP_SUDO_PROMPT=true

Happy to make that change if folks think it would be useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That change looks better from a backwards-compatibility stance IMO

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

STRAP_ANSIBLE_VERSION="${STRAP_ANSIBLE_VERSION:-}"
STRAP_ANSIBLE_DIR="${STRAP_USER_HOME}/ansible"
STRAP_ANSIBLE_LOG_FILE="${STRAP_ANSIBLE_DIR}/ansible.log"
Expand Down Expand Up @@ -135,7 +135,7 @@ function strap::ansible::roles::run() {
esac
done

if [[ "${STRAP_INTERACTIVE}" == true ]]; then # false in CI
if [[ "${STRAP_SUDO_PROMPT}" == true ]]; then # false in CI
params+=( '--ask-become-pass' )
fi

Expand Down Expand Up @@ -267,7 +267,7 @@ EOF
export ANSIBLE_LOG_PATH="${STRAP_ANSIBLE_LOG_FILE}"
strap::ansible-galaxy-install -r "${requirements_file}"
printf '\nRunning ansible to manage localhost.'
if [[ "${STRAP_INTERACTIVE}" == true ]]; then
if [[ "${STRAP_SUDO_PROMPT}" == true ]]; then
printf ' Please enter your SUDO/' # make the --ask-become-pass prompt more visible/obvious
else
printf '\n'
Expand Down Expand Up @@ -305,7 +305,7 @@ strap::ansible::playbook::run() {
esac
done

if [[ "${STRAP_INTERACTIVE}" == true ]]; then # false in CI
if [[ "${STRAP_SUDO_PROMPT}" == true ]]; then # false in CI
params+=( '--ask-become-pass' )
fi

Expand Down Expand Up @@ -343,7 +343,7 @@ strap::ansible::playbook::run() {
export ANSIBLE_LOG_PATH="${STRAP_ANSIBLE_LOG_FILE}"
[[ -f "${requirements_file}" ]] && strap::ansible-galaxy-install -r "${requirements_file}" --force
printf '\nRunning ansible to manage localhost.'
if [[ "${STRAP_INTERACTIVE}" == true ]]; then
if [[ "${STRAP_SUDO_PROMPT}" == true ]]; then
printf ' Please enter your SUDO/' # make the --ask-become-pass prompt more visible/obvious
else
printf '\n'
Expand Down