* separate launch script by runner type concepts

* do not launch sudo playbook for simple server install
* use domain_name as env variable from launch script
This commit is contained in:
2024-01-22 01:24:38 +03:00
parent ffb599469e
commit 958e39bce7
5 changed files with 71 additions and 16 deletions

48
run-playbook.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/bash
SERVER=$1
PLAYBOOK=$2
SITE_NAME=$3
while [[ "$#" -gt 0 ]]; do
case $1 in
-f|--force) force=1; shift ;;
esac
shift
done
usage() {
echo "Usage: run-vps-playbook.sh server playbook"
echo "server - domain or ip address of the vps server"
echo "playbook - playbook file"
}
if [[ -z "$SERVER" ]]; then
echo "You must defined SERVER as first argument"
usage
exit 1
fi
if [[ -z "$PLAYBOOK" ]]; then
echo "You must defined PLAYBOOK as second argument"
usage
exit 1
fi
COMMAND=$(cat <<EOF
ansible-playbook -e "lxc_host=${SERVER} -e runner=normal"
EOF
)
COMMAND="${COMMAND} ${PLAYBOOK}"
if [[ -z "$force" ]]; then
printf 'Launch ansible playbook:\n%s\n' "${COMMAND}"
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
/bin/bash -c "${COMMAND}"
fi
else
/bin/bash -c "${COMMAND}"
fi