-
Notifications
You must be signed in to change notification settings - Fork 4
/
vmconfig.sh
executable file
·75 lines (62 loc) · 1.78 KB
/
vmconfig.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# Wrapper for a couple of helpful ansible commands
# Available commands:
# deploy
# update
# help
OPTIND=1
BASE_CMD="ansible-playbook -u vagrant --private-key=provisioning/keys/vagrant -i vagrant_ansible_inventory_default"
PLAYBOOK="provisioning/deploy.yml"
VERBOSE=0
EXTRA_ARGS=""
deploy() {
echo 'Running deployment command ...'
while getopts "h?vr:" OPTION "$@"; do
case $OPTION in
h|\?)
help
exit 0
;;
v)
VERBOSE=1
BASE_CMD="$BASE_CMD -vvvv"
;;
r)
vars="--extra-vars 'rsync_source=$OPTARG' --extra-vars 'local_dir=`pwd`/'"
EXTRA_ARGS="$EXTRA_ARGS $vars"
PLAYBOOK="provisioning/local_deploy.yml"
;;
esac
done
CMD="$BASE_CMD $EXTRA_ARGS $PLAYBOOK"
if [[ $VERBOSE == 1 ]]; then
echo "Command: $CMD"
fi
chmod 600 provisioning/keys/vagrant
exec $CMD
}
update() {
echo 'Running update command ...'
CMD="$BASE_CMD provisioning/stage.yml"
chmod 600 provisioning/keys/vagrant
exec $CMD
}
help() {
echo 'This script provides convenience functions to update the Vagrant VM '
echo 'without logging into the machine.'
echo 'Additionally, when using the "deploy -r <local_directory>" option'
echo 'a local copy of the flyscript_portal can be used as the deployment source'
echo 'so you can perform all of your development in your local environment.'
echo ''
echo 'Available commands:'
echo ' deploy [-h] [-r <local_directory>]'
echo ' update'
echo ' -h/help'
}
if [[ $1 == "deploy" || $1 == "update" || $1 == "help" ]]; then
"$@"
else
echo "Invalid subcommand $1" >&2
help
exit 1
fi