forked from SUSE-Cloud/socok8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·181 lines (166 loc) · 5.42 KB
/
run.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
set -o errexit
usage() {
echo "deploy -- Deploy SUSE Containerized OpenStack."
echo "update_openstack -- Update OpenStack deployment."
echo "test -- Deploy and run OpenStack Tempest tests."
echo "add_openstack_compute -- Add OpenStack compute node. Add compute node host(s) in inventory file."
echo "remove_openstack_compute <compute-node-name> -- Remove OpenStack compute node. Provide compute node host name with option."
echo "remove_deployment -- Delete all resources related with deployment including images."
}
if [ -z "${1:-}" ]; then
echo "$0 -h, --help -- Show help message."
exit 1
fi
scripts_absolute_dir="$( cd "$(dirname "$0")/script_library" ; pwd -P )"
socok8s_absolute_dir="$( cd "$(dirname "$0")" ; pwd -P )"
deployment_action=$1
while true ; do
case "$deployment_action" in
-h|--help) usage ; exit 0 ;;
*) source ${scripts_absolute_dir}/pre-flight-checks.sh "validate_cli_options $1"
break ;;
esac
done
if [[ "${SOCOK8S_DEVELOPER_MODE:-False}" == "True" ]]; then
set -x
SOCOK8S_USE_VIRTUALENV=${SOCOK8S_USE_VIRTUALENV:-True}
fi
# USE an env var to setup where to deploy to
# by default, ccp will deploy on openstack for inception style fun (and CI).
DEPLOYMENT_MECHANISM=${DEPLOYMENT_MECHANISM:-"kvm"}
# The base directory where workspace(s) are created in
SOCOK8S_WORKSPACE_BASEDIR=${SOCOK8S_WORKSPACE_BASEDIR:-~}
# The path to the terraform binary
TERRAFORM_BINARY_PATH=${TERRAFORM_BINARY_PATH:-/usr/bin/terraform}
source ${scripts_absolute_dir}/pre-flight-checks.sh check_common_env_vars_set
source ${scripts_absolute_dir}/bootstrap-ansible-if-necessary.sh
source ${scripts_absolute_dir}/pre-flight-checks.sh check_jq_present
source ${scripts_absolute_dir}/pre-flight-checks.sh check_ansible_requirements
source ${scripts_absolute_dir}/pre-flight-checks.sh check_git_submodules_are_present
# Bring an ansible runner that allows a userspace environment
source ${scripts_absolute_dir}/run-ansible.sh
pushd ${socok8s_absolute_dir}
# All the deployment actions (deploy steps) are defined in script_library/actions-openstack.sh for example.
# For simplificity, the following script contains each action for a deploy mechanism, and each action should
# contain a "master" playbook, which should be named playbooks/${DEPLOYMENT_MECHANISM}-${deployment_action}
source ${scripts_absolute_dir}/deployment-actions-${DEPLOYMENT_MECHANISM}.sh
case "$deployment_action" in
"deploy_network")
deploy_network
;;
"deploy_ses")
deploy_ses
;;
"deploy_caasp")
# this is CaaSP 3
deploy_caasp
;;
"deploy_caasp4")
# this is CaaSP 4
deploy_caasp4
;;
"deploy_ccp_deployer")
# CCP deployer is a node that will be used to control k8s cluster,
# as we shouldn't do it on caasp cluster (microOS and others)
deploy_ccp_deployer
;;
"configure_ccp_deployer")
configure_ccp_deployer
;;
"enroll_caasp_workers")
enroll_caasp_workers
;;
"patch_upstream")
patch_upstream
;;
"build_images")
build_images
;;
"deploy_osh")
deploy_osh
;;
"add_openstack_compute")
add_compute
;;
"remove_openstack_compute")
if [ -z ${2+x} ];then
echo "Please enter compute node host name"
exit 1
fi
read -r -p "WARNING: Please remove all VM(s) from the compute host. Are you sure to continue? [y/n] " user_input
if [[ $user_input == "y" ]]; then
remove_compute $2
else
exit 0
fi
;;
"setup_caasp_workers_for_openstack")
setup_caasp_workers_for_openstack
;;
"setup_hosts")
deploy_network
deploy_ses
deploy_caasp
deploy_ccp_deployer
configure_ccp_deployer
enroll_caasp_workers
;;
"setup_openstack")
setup_caasp_workers_for_openstack
patch_upstream
build_images
deploy_osh
;;
"setup_airship")
setup_caasp_workers_for_openstack
deploy_airship
;;
"deploy")
deploy_airship
;;
"update_openstack")
deploy_airship update_airship_osh_site
;;
"setup_everything")
deploy_network
deploy_ses
deploy_caasp
deploy_ccp_deployer
configure_ccp_deployer
enroll_caasp_workers
setup_caasp_workers_for_openstack
patch_upstream
build_images
deploy_osh
;;
"teardown")
teardown
;;
"clean_caasp4")
clean_caasp4
;;
"clean_k8s")
clean_k8s
;;
"clean_airship_not_images")
clean_airship clean_openstack_clean_ucp_clean_rest
;;
"remove_deployment")
read -r -p "WARNING: Please remove all VM(s) from all compute host(s). This deletes everything that is deployed. Are you sure to continue? [y/n] " user_input
if [[ $user_input == "y" ]]; then
clean_airship
else
exit 0
fi
;;
"gather_logs")
gather_logs
;;
"test")
deploy_tempest
;;
*)
echo "Invalid option, Check --help for valid options"
;;
esac