forked from Azure/az-hop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·98 lines (88 loc) · 2.58 KB
/
install.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
TARGET=${1:-all}
set -e
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PLAYBOOKS_DIR=$THIS_DIR/playbooks
INVENTORY=$PLAYBOOKS_DIR/inventory
OOD_AUTH="basic"
function run_playbook ()
{
local playbook=$1
shift
local extra_vars_file=$@
# If running all playbooks and playbook marker doesn't exists, run the playbook
# If user requested specific playbook ignore marker file and force run
if [ ! -e $PLAYBOOKS_DIR/$playbook.ok ] || [ "$TARGET" != "all" ]; then
local options=""
if [ "$extra_vars_file" != "" ]; then
# Merge overrides variables in a single file
yq eval-all '. as $item ireduce ({}; . *+ $item)' $extra_vars_file > $PLAYBOOKS_DIR/extra_vars.yml
options+=" --extra-vars=@$PLAYBOOKS_DIR/extra_vars.yml"
fi
ansible-playbook -i $INVENTORY $PLAYBOOKS_DIR/$playbook.yml $options || exit 1
if [ -e $PLAYBOOKS_DIR/extra_vars.yml ]; then
rm $PLAYBOOKS_DIR/extra_vars.yml
fi
touch $PLAYBOOKS_DIR/$playbook.ok
else
echo "Skipping playbook $PLAYBOOKS_DIR/$playbook.yml as it has been successfully run "
fi
}
function get_scheduler ()
{
local scheduler
scheduler=$(yq eval '.queue_manager' config.yml)
if [ "$scheduler" == "null" ]; then
scheduler="openpbs"
fi
SCHEDULER=$scheduler
echo "Running on $SCHEDULER"
}
function get_ood_auth ()
{
local ood_auth
ood_auth=$(yq eval '.authentication.httpd_auth' config.yml)
if [ "$ood_auth" == "null" ]; then
ood_auth="basic"
fi
OOD_AUTH=$ood_auth
echo "Authentication is $OOD_AUTH"
}
# Apply pre-reqs
$THIS_DIR/ansible_prereqs.sh
# Check config syntax
yamllint config.yml
get_scheduler
get_ood_auth
case $TARGET in
all)
run_playbook ad
run_playbook linux
run_playbook add_users
run_playbook lustre-sas
run_playbook lustre
run_playbook ccportal
run_playbook cccluster
run_playbook scheduler
run_playbook ood $PLAYBOOKS_DIR/ood-overrides-common.yml $PLAYBOOKS_DIR/ood-overrides-$SCHEDULER.yml $PLAYBOOKS_DIR/ood-overrides-auth-$OOD_AUTH.yml
run_playbook ood-custom
run_playbook grafana
run_playbook telegraf
run_playbook chrony
;;
lustre)
run_playbook lustre-sas
run_playbook lustre
;;
ad | linux | add_users | ccportal | chrony | cccluster | scheduler | grafana | telegraf | ood-custom | winviz | remove_users | tests)
run_playbook $TARGET
;;
ood)
run_playbook ood $PLAYBOOKS_DIR/ood-overrides-common.yml $PLAYBOOKS_DIR/ood-overrides-$SCHEDULER.yml $PLAYBOOKS_DIR/ood-overrides-auth-$OOD_AUTH.yml
run_playbook ood-custom
;;
*)
echo "unknown target"
exit 1
;;
esac