-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·48 lines (35 loc) · 1.26 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
APP_DEB_PACKAGE=
TARGET_HOST=
REMOTE_USER=pi
if [[ $# -ne 2 ]]; then
echo "[!] Define a target host and the path to the Debian application package"
exit 1;
fi
TARGET_HOST=$1
APP_DEB_PACKAGE=$2
if [[ ! -f ${APP_DEB_PACKAGE} ]]; then
echo "[!] Debian installation package '${APP_DEB_PACKAGE}' not found"
exit 1;
fi
APP_DEB_PACKAGE_NAME=$(basename "${APP_DEB_PACKAGE}")
echo -e "[i] Symlink Debian installation package to ansible directory"
ln -fvs "$(pwd)/${APP_DEB_PACKAGE}" ansible
echo -e "[i] Create a Ansible hosts file"
echo -e "[jberts]\n${TARGET_HOST}" > ansible/hosts
cat ansible/hosts
if [[ -f "$(pwd)/application.yml" ]]; then
echo -e "[i] Symlink application configuration file to ansible directory"
ln -fvs "$(pwd)/application.yml" ansible
fi
echo -e "[i] Run Ansible playbook"
cd ansible
time ansible-playbook deploy.yml -i hosts -u ${REMOTE_USER} -e "local_jbert_deb_package=${APP_DEB_PACKAGE_NAME}"
cd -
echo -e "[i] Remove generated ansible hosts file"
rm -v ansible/hosts
echo -e "[i] Remove symlink to Debian installation package in ansible directory"
rm -fv "ansible/${APP_DEB_PACKAGE_NAME}"
echo -e "[i] Remove symlink to application configuration ansible directory"
rm -fv "ansible/${APP_DEB_PACKAGE_NAME}"
echo -e "[i] Done"