Skip to content

Commit

Permalink
Merge pull request #47 from UWIT-IAM/ansible
Browse files Browse the repository at this point in the history
Make the ansible scripts a little safer.
  • Loading branch information
stea-uw authored Jan 22, 2024
2 parents 03ab5d5 + f531772 commit 9606462
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
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}"

0 comments on commit 9606462

Please sign in to comment.