2024-02-14 15:51:08 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
cd $(dirname "${BASH_SOURCE[0]}")
|
|
|
|
|
|
|
|
if [[ "$RUNNER_DEBUG" == "1" ]]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
|
|
|
OPERATION=$1
|
|
|
|
REGION=$2
|
2024-07-24 14:45:02 +00:00
|
|
|
CLUSTER_NAME=$3
|
2024-02-14 15:51:08 +00:00
|
|
|
|
|
|
|
case $OPERATION in
|
|
|
|
requirements)
|
|
|
|
ansible-galaxy collection install -r requirements.yml
|
2024-06-13 08:37:44 +00:00
|
|
|
pip3 install --user "ansible==9.*" boto3 botocore
|
2024-02-14 15:51:08 +00:00
|
|
|
;;
|
|
|
|
create|delete|start|stop)
|
|
|
|
if [ -f "env.yml" ]; then ANSIBLE_CUSTOM_VARS_ARG="-e @env.yml"; fi
|
2024-07-24 14:45:02 +00:00
|
|
|
ansible-playbook aws_ec2.yml -v -e "region=$REGION" -e "operation=$OPERATION" -e "cluster_name=$CLUSTER_NAME" $ANSIBLE_CUSTOM_VARS_ARG "${@:4}"
|
2024-02-14 15:51:08 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid option!"
|
|
|
|
echo "Available operations: requirements, create, delete, start, stop."
|
|
|
|
;;
|
|
|
|
esac
|