Newer
Older
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
#!/bin/bash
set -e
# Library of functions for the kayobe development environment.
# Configuration
function config_defaults {
# Set default values for kayobe development configuration.
# Try to detect if we are running in a vagrant VM.
if [[ -e /vagrant ]]; then
KAYOBE_SOURCE_PATH_DEFAULT=/vagrant
else
KAYOBE_SOURCE_PATH_DEFAULT=$(pwd)
fi
# Path to the kayobe source code repository. Typically this will be the
# Vagrant shared directory.
export KAYOBE_SOURCE_PATH=${KAYOBE_SOURCE_PATH:-$KAYOBE_SOURCE_PATH_DEFAULT}
# Path to the kayobe-config repository checkout.
export KAYOBE_CONFIG_SOURCE_PATH=${KAYOBE_CONFIG_SOURCE_PATH:-${KAYOBE_SOURCE_PATH}/config/src/kayobe-config}
# Path to the kayobe virtual environment.
export KAYOBE_VENV_PATH=${KAYOBE_VENV_PATH:-~/kayobe-venv}
# Whether to build container images for the seed services. If 0, they will
# be pulled.
export KAYOBE_SEED_CONTAINER_IMAGE_BUILD=${KAYOBE_SEED_CONTAINER_IMAGE_BUILD:-0}
# Whether to build container images for the overcloud services. If 0, they
# will be pulled.
export KAYOBE_OVERCLOUD_CONTAINER_IMAGE_BUILD=${KAYOBE_OVERCLOUD_CONTAINER_IMAGE_BUILD:-0}
}
function config_set {
# Source the configuration file, config.sh
PARENT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source ${PARENT}/config.sh
}
function config_check {
# Check the configuration environment variables.
if [[ ! -e $KAYOBE_CONFIG_SOURCE_PATH ]]; then
if [[ ${KAYOBE_CONFIG_REQUIRED:-1} -eq 1 ]]; then
echo "Kayobe configuration path $KAYOBE_CONFIG_SOURCE_PATH does not exist"
return 1
fi
fi
if [[ ! -e $KAYOBE_SOURCE_PATH ]]; then
echo "Kayobe source path $KAYOBE_SOURCE_PATH does not exist"
return 1
fi
}
function config_init {
config_defaults
config_set
config_check
}
# Installation
function install_dependencies {
echo "Installing package dependencies for kayobe"
if [[ -e /etc/centos-release ]]; then
sudo yum -y install gcc git vim python-virtualenv
else
sudo apt install -y python-dev python-virtualenv gcc git
fi
}
function install_venv {
local venv_parent=$(dirname ${KAYOBE_VENV_PATH})
if [[ ! -d $venv_parent ]]; then
mkdir -p $venv_parent
fi
if [[ ! -f ${KAYOBE_VENV_PATH}/bin/activate ]]; then
echo "Creating kayobe virtual environment in ${KAYOBE_VENV_PATH}"
virtualenv ${KAYOBE_VENV_PATH}
source ${KAYOBE_VENV_PATH}/bin/activate
pip install -U pip
pip install ${KAYOBE_SOURCE_PATH}
deactivate
else
echo "Using existing kayobe virtual environment in ${KAYOBE_VENV_PATH}"
fi
}
# Deployment
function is_deploy_image_built_locally {
ipa_build_images=$(kayobe configuration dump --host controllers[0] --var-name ipa_build_images)
[[ $ipa_build_images =~ ^true$ ]]
}
function environment_setup {
source ${KAYOBE_VENV_PATH}/bin/activate
source ${KAYOBE_CONFIG_SOURCE_PATH}/kayobe-env
cd ${KAYOBE_SOURCE_PATH}
}
function seed_hypervisor_deploy {
# Deploy a seed hypervisor.
environment_setup
echo "Bootstrapping the ansible control host"
kayobe control host bootstrap
echo "Configuring the seed hypervisor"
kayobe seed hypervisor host configure
}
function seed_deploy {
# Deploy a kayobe seed in a VM.
environment_setup
echo "Bootstrapping the ansible control host"
kayobe control host bootstrap
echo "Provisioning the seed VM"
kayobe seed vm provision
echo "Configuring the seed host"
kayobe seed host configure
# Note: This must currently be before host configure, because host
# configure runs kolla-ansible.yml, which validates the presence of the
# built deploy images.
if is_deploy_image_built_locally; then
echo "Building seed deployment images"
kayobe seed deployment image build
else
echo "Not building seed deployment images"
fi
if [[ ${KAYOBE_SEED_CONTAINER_IMAGE_BUILD} = 1 ]]; then
echo "Building seed container images"
kayobe seed container image build
else
echo "Not pulling seed container images - no such command yet"
#kayobe seed container image pull
fi
echo "Deploying containerised seed services"
kayobe seed service deploy
}
function overcloud_deploy {
# Deploy a kayobe control plane.
echo "Deploying a kayobe development environment. This consists of a "
echo "single node OpenStack control plane."
environment_setup
echo "Bootstrapping the ansible control host"
kayobe control host bootstrap
echo "Configuring the controller host"
kayobe overcloud host configure
# Note: This must currently be before host configure, because host
# configure runs kolla-ansible.yml, which validates the presence of the
# built deploy images.
if is_deploy_image_built_locally; then
echo "Building overcloud deployment images"
kayobe overcloud deployment image build
else
echo "Not building overcloud deployment images"
fi
if [[ ${KAYOBE_OVERCLOUD_CONTAINER_IMAGE_BUILD} = 1 ]]; then
echo "Building overcloud container images"
kayobe overcloud container image build
else
echo "Pulling overcloud container images"
kayobe overcloud container image pull
fi
echo "Deploying containerised overcloud services"
kayobe overcloud service deploy
echo "Performing post-deployment configuration"
source ${KOLLA_CONFIG_PATH:-/etc/kolla}/admin-openrc.sh
kayobe overcloud post configure
echo "Control plane deployment complete"
}