aboutsummaryrefslogtreecommitdiff
path: root/docker/centos/binary/barbican
diff options
context:
space:
mode:
authorSam Yaple <sam@yaple.net>2015-05-13 06:46:24 -0500
committerSam Yaple <sam@yaple.net>2015-05-15 01:32:22 -0500
commit13062e23e86b5d86020949754540460cb5b0b4fe (patch)
treee0b3c8411418949a3d8df221da7c8cb2831b6d5d /docker/centos/binary/barbican
parent354ba01c8f5c7e1695cbea3bfc07aee5b75e76d9 (diff)
downloadkolla-13062e23e86b5d86020949754540460cb5b0b4fe.tar.gz
kolla-13062e23e86b5d86020949754540460cb5b0b4fe.zip
Restructure builds to allow more flexibility
As a restructure, nothing is changed from the original behaviour and naming despite the file structure changing. The symlinks to build had to be updated generating lots of "deleted" and "new_file". The new structure is: docker/${base_distro}/${type}/${container} base_distro == centos, ubuntu, fedora, etc type == source, binary, rdo type rdo is a symlink to binary for backwards compatibility Two new flags are added to the build-all script to support the ability to support different base distros and a flag to support binary or source containers. There are several added folders that are empty to hold the directory structure for future containers of these types. To use a prefix other than centos-rdo- you can set PREFIX in the toplevel directory .buildconf file Change-Id: Ifc7bac0d827470f506c8b5c004a833da9ce13b90
Diffstat (limited to 'docker/centos/binary/barbican')
-rw-r--r--docker/centos/binary/barbican/Dockerfile40
l---------docker/centos/binary/barbican/build1
-rwxr-xr-xdocker/centos/binary/barbican/start.sh81
3 files changed, 122 insertions, 0 deletions
diff --git a/docker/centos/binary/barbican/Dockerfile b/docker/centos/binary/barbican/Dockerfile
new file mode 100644
index 000000000..0a124dc38
--- /dev/null
+++ b/docker/centos/binary/barbican/Dockerfile
@@ -0,0 +1,40 @@
+FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%base:%%KOLLA_TAG%%
+MAINTAINER Kolla Project (https://launchpad.net/kolla)
+
+ADD ./start.sh /start.sh
+
+# Install required packages
+# NOTE: these packages (tar especially) can be pruned once converted to
+# installation via RPM: https://bugs.launchpad.net/kolla/+bug/1453926
+RUN yum install -y gcc Cython sqlite-devel mysql-devel libffi-devel tar && yum clean all
+
+# use the Barbican Juno version
+# setting this as environment variable also keeps pbr version checking happy
+# TODO: when the Barbican rpm from cloudkeep.io is usable,
+# switch to using that instead
+ENV PBR_VERSION 2014.2
+
+# Get and extract the Barbican tar ball
+RUN curl -o /barbican-$PBR_VERSION.tar.gz https://github.com/openstack/barbican/archive/$PBR_VERSION.tar.gz -L
+RUN tar -xzf barbican-$PBR_VERSION.tar.gz
+
+# Install Barbican requirements
+RUN pip install -r barbican-$PBR_VERSION/requirements.txt
+RUN pip install MySQL-python
+
+# Install Barbican
+RUN cd barbican-$PBR_VERSION && python setup.py install
+
+# Configure Barbican
+RUN mkdir -p /etc/barbican
+RUN mkdir -p /var/log/barbican
+RUN cp -r /barbican-$PBR_VERSION/etc/barbican/* /etc/barbican
+
+# Instal uwsgi as that is what we will use to run Barbican
+RUN pip install uwsgi
+
+# Cleanup files not required anymore
+RUN rm -rf /barbican-$PBR_VERSION
+RUN rm -rf /barbican-$PBR_VERSION.tar.gz
+
+CMD ["/start.sh"]
diff --git a/docker/centos/binary/barbican/build b/docker/centos/binary/barbican/build
new file mode 120000
index 000000000..8d652f7ee
--- /dev/null
+++ b/docker/centos/binary/barbican/build
@@ -0,0 +1 @@
+../../../../tools/build-docker-image \ No newline at end of file
diff --git a/docker/centos/binary/barbican/start.sh b/docker/centos/binary/barbican/start.sh
new file mode 100755
index 000000000..673aa4339
--- /dev/null
+++ b/docker/centos/binary/barbican/start.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+
+set -e
+
+: ${BARBICAN_DB_USER:=barbican}
+: ${BARBICAN_DB_NAME:=barbican}
+: ${KEYSTONE_AUTH_PROTOCOL:=http}
+: ${BARBICAN_KEYSTONE_USER:=barbican}
+: ${ADMIN_TENANT_NAME:=admin}
+
+if ! [ "$BARBICAN_DB_PASSWORD" ]; then
+ BARBICAN_DB_PASSWORD=$(openssl rand -hex 15)
+ export BARBICAN_DB_PASSWORD
+fi
+
+check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \
+ KEYSTONE_ADMIN_SERVICE_PORT BARBICAN_ADMIN_PASSWORD
+fail_unless_db
+fail_unless_os_service_running keystone
+
+mysql -h ${MARIADB_SERVICE_HOST} -u root -p"${DB_ROOT_PASSWORD}" mysql <<EOF
+CREATE DATABASE IF NOT EXISTS ${BARBICAN_DB_NAME};
+GRANT ALL PRIVILEGES ON barbican.* TO
+ '${BARBICAN_DB_USER}'@'%' IDENTIFIED BY '${BARBICAN_DB_PASSWORD}'
+EOF
+
+# config file setup
+crudini --set /etc/barbican/barbican-api.conf \
+ DEFAULT \
+ sql_connection \
+ "mysql://${BARBICAN_DB_USER}:${BARBICAN_DB_PASSWORD}@${MARIADB_SERVICE_HOST}/${BARBICAN_DB_NAME}"
+crudini --set /etc/barbican/barbican-api.conf \
+ DEFAULT \
+ log_dir \
+ "/var/log/barbican/"
+crudini --set /etc/barbican/barbican-api.conf \
+ DEFAULT \
+ log_file \
+ "/var/log/barbican/barbican.log"
+crudini --set /etc/barbican/barbican-api-paste.ini \
+ pipeline:barbican_api \
+ pipeline \
+ "keystone_authtoken context apiapp"
+crudini --set /etc/barbican/barbican-api-paste.ini \
+ filter:keystone_authtoken \
+ auth_host \
+ ${KEYSTONE_ADMIN_SERVICE_HOST}
+crudini --set /etc/barbican/barbican-api-paste.ini \
+ filter:keystone_authtoken \
+ auth_port \
+ ${KEYSTONE_ADMIN_SERVICE_PORT}
+crudini --set /etc/barbican/barbican-api-paste.ini \
+ filter:keystone_authtoken \
+ auth_protocol \
+ ${KEYSTONE_AUTH_PROTOCOL}
+crudini --set /etc/barbican/barbican-api-paste.ini \
+ filter:keystone_authtoken \
+ admin_tenant_name \
+ ${ADMIN_TENANT_NAME}
+crudini --set /etc/barbican/barbican-api-paste.ini \
+ filter:keystone_authtoken \
+ admin_user \
+ ${BARBICAN_KEYSTONE_USER}
+crudini --set /etc/barbican/barbican-api-paste.ini \
+ filter:keystone_authtoken \
+ admin_password \
+ ${BARBICAN_KEYSTONE_USER}
+
+# create the required keystone entities for barbican
+export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
+export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0"
+
+keystone user-get ${BARBICAN_KEYSTONE_USER} > /dev/null 2>&1 || /bin/keystone user-create --name ${BARBICAN_KEYSTONE_USER} --pass ${BARBICAN_ADMIN_PASSWORD}
+
+keystone role-get observer > /dev/null 2>&1 || /bin/keystone role-create --name observer
+keystone role-get creator > /dev/null 2>&1 || /bin/keystone role-create --name creator
+
+keystone user-get ${BARBICAN_KEYSTONE_USER} > /dev/null 2>&1 || /bin/keystone user-role-add --user ${BARBICAN_KEYSTONE_USER} --role admin --tenant ${ADMIN_TENANT_NAME}
+
+# launch Barbican using uwsgi
+exec uwsgi --master --emperor /etc/barbican/vassals