Skip to content
Open
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
29 changes: 25 additions & 4 deletions bin/run-ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ aurora_home=/tmp/aurora

playbook=$1
aurora_limit=all
test_machine=false
shift

while [[ $# -gt 1 ]]
Expand All @@ -67,14 +68,18 @@ case ${key} in
read_secure="$2"
shift 2
;;
--test-machine)
test_machine="$2"
shift 2
;;
*)
break
;;
esac
done


if [[ "${playbook}" = "server_and_nuc_deploy" || "${playbook}" = "teleop_deploy" ]]; then
if [[ "${playbook}" = "server_and_nuc_deploy" || "${playbook}" = "teleop_deploy" ]] && [[ "${test_machine}" = "false" ]]; then
if [[ -z ${read_secure} ]]; then
read_secure="sudo_password"
else
Expand Down Expand Up @@ -116,6 +121,7 @@ echo "playbook = ${playbook}"
echo "branch = ${aurora_tools_branch}"
echo "inventory = ${aurora_inventory}"
echo "limit = ${aurora_limit}"
echo "Testing setup= ${test_machine}"

export ANSIBLE_ROLES_PATH="${aurora_home}/ansible/roles"
export ANSIBLE_CALLBACK_PLUGINS="${HOME}/.ansible/plugins/callback:/usr/share/ansible/plugins/callback:${aurora_home}/ansible/playbooks/callback_plugins"
Expand Down Expand Up @@ -328,6 +334,11 @@ echo " | Installing needed packages |"
echo " ---------------------------------"
echo ""

if [[ "${test_machine}" = "true" ]]; then
echo $test_password | sudo -S echo "Running on testing machine. Retrieving passwords from ENV..."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where does the variable test_password get set? Should we add an example or instructions or a script that calls run-ansible.sh after setting this variable?

formatted_extra_vars="$formatted_extra_vars sudo_password=$test_password docker_username=$docker_username docker_password=$docker_password ansible_sudo_pass=$test_password"
fi

# Wait for apt-get update lock file to be released
while (sudo fuser /var/lib/apt/lists/lock >/dev/null 2>&1) || (sudo fuser /var/lib/dpkg/lock >/dev/null 2>&1) do
echo "Waiting for apt-get update file lock..."
Expand Down Expand Up @@ -395,15 +406,23 @@ if [[ "${playbook}" = "server_and_nuc_deploy" ]]; then
else
aurora_inventory="ansible/inventory/server_and_nuc/${aurora_inventory}"
fi
ansible_flags="${ansible_flags} --ask-vault-pass"
if [[ "${test_machine}" = "true" ]]; then
ansible_flags="${ansible_flags} --vault-password-file /home/$USER/vault.sh"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How does the vault.sh file look like? Should we add an exmple file? or a comment describing the contents of such file?

else
ansible_flags="${ansible_flags} --ask-vault-pass"
fi
echo ""
echo " ---------------------------------------------------"
echo " | VAULT password: |"
echo " | Enter the VAULT password provided by Shadow |"
echo " ---------------------------------------------------"
echo ""
elif [[ "${playbook}" = "teleop_deploy" ]]; then
ansible_flags="${ansible_flags} --ask-vault-pass"
if [[ "${test_machine}" = "true" ]]; then
ansible_flags="${ansible_flags} --vault-password-file /home/$USER/vault.sh"
else
ansible_flags="${ansible_flags} --ask-vault-pass"
fi
if [[ "${aurora_inventory}" = "" ]]; then
aurora_inventory="ansible/inventory/teleop/production"
else
Expand All @@ -418,7 +437,9 @@ elif [[ "${playbook}" = "teleop_deploy" ]]; then
echo ""
else
aurora_inventory="ansible/inventory/${aurora_inventory}"
ansible_flags="${ansible_flags} --ask-become-pass"
if [[ "${test_machine}" != "true" ]]; then
ansible_flags="${ansible_flags} --ask-become-pass"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why don't we need the become password in the test_machine case?

fi
echo ""
echo " --------------------------------------------"
echo " | BECOME password: |"
Expand Down