-
Notifications
You must be signed in to change notification settings - Fork 15
/
8_configure_followers.sh
executable file
·77 lines (51 loc) · 1.67 KB
/
8_configure_followers.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
#!/bin/bash
set -euo pipefail
. utils.sh
main() {
set_namespace $CONJUR_NAMESPACE_NAME
announce "Configuring followers."
if [[ "${DEPLOY_MASTER_CLUSTER}" = "true" ]]; then
seed_dir="tmp-$CONJUR_NAMESPACE_NAME"
prepare_follower_seed
fi
configure_followers
if [[ "${DEPLOY_MASTER_CLUSTER}" = "true" ]]; then
delete_follower_seed
fi
echo "Followers configured."
}
prepare_follower_seed() {
echo "Preparing follower seed files..."
master_pod_name=$(get_master_pod_name)
# Create dir w/ guid from namespace name for parallel CI execution
mkdir -p "$seed_dir"
FOLLOWER_SEED="./$seed_dir/follower-seed.tar"
$cli exec $master_pod_name -- evoke seed follower conjur-follower > $FOLLOWER_SEED
}
configure_followers() {
pod_list=$($cli get pods -l role=follower --no-headers | awk '{ print $1 }')
for pod_name in $pod_list; do
configure_follower $pod_name &
done
wait # for parallel configuration of followers
}
configure_follower() {
local pod_name=$1
KEYS_COMMAND=""
printf "Configuring follower %s...\n" $pod_name
copy_file_to_container $FOLLOWER_SEED "/tmp/follower-seed.tar" "$pod_name"
if [ -f "${CONJUR_DATA_KEY:-}" ]; then
copy_file_to_container $CONJUR_DATA_KEY "/opt/conjur/etc/conjur-data-key" "$pod_name"
KEYS_COMMAND="evoke keys exec -m /opt/conjur/etc/conjur-data-key --"
fi
echo "Unpacking seed..."
$cli exec $pod_name -- evoke unpack seed /tmp/follower-seed.tar
echo "Configuring follower with evoke..."
$cli exec $pod_name -- $KEYS_COMMAND evoke configure follower
set_conjur_pod_log_level $pod_name
}
delete_follower_seed() {
echo "Deleting follower seed..."
rm -rf $seed_dir
}
main $@