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

Make the ansible scripts a little safer. #47

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 12 additions & 3 deletions ansible/install-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
mode: 0664
notify:
- restart tomcat

# configure tomcat startup properties
# change restarts tomcat
# - name: tomcat startup params
Expand All @@ -50,7 +50,7 @@
notify: restart apache

# copy the attributes data file
# until this is in the database
# until this is in the database
- name: copy attribute data
copy: "src=../attribute.xml dest={{ spreg_root }}/attribute.xml group=iam-dev mode=664"
notify: restart tomcat
Expand All @@ -75,9 +75,18 @@
- name: copy xmlsectool
synchronize: "src=../xmlsectool dest={{ spreg_root }} "

# run any handlers
# run any handlers
- meta: flush_handlers

# Do a basic smoke test
- name: smoke test (fetch url)
uri:
url: https://iam-tools-test.u.washington.edu/spreg/
method: GET
return_content: true
register: this
failed_when: this is failed or "'Login with your UW NetID' not in this.content"

# handlers mostly standard from iam-ansible

handlers:
Expand Down
20 changes: 18 additions & 2 deletions ansible/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ while getopts 'h?l:Hvdp:' opt; do
;;
p) playbook=$OPTARG
;;
y) force=1
;;
esac
done

Expand All @@ -73,6 +75,21 @@ target="$2"
[[ "$target" == "eval" || "$target" == "prod" || "$target" == "targets" ]] || usage
[[ "$target" != "targets" ]] || targets
[[ -z $playbook ]] && playbook="install-${product}.yml"

if [[ $target =~ "prod" && force -eq 0 ]]
then
target=
read -p "Are you sure you want to push prod? [yN] " -r -n1
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
target="prod"
else
echo "Aborting"
exit 1
fi
fi

echo "Installing $playbook to $target"
[[ -r $playbook ]] || {
echo "Playbook $playbook not found!"
Expand Down Expand Up @@ -114,7 +131,7 @@ END
}


# run the installer
# run the installer

vars=
(( verb>0 )) && vars="$vars -v "
Expand All @@ -124,4 +141,3 @@ vars=
vars="$vars -l $limit "
}
ansible-playbook ${playbook} $vars -i ./hosts --extra-vars "target=${target}"