Merge "Fix vagrant bootstrapping for ubuntu"
This commit is contained in:
commit
3f8bc07270
@ -40,7 +40,7 @@ function prep_work {
|
|||||||
# Install and configure a quick&dirty docker daemon.
|
# Install and configure a quick&dirty docker daemon.
|
||||||
function install_docker {
|
function install_docker {
|
||||||
# Allow for an externally supplied docker binary.
|
# Allow for an externally supplied docker binary.
|
||||||
if [ -f "/data/docker" ]; then
|
if [[ -f "/data/docker" ]]; then
|
||||||
cp /vagrant/docker /usr/bin/docker
|
cp /vagrant/docker /usr/bin/docker
|
||||||
chmod +x /usr/bin/docker
|
chmod +x /usr/bin/docker
|
||||||
else
|
else
|
||||||
@ -90,7 +90,7 @@ function configure_operator {
|
|||||||
pip install ~vagrant/kolla
|
pip install ~vagrant/kolla
|
||||||
|
|
||||||
# Note: this trickery requires a patched docker binary.
|
# Note: this trickery requires a patched docker binary.
|
||||||
if [ "$http_proxy" = "" ]; then
|
if [[ "$http_proxy" = "" ]]; then
|
||||||
su - vagrant sh -c "echo BUILDFLAGS=\\\"--build-env=http_proxy=$http_proxy --build-env=https_proxy=$https_proxy\\\" > ~/kolla/.buildconf"
|
su - vagrant sh -c "echo BUILDFLAGS=\\\"--build-env=http_proxy=$http_proxy --build-env=https_proxy=$https_proxy\\\" > ~/kolla/.buildconf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -136,7 +136,6 @@ EOF
|
|||||||
|
|
||||||
|
|
||||||
# Launch a local registry (and mirror) to speed up pulling images.
|
# Launch a local registry (and mirror) to speed up pulling images.
|
||||||
# 0.9.1 is actually the _latest_ tag.
|
|
||||||
if [[ ! $(docker ps -a -q -f name=registry) ]]; then
|
if [[ ! $(docker ps -a -q -f name=registry) ]]; then
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name registry \
|
--name registry \
|
||||||
@ -154,6 +153,6 @@ EOF
|
|||||||
prep_work
|
prep_work
|
||||||
install_docker
|
install_docker
|
||||||
|
|
||||||
if [ "$VM" = "operator" ]; then
|
if [[ "$VM" = "operator" ]]; then
|
||||||
configure_operator
|
configure_operator
|
||||||
fi
|
fi
|
||||||
|
@ -1,55 +1,116 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Bootstrap script to configure all nodes.
|
||||||
|
#
|
||||||
|
|
||||||
VM=$1
|
VM=$1
|
||||||
MODE=$2
|
MODE=$2
|
||||||
KOLLA_PATH=$3
|
KOLLA_PATH=$3
|
||||||
|
|
||||||
REGISTRY=operator.local
|
export http_proxy=
|
||||||
REGISTRY_PORT=4000
|
export https_proxy=
|
||||||
|
|
||||||
install_ansible() {
|
if [ "$MODE" = 'aio' ]; then
|
||||||
echo "Installing Ansible"
|
# Run registry on port 4000 since it may collide with keystone when doing AIO
|
||||||
apt-get install -y software-properties-common
|
REGISTRY_PORT=4000
|
||||||
apt-add-repository -y ppa:ansible/ansible
|
SUPPORT_NODE=operator
|
||||||
|
else
|
||||||
|
REGISTRY_PORT=5000
|
||||||
|
SUPPORT_NODE=support01
|
||||||
|
fi
|
||||||
|
REGISTRY=operator.local:${REGISTRY_PORT}
|
||||||
|
ADMIN_PROTOCOL="http"
|
||||||
|
|
||||||
|
# Install common packages and do some prepwork.
|
||||||
|
function prep_work {
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y ansible=1.9.4*
|
apt-get install -y python-mysqldb python-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt-dev
|
||||||
cat >/root/.ansible.cfg <<-EOF
|
apt-get clean
|
||||||
|
easy_install pip
|
||||||
|
pip install --upgrade docker-py
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install and configure a quick&dirty docker daemon.
|
||||||
|
function install_docker {
|
||||||
|
# Allow for an externally supplied docker binary.
|
||||||
|
if [[ -f "/data/docker" ]]; then
|
||||||
|
cp /vagrant/docker /usr/bin/docker
|
||||||
|
chmod +x /usr/bin/docker
|
||||||
|
else
|
||||||
|
apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
||||||
|
echo "deb https://apt.dockerproject.org/repo ubuntu-wily main" > /etc/apt/sources.list.d/docker.list
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y docker-engine
|
||||||
|
sed -i -r "s,(ExecStart)=(.+),\1=/usr/bin/docker daemon --insecure-registry ${REGISTRY} --registry-mirror=http://${REGISTRY}|" /lib/systemd/system/docker.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable docker
|
||||||
|
systemctl restart docker
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function configure_kolla {
|
||||||
|
# Use local docker registry
|
||||||
|
sed -i -r "s,^[# ]*namespace *=.+$,namespace = ${REGISTRY}/lokolla," /etc/kolla/kolla-build.conf
|
||||||
|
sed -i -r "s,^[# ]*push *=.+$,push = True," /etc/kolla/kolla-build.conf
|
||||||
|
sed -i -r "s,^[# ]*docker_registry:.+$,docker_registry: \"${REGISTRY}\"," /etc/kolla/globals.yml
|
||||||
|
sed -i -r "s,^[# ]*docker_namespace:.+$,docker_namespace: \"lokolla\"," /etc/kolla/globals.yml
|
||||||
|
sed -i -r "s,^[# ]*docker_insecure_registry:.+$,docker_insecure_registry: \"True\"," /etc/kolla/globals.yml
|
||||||
|
# Set network interfaces
|
||||||
|
sed -i -r "s,^[# ]*network_interface:.+$,network_interface: \"eth1\"," /etc/kolla/globals.yml
|
||||||
|
sed -i -r "s,^[# ]*neutron_external_interface:.+$,neutron_external_interface: \"eth2\"," /etc/kolla/globals.yml
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure the operator node and install some additional packages.
|
||||||
|
function configure_operator {
|
||||||
|
apt-get install -y git mariadb-client selinux-utils && apt-get clean
|
||||||
|
pip install --upgrade "ansible<2" python-openstackclient python-neutronclient tox
|
||||||
|
|
||||||
|
pip install ~vagrant/kolla
|
||||||
|
|
||||||
|
# Note: this trickery requires a patched docker binary.
|
||||||
|
if [[ "$http_proxy" = "" ]]; then
|
||||||
|
su - vagrant sh -c "echo BUILDFLAGS=\\\"--build-env=http_proxy=$http_proxy --build-env=https_proxy=$https_proxy\\\" > ~/kolla/.buildconf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -r ~vagrant/kolla/etc/kolla/ /etc/kolla
|
||||||
|
oslo-config-generator --config-file \
|
||||||
|
~vagrant/kolla/etc/oslo-config-generator/kolla-build.conf \
|
||||||
|
--output-file /etc/kolla/kolla-build.conf
|
||||||
|
mkdir -p /usr/share/kolla
|
||||||
|
chown -R vagrant: /etc/kolla /usr/share/kolla
|
||||||
|
|
||||||
|
configure_kolla
|
||||||
|
|
||||||
|
# Make sure Ansible uses scp.
|
||||||
|
cat > ~vagrant/.ansible.cfg <<EOF
|
||||||
[defaults]
|
[defaults]
|
||||||
forks=100
|
forks=100
|
||||||
|
|
||||||
[ssh_connection]
|
[ssh_connection]
|
||||||
scp_if_ssh=True
|
scp_if_ssh=True
|
||||||
EOF
|
EOF
|
||||||
}
|
chown vagrant: ~vagrant/.ansible.cfg
|
||||||
|
|
||||||
install_docker() {
|
# The openrc file.
|
||||||
echo "Installing Docker"
|
cat > ~vagrant/openrc <<EOF
|
||||||
apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
export OS_AUTH_URL="$(ADMIN_PROTOCOL)://${SUPPORT_NODE}:35357/v3"
|
||||||
echo "deb https://apt.dockerproject.org/repo ubuntu-vivid main" > /etc/apt/sources.list.d/docker.list
|
export OS_USERNAME=admin
|
||||||
apt-get update
|
export OS_PASSWORD=password
|
||||||
apt-get install -y docker-engine
|
export OS_TENANT_NAME=admin
|
||||||
sed -i -r "s,(ExecStart)=(.+),\1=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --insecure-registry ${REGISTRY}:${REGISTRY_PORT}," /lib/systemd/system/docker.service
|
export OS_VOLUME_API_VERSION=3
|
||||||
systemctl daemon-reload
|
export OS_USER_DOMAIN_ID=default
|
||||||
systemctl enable docker
|
EOF
|
||||||
systemctl restart docker
|
chown vagrant: ~vagrant/openrc
|
||||||
}
|
|
||||||
|
|
||||||
install_python_deps() {
|
mkdir -p /etc/kolla/config/nova/
|
||||||
echo "Installing Python"
|
cat > /etc/kolla/config/nova/nova-compute.conf <<EOF
|
||||||
# Python
|
[libvirt]
|
||||||
apt-get install -y python-setuptools python-dev libffi-dev libssl-dev
|
virt_type=qemu
|
||||||
easy_install pip
|
EOF
|
||||||
pip install --upgrade pip virtualenv virtualenvwrapper
|
|
||||||
}
|
|
||||||
|
|
||||||
install_ntp() {
|
|
||||||
echo "Installing NTP"
|
|
||||||
# NTP
|
|
||||||
apt-get install -y ntp
|
|
||||||
}
|
|
||||||
|
|
||||||
create_registry() {
|
# Launch a local registry (and mirror) to speed up pulling images.
|
||||||
echo "Creating Docker Registry"
|
if [[ ! $(docker ps -a -q -f name=registry) ]]; then
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name registry \
|
--name registry \
|
||||||
--restart=always \
|
--restart=always \
|
||||||
@ -58,15 +119,9 @@ create_registry() {
|
|||||||
-e MIRROR_SOURCE=https://registry-1.docker.io \
|
-e MIRROR_SOURCE=https://registry-1.docker.io \
|
||||||
-e MIRROR_SOURCE_INDEX=https://index.docker.io \
|
-e MIRROR_SOURCE_INDEX=https://index.docker.io \
|
||||||
-e STORAGE_PATH=/var/lib/registry \
|
-e STORAGE_PATH=/var/lib/registry \
|
||||||
-e GUNICORN_OPTS=[--preload] \
|
|
||||||
-e SEARCH_BACKEND=sqlalchemy \
|
|
||||||
-v /data/host/registry-storage:/var/lib/registry \
|
-v /data/host/registry-storage:/var/lib/registry \
|
||||||
registry:0.9.1
|
registry:2
|
||||||
}
|
fi
|
||||||
|
|
||||||
configure_kolla() {
|
|
||||||
echo "Configuring Kolla"
|
|
||||||
pip install -r ${KOLLA_PATH}/requirements.txt
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Kernel version $(uname -r)"
|
echo "Kernel version $(uname -r)"
|
||||||
@ -82,10 +137,9 @@ if [[ $(uname -r) != *"4.2"* ]]; then
|
|||||||
sleep 3
|
sleep 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install_ansible
|
prep_work
|
||||||
install_docker
|
install_docker
|
||||||
install_ntp
|
|
||||||
install_python_deps
|
|
||||||
create_registry
|
|
||||||
configure_kolla
|
|
||||||
|
|
||||||
|
if [[ "$VM" = "operator" ]]; then
|
||||||
|
configure_operator
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user