-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy
executable file
·57 lines (51 loc) · 1.22 KB
/
deploy
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
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash -eu
function usage() { # TODO allow configuring via the private address
echo "Usage: $0 -h <host_public_ip> -u <adminuser> -i <ssh_key> [-p <port>]"
exit 1
}
if [[ $# -eq 0 ]]; then
usage
fi
port=22
while [[ $# -gt 1 ]]; do
key=$1
case $key in
-h|--hostname)
host="$2"
shift
;;
-u|--username)
admin="$2"
shift
;;
-i|--identity)
private_key_file="$2"
shift
;;
-p|--port)
port="$2"
shift
;;
*)
usage
;;
esac
shift
done
# TODO verify that all required parameters are set
if [ ! -f ${private_key_file} ]; then
echo "SSH key ${private_key_file} not found, exiting..."
exit 2
fi
echo "Deploying StrongSwan on host $host port $port as admin $admin using key ${private_key_file}"
read -p "Proceed? [y/N]: " -r proceed
proceed=${proceed:-n}
if [[ "$proceed" =~ ^(y|Y)$ ]]; then
ansible-playbook deploy.yml -vv -i ${host}, --extra-vars "\
ansible_port=$port \
ansible_ssh_private_key_file=${private_key_file} \
ansible_user=$admin \
IP_subject_alt_name=$host"
else
echo "Nothing to do, exiting..."
fi