File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # This script updates the ccdb host in all config files in all head nodes.
2+ # It is ad hoc and specific but it can easily be modified for similar purpose.
3+
4+ # set -x
5+
6+ HEAD_NODES=(
7+ # alio2-cr1-flp162
8+ # alio2-cr1-flp146
9+ # alio2-cr1-flp160
10+ # alio2-cr1-flp187
11+ # alio2-cr1-flp148
12+ # alio2-cr1-flp182
13+ # alio2-cr1-flp159
14+ # alio2-cr1-flp164
15+ # alio2-cr1-flp178
16+ # alio2-cr1-hv-head01
17+ # alio2-cr1-flp166
18+ # alio2-cr1-flp181
19+ # alio2-cr1-mvs01
20+ barth-test-cc7.cern.ch
21+ )
22+ echo " Number of nodes: ${# HEAD_NODES[@]} "
23+
24+ # Check that we have `jq`
25+ if ! command -v jq & > /dev/null
26+ then
27+ echo " jq could not be found, please install it."
28+ exit
29+ fi
30+
31+ # for each node
32+ for (( nodeIndex = 0 ; nodeIndex < ${# HEAD_NODES[@]} ; nodeIndex++ )) ; do
33+
34+ node=${HEAD_NODES[${nodeIndex}]}
35+ echo " node: $node "
36+ export CONSUL_HTTP_ADDR=${node} :8500
37+ echo $CONSUL_HTTP_ADDR
38+
39+ # Get the list of config files for qc
40+ list_files=$( curl -s ${node} :8500/v1/kv/o2/components/qc/ANY/any? keys=true | jq -c -r ' .[]' )
41+ IFS=$' \n ' read -rd ' ' -a array_files <<< " $list_files"
42+
43+ # for each file
44+ for file in " ${array_files[@]} " ; do
45+ echo " file: $file "
46+ # download
47+ consul kv get " $file " > /tmp/consul.json
48+ # modify
49+ new_content=$( cat /tmp/consul.json | jq ' .qc.config.database.host |= "alio2-cr1-hv-qcdb1:8083"' )
50+ # upload
51+ consul kv put " $file " " $new_content "
52+ done
53+ done
You can’t perform that action at this time.
0 commit comments