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
|
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
submit_bug_report() {
cd ${XCI_PATH}
echo ""
echo "-------------------------------------------------------------------------"
echo "Oh nooooo! The XCI deployment failed miserably :-("
echo ""
echo "If you need help, please choose one of the following options"
echo "* #opnfv-pharos @ freenode network"
echo "* opnfv-tech-discuss mailing list (https://lists.opnfv.org/mailman/listinfo/opnfv-tech-discuss)"
echo " - Please prefix the subject with [XCI]"
echo "* https://jira.opnfv.org (Release Engineering project)"
echo ""
echo "Do not forget to submit the following information on your bug report:"
echo ""
git diff --quiet && echo "releng-xci tree status: clean" || echo "releng-xci tree status: local modifications"
echo "opnfv/releng-xci version: $(git rev-parse HEAD)"
echo "openstack/bifrost version: $OPENSTACK_BIFROST_VERSION"
echo "openstack/openstack-ansible version: $OPENSTACK_OSA_VERSION"
echo "xci flavor: $XCI_FLAVOR"
echo "xci installer: $XCI_INSTALLER"
echo "Environment variables:"
env | grep --color=never '\(OPNFV\|XCI\|OPENSTACK\)'
echo "-------------------------------------------------------------------------"
}
#-------------------------------------------------------------------------------
# This script should not be run as root
#-------------------------------------------------------------------------------
if [[ $(whoami) == "root" ]]; then
echo "WARNING: This script should not be run as root!"
echo "Elevated privileges are aquired automatically when necessary"
echo "Waiting 10s to give you a chance to stop the script (Ctrl-C)"
for x in $(seq 10 -1 1); do echo -n "$x..."; sleep 1; done
fi
#-------------------------------------------------------------------------------
# Set environment variables
#-------------------------------------------------------------------------------
# The order of sourcing the variable files is significant so please do not
# change it or things might stop working.
# - user-vars: variables that can be configured or overriden by user.
# - pinned-versions: versions to checkout. These can be overriden if you want to
# use different/more recent versions of the tools but you might end up using
# something that is not verified by OPNFV XCI.
# - flavor-vars: settings for VM nodes for the chosen flavor.
# - env-vars: variables for the xci itself and you should not need to change or
# override any of them.
#-------------------------------------------------------------------------------
# find where are we
export XCI_PATH="$(git rev-parse --show-toplevel)"
# source user vars
source $XCI_PATH/xci/config/user-vars
# source pinned versions
source $XCI_PATH/xci/config/pinned-versions
# source flavor configuration
source "$XCI_PATH/xci/config/${XCI_FLAVOR}-vars"
# source installer configuration
source "$XCI_PATH/xci/installer/${XCI_INSTALLER}/env" &>/dev/null || true
# source xci configuration
source $XCI_PATH/xci/config/env-vars
if [[ -z $(echo $PATH | grep "$HOME/.local/bin") ]]; then
export PATH="$HOME/.local/bin:$PATH"
fi
#-------------------------------------------------------------------------------
# Sanitize local development environment variables
#-------------------------------------------------------------------------------
user_local_dev_vars=(OPENSTACK_OSA_DEV_PATH OPENSTACK_BIFROST_DEV_PATH)
for local_user_var in ${user_local_dev_vars[@]}; do
[[ -n ${!local_user_var:-} ]] && export $local_user_var=${!local_user_var%/}/
done
unset user_local_dev_vars local_user_var
# register our handler
trap submit_bug_report ERR
#-------------------------------------------------------------------------------
# Log info to console
#-------------------------------------------------------------------------------
echo "Info: Starting XCI Deployment"
echo "Info: Deployment parameters"
echo "-------------------------------------------------------------------------"
echo "xci flavor: $XCI_FLAVOR"
echo "xci installer: $XCI_INSTALLER"
echo "opnfv/releng-xci version: $(git rev-parse HEAD)"
echo "openstack/bifrost version: $OPENSTACK_BIFROST_VERSION"
echo "openstack/openstack-ansible version: $OPENSTACK_OSA_VERSION"
echo "OPNFV scenario: $DEPLOY_SCENARIO"
echo "-------------------------------------------------------------------------"
#-------------------------------------------------------------------------------
# Install ansible on localhost
#-------------------------------------------------------------------------------
echo "Info: Installing Ansible from pip"
echo "-------------------------------------------------------------------------"
bash files/install-ansible.sh
echo "-------------------------------------------------------------------------"
case ${XCI_DISTRO,,} in
# These should ideally match the CI jobs
ubuntu)
export DIB_OS_RELEASE="${DIB_OS_RELEASE:-xenial}"
export DIB_OS_ELEMENT="${DIB_OS_ELEMENT:-ubuntu-minimal}"
export DIB_OS_PACKAGES="${DIB_OS_PACKAGES:-vlan,vim,less,bridge-utils,language-pack-en,iputils-ping,rsyslog,curl,iptables}"
;;
centos)
export DIB_OS_RELEASE="${DIB_OS_RELEASE:-7}"
export DIB_OS_ELEMENT="${DIB_OS_ELEMENT:-centos-minimal}"
export DIB_OS_PACKAGES="${DIB_OS_PACKAGES:-vim,less,bridge-utils,iputils,rsyslog,curl,iptables}"
;;
opensuse)
export DIB_OS_RELEASE="${DIB_OS_RELEASE:-42.3}"
export DIB_OS_ELEMENT="${DIB_OS_ELEMENT:-opensuse-minimal}"
export DIB_OS_PACKAGES="${DIB_OS_PACKAGES:-vim,less,bridge-utils,iputils,rsyslog,curl,iptables}"
;;
esac
if [[ ${XCI_DISTRO,,} == centos ]]; then
echo ""
echo "Warning: Only Ubuntu and SUSE hosts are fully supported for now!"
echo "Warning: CentOS 7 support is still work in progress."
echo
fi
# Clone OPNFV scenario repositories
#-------------------------------------------------------------------------------
# This playbook
# - removes existing scenario roles
# - clones OPNFV scenario roles based on the xci/opnfv-scenario-requirements.yml file
#-------------------------------------------------------------------------------
echo "Info: Cloning OPNFV scenario repositories"
echo "-------------------------------------------------------------------------"
cd $XCI_PATH/xci/playbooks
ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -i inventory get-opnfv-scenario-requirements.yml
echo "-------------------------------------------------------------------------"
#-------------------------------------------------------------------------------
# Get scenario variables overrides
#-------------------------------------------------------------------------------
if [[ -f $XCI_SCENARIOS_CACHE/${DEPLOY_SCENARIO:-_no_scenario_}/xci_overrides ]]; then
source $XCI_SCENARIOS_CACHE/$DEPLOY_SCENARIO/xci_overrides
fi
#-------------------------------------------------------------------------------
# Start provisioning VM nodes
#-------------------------------------------------------------------------------
# This playbook
# - removes directories that were created by the previous xci run
# - clones opnfv/releng-xci and openstack/bifrost repositories
# - combines opnfv/releng-xci and openstack/bifrost scripts/playbooks
# - destroys VMs, removes ironic db, leases, logs
# - creates and provisions VMs for the chosen flavor
#-------------------------------------------------------------------------------
echo "Info: Starting provisining VM nodes using openstack/bifrost"
echo "-------------------------------------------------------------------------"
# We are using sudo so we need to make sure that env_reset is not present
sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers
cd $XCI_PATH/bifrost/
sudo -E bash ./scripts/destroy-env.sh
cd $XCI_PLAYBOOKS
ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -i inventory provision-vm-nodes.yml
cd ${XCI_CACHE}/repos/bifrost
bash ./scripts/bifrost-provision.sh
echo "-----------------------------------------------------------------------"
echo "Info: VM nodes are provisioned!"
echo "-----------------------------------------------------------------------"
# Deploy OpenStack on the selected installer
echo "Info: Deploying '${XCI_INSTALLER}' installer"
echo "-----------------------------------------------------------------------"
source ${XCI_PATH}/xci/installer/${XCI_INSTALLER}/deploy.sh
# vim: set ts=4 sw=4 expandtab:
|