-
Notifications
You must be signed in to change notification settings - Fork 3
/
jump.sh
executable file
·133 lines (115 loc) · 4.72 KB
/
jump.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
function run_lock {
set +e
run_item="${RUN_TASKS[$1]}"
file_part="${run_item}"
for part in $run_item; do
if [[ "$part" == *.yml ]];then
file_part="$part"
break
fi
done
if [ ! -d "/etc/openstack_deploy/upgrade-${TARGET_SERIES}" ]; then
mkdir -p "/etc/openstack_deploy/upgrade-${TARGET_SERIES}"
fi
upgrade_marker_file=$(basename ${file_part} .yml)
upgrade_marker="/etc/openstack_deploy/upgrade-${TARGET_SERIES}/$upgrade_marker_file.complete"
if [ ! -f "$upgrade_marker" ];then
eval "openstack-ansible $2"
playbook_status="$?"
echo "ran $run_item"
if [ "$playbook_status" == "0" ];then
RUN_TASKS=("${RUN_TASKS[@]/$run_item}")
touch "$upgrade_marker"
echo "$run_item has been marked as success"
else
echo "******************** failure ********************"
echo "The upgrade script has encountered a failure."
echo "Failed on task \"$run_item\""
echo "Re-run the run-upgrade.sh script, or"
echo "execute the remaining tasks manually:"
for item in $(seq $1 $((${#RUN_TASKS[@]} - 1))); do
if [ -n "${RUN_TASKS[$item]}" ]; then
echo "openstack-ansible ${RUN_TASKS[$item]}"
fi
done
echo "******************** failure ********************"
exit 99
fi
else
RUN_TASKS=("${RUN_TASKS[@]/$run_item.*}")
fi
set -e
}
function upgrade_database {
pushd /root/upgrades
RUN_TASKS=("/root/upgrades/pre-upgrade-backup.yml")
RUN_TASKS+=("/root/upgrades/prep-upgrade.yml")
RUN_TASKS+=("/root/upgrades/build-configs.yml")
RUN_TASKS+=("/root/upgrades/build-venvs.yml")
RUN_TASKS+=("/root/upgrades/shutdown-containers.yml")
RUN_TASKS+=("/root/upgrades/upgrade-database-ocata.yml")
RUN_TASKS+=("/root/upgrades/upgrade-database-pike.yml")
RUN_TASKS+=("/root/upgrades/upgrade-database-queens.yml")
RUN_TASKS+=("/root/upgrades/upgrade-database-rocky.yml")
RUN_TASKS+=("/root/upgrades/post-upgrade-backup.yml")
for item in ${!RUN_TASKS[@]}; do
run_lock $item "${RUN_TASKS[$item]}"
done
popd
}
function pre_flight {
upgrade_marker_file="bootstrap"
upgrade_marker="/etc/openstack_deploy/upgrade-${TARGET_SERIES}/$upgrade_marker_file.complete"
if [ ! -f "$upgrade_marker" ];then
openstack-ansible /root/upgrades/prep-jump.yml
if [ ! -d "/opt/openstack-ansible" ]; then
pushd /opt
git clone https://github.com/openstack/openstack-ansible
popd
fi
pushd /opt/openstack-ansible
git stash
git checkout master
git fetch && git fetch --tags
git checkout stable/rocky
git pull
sed -i -e 's|^neutron_vpnaas_git_install_branch:.*|neutron_vpnaas_git_install_branch: 13.0.0|g' \
/opt/openstack-ansible/playbooks/defaults/repo_packages/openstack_services.yml
sed -i -e 's|^dragonflow_git|#dragonflow_git|g' \
/opt/openstack-ansible/playbooks/defaults/repo_packages/openstack_services.yml \
/etc/ansible/roles/os_neutron/defaults/main.yml
sed -i -e 's|^octavia_dashboard_git_install_branch:.*|octavia_dashboard_git_install_branch: 2.0.1|g' \
/opt/openstack-ansible/playbooks/defaults/repo_packages/openstack_services.yml
echo "Waiting for containers to start up"
sleep 2m
/opt/openstack-ansible/scripts/bootstrap-ansible.sh
popd
touch "$upgrade_marker"
fi
}
function main {
pre_flight
pushd /opt/openstack-ansible
cp /opt/openstack-ansible/inventory/env.d/nova.yml /etc/openstack_deploy/env.d
RUN_TASKS=("/opt/openstack-ansible/scripts/upgrade-utilities/playbooks/user-secrets-adjustment.yml")
RUN_TASKS+=("/opt/openstack-ansible/playbooks/lxc-containers-destroy.yml -e force_containers_destroy=true -e force_containers_data_destroy=true")
RUN_TASKS+=("/root/upgrades/cleanup-for-bm.yml")
RUN_TASKS+=("/root/upgrades/cleanup-heat.yml")
RUN_TASKS+=("/root/upgrades/cleanup-ironic.yml")
RUN_TASKS+=("/root/upgrades/cleanup-nova.yml")
RUN_TASKS+=("/root/upgrades/deploy-config-changes.yml")
RUN_TASKS+=("/opt/openstack-ansible/playbooks/setup-hosts.yml -f 50 -l '!compute_all'")
RUN_TASKS+=("/root/upgrades/venv_install.yml")
RUN_TASKS+=("/opt/openstack-ansible/playbooks/setup-infrastructure.yml -f 50 -l '!compute_all'")
RUN_TASKS+=("/root/upgrades/install_db.yml")
RUN_TASKS+=("/opt/openstack-ansible/playbooks/setup-openstack.yml -f 50 -l '!compute_all'")
RUN_TASKS+=("/opt/openstack-ansible/playbooks/setup-everything.yml -f 50 -l 'compute_all'")
for item in ${!RUN_TASKS[@]}; do
run_lock $item "${RUN_TASKS[$item]}"
done
popd
}
TARGET_SERIES="rocky"
upgrade_database
main