-
Notifications
You must be signed in to change notification settings - Fork 14
/
run
executable file
·323 lines (278 loc) · 11.7 KB
/
run
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#!/usr/bin/env bash
# Copyright 2015, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -xeuo pipefail
source scripts/scripts-libs.sh
echo "Gate job started"
echo "+-------------------- START ENV VARS --------------------+"
env
echo "+-------------------- START ENV VARS --------------------+"
export RE_JOB_SCENARIO=${RE_JOB_SCENARIO:-"functional"}
export RPCO_VERSION="${RE_JOB_SCENARIO%_mimic}"
export RPCO_VERSION="${RPCO_VERSION#rpco_}"
export RPCO_DIR=${RPCO_DIR:-/opt/rpc-openstack}
export RPC_MAAS_DIR=${RPC_MAAS_DIR:-/etc/ansible/ceph_roles/rpc-maas}
export TEST_RPC_MAAS=${TEST_RPC_MAAS:-False}
export CEPH_BOOTSTRAP_OPTS=${CEPH_BOOTSTRAP_OPTS:-""}
export DATA_DISK_MIN_SIZE_GB=${DATA_DISK_MIN_SIZE_GB:-50}
# For Queens and older use the queens branch of openstack-ansible-tests
if [[ "${RE_JOB_SCENARIO}" =~ ^rpco_[q-z] ]]; then
export OSA_TEST_VERSION=$RPCO_VERSION
else
export OSA_TEST_VERSION="queens"
fi
LINT_COMMAND="/opt/rpc-ceph_ansible-runtime/bin/ansible-lint"
# Do not lint these playbooks because they come directly from upstream ceph-ansible
LINT_WHITELIST='deploy-ceph.yml|rolling_update.yml|osd-configure.yml|purge-cluster.yml|deploy.yml'
# Install python2 for Ubuntu 16.04 and CentOS 7
if which apt-get; then
sudo apt-get update && sudo apt-get install -y python
if [[ "$(lsb_release -cs)" == "xenial" ]]; then
# Workaround for this until it gets released upstream:
# https://github.com/openstack/openstack-ansible-lxc_hosts/commit/f63abfa921b2c69e202b068fe631b48adbb9ad64
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes
fi
fi
if which yum; then
sudo yum install -y python
fi
# Install pip.
if ! which pip; then
curl --silent --show-error --retry 5 \
https://bootstrap.pypa.io/get-pip.py | sudo python2.7
fi
# Add syslog user if one doesn't exist. The haproxy_server role assumes
# on Ubuntu that a syslog user exists and fails if there is not one.
# Our RE Ubuntu images do not have a syslog user.
if ! id -u syslog ; then
apt-get install -y rsyslog
fi
# Install bindep and tox with pip.
sudo pip install bindep tox
# CentOS 7 requires two additional packages:
# redhat-lsb-core - for bindep profile support
# epel-release - required to install python-ndg_httpsclient/python2-pyasn1
if which yum; then
sudo yum -y install redhat-lsb-core epel-release
fi
function _set_rpco_vars {
## Copy over the keystone_auth_admin_password from OSA --> Ceph
if ! grep -q keystone_auth_admin_password ${CLONE_DIR}/tests/test-vars-openstack.yml; then
grep keystone_auth_admin_password ${SECRETS_FILE} >> ${CLONE_DIR}/tests/test-vars-openstack.yml
fi
## Add the rsyslog_container into the inventory
if ! grep -q rsyslog_container ${CLONE_DIR}/tests/inventory_rpco; then
RSYSLOG_HOST=$(lxc-ls -f | grep rsyslog_container | awk {'print $1'})
RSYSLOG_HOST_IP=$(grep $RSYSLOG_HOST /etc/hosts | awk {' print $1 '})
echo -e "\n[rsyslog_all]\n$RSYSLOG_HOST ansible_host=$RSYSLOG_HOST_IP" >> ${CLONE_DIR}/tests/inventory_rpco
fi
# Generate Cinder Ceph Client UUID
CINDER_CEPH_CLIENT_UUID=$(uuidgen)
echo "cinder_ceph_client_uuid: $CINDER_CEPH_CLIENT_UUID" >> /etc/openstack_deploy/user_rpc_ceph_vars.yml
}
function _configure_rpco {
export CINDER_ENVD="inventory/env.d/cinder.yml"
export SECRETS_FILE="/etc/openstack_deploy/user_secrets.yml"
export OSA_DIR="/opt/openstack-ansible"
if [ "${RE_JOB_SCENARIO}" = "rpco_newton" ]; then
export OSA_DIR="${RPCO_DIR}/openstack-ansible"
export SECRETS_FILE="/etc/openstack_deploy/user_osa_secrets.yml"
elif [ "${RE_JOB_SCENARIO}" != "rpco_pike" ]; then
## For Queens onwards (e.g. not Pike or Newton) the inventory dir has moved
export CINDER_ENVD="../inventory/env.d/cinder.yml"
fi
if [[ ! -d /opt/rpc-openstack ]]; then
git clone https://github.com/rcbops/rpc-openstack -b ${RPCO_VERSION} --recursive ${RPCO_DIR}
fi
pushd ${RPCO_DIR}
# Install required packages for the integrated build.
apt-get install -y parted iptables util-linux uuid-runtime
## Dont use the specified Ceph inventory
unset ANSIBLE_INVENTORY
## Set the RPC_ARTIFACT_MODE vars
export RPC_APT_ARTIFACT_ENABLED=no
export RPC_APT_ARTIFACT_MODE=loose
## Use the openstack-ansible binary
export ANSIBLE_BINARY="openstack-ansible"
## Bootstrap RPC-O's ansible
if [ "${RE_JOB_SCENARIO}" = "rpco_newton" ]; then
bash scripts/bootstrap-ansible.sh
cp ${CLONE_DIR}/tests/rpco_vars/user_rpc_ceph_vars.yml /etc/openstack_deploy/user_rpc_ceph_vars.yml
bash scripts/bootstrap-aio.sh
else
bash scripts/deploy.sh
pushd ${OSA_DIR}
export BOOTSTRAP_OPTS="@/etc/openstack_deploy/user_rpc_ceph_vars.yml ${CEPH_BOOTSTRAP_OPTS}"
bash scripts/bootstrap-ansible.sh
cp ${CLONE_DIR}/tests/rpco_vars/user_rpc_ceph_vars.yml /etc/openstack_deploy/user_rpc_ceph_vars.yml
bash scripts/bootstrap-aio.sh
popd
fi
## Build out the hosts, infrastructure and keystone only.
pushd ${OSA_DIR}/playbooks
cp ${CLONE_DIR}/tests/rpco_vars/cinder.yml.ceph /etc/openstack_deploy/conf.d/cinder.yml
cp ${CINDER_ENVD} /etc/openstack_deploy/env.d/cinder.yml
sed -i 's/is_metal: true/is_metal: false/g' /etc/openstack_deploy/env.d/cinder.yml
${ANSIBLE_BINARY} setup-hosts.yml
${ANSIBLE_BINARY} setup-infrastructure.yml
${ANSIBLE_BINARY} os-keystone-install.yml
popd
popd
## Set the binary and inventory back to ceph's version.
export ANSIBLE_BINARY="ceph-ansible-playbook"
export ANSIBLE_INVENTORY="${CLONE_DIR}/tests/inventory_rpco"
export CEPH_BOOTSTRAP_OPTS="-e @tests/test-vars-openstack.yml ${CEPH_BOOTSTRAP_OPTS}"
}
function _deploy_rpco {
unset ANSIBLE_INVENTORY
export ANSIBLE_BINARY="openstack-ansible"
pushd ${OSA_DIR}/playbooks
${ANSIBLE_BINARY} os-glance-install.yml
${ANSIBLE_BINARY} os-cinder-install.yml
${ANSIBLE_BINARY} os-nova-install.yml
${ANSIBLE_BINARY} os-neutron-install.yml
${ANSIBLE_BINARY} os-tempest-install.yml
popd
}
function _get_data_disk {
# Get minimum disk size
DATA_DISK_MIN_SIZE="$((1024**3 * ${DATA_DISK_MIN_SIZE_GB} ))"
# Determine the largest secondary disk device that meets the minimum size
DATA_DISK_DEVICE=$(lsblk -brndo NAME,TYPE,RO,SIZE | awk '/d[b-z]+ disk 0/{ if ($4>m && $4>='$DATA_DISK_MIN_SIZE'){m=$4; d=$1}}; END{print d}')
# Only set the secondary disk device option if there is one
if [ -n "${DATA_DISK_DEVICE}" ]; then
export CEPH_BOOTSTRAP_OPTS="-e bootstrap_host_data_disk_device=${DATA_DISK_DEVICE} ${CEPH_BOOTSTRAP_OPTS}"
fi
}
function _download_dependent_components {
# Install python3 for Ubuntu 16.04 and CentOS 7
if which apt-get; then
sudo apt-get install -y python3-virtualenv
virtualenv --python python3 --no-pip --no-setuptools --no-wheel .rpc_component_venv
fi
if which yum; then
sudo yum install -y python34-virtualenv.noarch
virtualenv-3 --no-pip --no-setuptools --no-wheel .rpc_component_venv
fi
get_pip .rpc_component_venv/bin/python
# NOTE(mattt): We use a subshell here to unset PYTHONPATH only for the
# duration of the subshell itself. When rpc-maas's tox runs, it
# forces a PYTHONPATH to tox's virtualenv, which breaks our
# ability to use the python3 venv below.
(
unset PYTHONPATH
.rpc_component_venv/bin/pip3 install "git+https://github.com/rcbops/rpc_component@85f152ece9eee3c9cd7d68bd2ecc5982e17400ae#egg=rpc_component"
.rpc_component_venv/bin/component dependency download-requirements --download-dir /etc/ansible/ceph_roles/
)
}
function _test_ansible_lint {
set +e
retv=0
for playbook in $(find ./playbooks -type f -regex '.*\.y[a]?ml' -print \
| egrep -v "/(${LINT_WHITELIST})$"); do
${LINT_COMMAND} --exclude=/etc $playbook
retv=$(($retv + $?))
done
exit $retv
}
function _test_build_releasenotes {
pip install sphinx reno oslosphinx
sphinx-build -a -E -W -d releasenotes/build/doctrees \
-b html releasenotes/source releasenotes/build/html
exit
}
function _test_build_docs {
DEBIAN_FRONTEND=noninteractive sudo apt -y install docker.io make
cd ${CLONE_DIR}/docs
make docs
exit
}
export CLONE_DIR="$(pwd)"
export ANSIBLE_INVENTORY="${CLONE_DIR}/tests/inventory"
export ANSIBLE_PARAMETERS="-e @${CLONE_DIR}/tests/test-vars.yml -e @${RPC_MAAS_DIR}/tests/user_rpcm_secrets.yml"
export ANSIBLE_BINARY="${ANSIBLE_BINARY:-ceph-ansible-playbook}"
bash scripts/bootstrap-ansible.sh
_download_dependent_components
if [ "${RE_JOB_SCENARIO}" = "ansible_lint" ]; then
_test_ansible_lint
fi
if [ "${RE_JOB_SCENARIO}" = "build_releasenotes" ]; then
_test_build_releasenotes
fi
if [ "${RE_JOB_SCENARIO}" = "build_docs" ]; then
_test_build_docs
fi
if [ "${RE_JOB_SCENARIO}" != "rpco_newton" ]; then
_get_data_disk
fi
# Clone the test repos when not integrating with RPC-O
# RPC-O has existing lxc roles that will conflict
if [[ "${RE_JOB_SCENARIO}" =~ ^rpco_ ]]; then
_configure_rpco
_set_rpco_vars
else
ROLE_FILE="../tests/ansible-role-test-requirements.yml"
if [[ $(lsb_release -cs || true) = "bionic" ]]; then
ROLE_FILE="../tests/ansible-role-test-requirements-bionic.yml"
fi
${ANSIBLE_BINARY} playbooks/git-clone-repos.yml \
-i ${ANSIBLE_INVENTORY} \
-e role_file=${ROLE_FILE}
fi
## Set the inventory and include the additional overrides vars file
if [[ "${RE_JOB_SCENARIO}" =~ ^keystone_rgw ]]; then
export ANSIBLE_INVENTORY="${CLONE_DIR}/tests/inventory_rgw"
export CEPH_BOOTSTRAP_OPTS="-e @tests/test-vars-rgw.yml ${CEPH_BOOTSTRAP_OPTS}"
fi
if [[ "${RE_JOB_SCENARIO}" =~ ^bluestore ]]; then
export CEPH_BOOTSTRAP_OPTS="-e @tests/test-vars-bluestore.yml ${CEPH_BOOTSTRAP_OPTS}"
fi
if [[ ! -d tests/common ]]; then
git clone https://github.com/openstack/openstack-ansible-tests -b stable/${OSA_TEST_VERSION} tests/common
fi
# Set variavles needed to deploy ceph mimic for _mimic$ scenarios
if [[ "${RE_JOB_SCENARIO}" =~ _mimic$ ]]; then
export CEPH_BOOTSTRAP_OPTS="-e @tests/test-vars-mimic.yml ${CEPH_BOOTSTRAP_OPTS}"
fi
# Install Ceph AIO across LXC containers
${ANSIBLE_BINARY} tests/setup-ceph-aio.yml \
-i ${ANSIBLE_INVENTORY} \
-e @tests/test-vars.yml ${CEPH_BOOTSTRAP_OPTS}
# Validate Ceph AIO install
${ANSIBLE_BINARY} tests/test-ceph-aio.yml \
-i ${ANSIBLE_INVENTORY} \
-e @tests/test-vars.yml ${CEPH_BOOTSTRAP_OPTS}
if [[ "${RE_JOB_SCENARIO}" =~ ^rpco_ ]]; then
_deploy_rpco
fi
# Use the rpc-maas deploy to test MaaS
if [ "${TEST_RPC_MAAS}" != "False" ]; then
if [[ "${RE_JOB_SCENARIO}" =~ ^rpco_ ]]; then
bash maas-ceph-rpco.sh
fi
if [ "${RE_JOB_SCENARIO}" =~ ^functional ]; then
pushd ${RPC_MAAS_DIR}
export RE_JOB_SCENARIO="ceph"
## This is needed for the maas job to be able to update the apt cache
## When the influxdb repo is present.
apt-get install -y apt-transport-https
bash tests/test-ansible-functional.sh
popd
## Test purge-cluster
${ANSIBLE_BINARY} playbooks/purge-cluster.yml \
-i ${ANSIBLE_INVENTORY} \
-e @tests/test-vars.yml ${CEPH_BOOTSTRAP_OPTS} \
-e ireallymeanit=yes
fi
fi