Skip to content
Snippets Groups Projects
Commit 897337cd authored by Paul Bourke's avatar Paul Bourke
Browse files

Symlink all non Dockerfile resources in images

The only files in the docker image directories that differ majorly between
distros are the Dockerfiles (e.g. different package manager mechanisms,
different repo sources, etc).

The supporting files such as the start.sh/check.sh and config files should
largely stay the same between base images.

This change moves these files up into a "common" directory, and symlinks them
in the same way that the build script is managed. This means when adding a new
base distro only new Dockerfiles need to be created. Also, if a distro does
happen to require a vastly different start.sh script for example, one can
choose to simply not symlink to the common and instead drop in a custom one.

Implements: blueprint refactor-base-image-layout

Change-Id: Ic4db69d31ff54a1fb95af4853a2e5ae490064284
parent c2b05b57
No related branches found
No related tags found
No related merge requests found
Showing
with 20 additions and 574 deletions
#!/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
../../../common/barbican/start.sh
\ No newline at end of file
../../../common/kolla-common.sh ../../../common/base/kolla-common.sh
\ No newline at end of file \ No newline at end of file
../../../common/service_hosts.sh ../../../common/base/service_hosts.sh
\ No newline at end of file \ No newline at end of file
#!/bin/bash
set -e
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-ceilometer.sh
exec /usr/bin/ceilometer-alarm-evaluator &
exec /usr/bin/ceilometer-alarm-notifier
../../../../common/ceilometer/ceilometer-alarm/start.sh
\ No newline at end of file
#!/bin/bash
set -e
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-ceilometer.sh
check_required_vars CEILOMETER_DB_USER CEILOMETER_DB_NAME \
CEILOMETER_DB_PASSWORD KEYSTONE_ADMIN_TOKEN \
KEYSTONE_AUTH_PROTOCOL KEYSTONE_ADMIN_SERVICE_HOST \
KEYSTONE_ADMIN_SERVICE_PORT ADMIN_TENANT_NAME \
CEILOMETER_KEYSTONE_USER CEILOMETER_ADMIN_PASSWORD \
CEILOMETER_API_SERVICE_HOST PUBLIC_IP
fail_unless_os_service_running keystone
fail_unless_db
#TODO(pkilambi): Add mongodb support
mysql -h ${MARIADB_SERVICE_HOST} -u root -p${DB_ROOT_PASSWORD} mysql <<EOF
CREATE DATABASE IF NOT EXISTS ${CEILOMETER_DB_NAME} DEFAULT CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON ${CEILOMETER_DB_NAME}.* TO
'${CEILOMETER_DB_USER}'@'%' IDENTIFIED BY '${CEILOMETER_DB_PASSWORD}'
EOF
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0"
crux user-create -n ${CEILOMETER_KEYSTONE_USER} \
-p ${CEILOMETER_ADMIN_PASSWORD} \
-t ${ADMIN_TENANT_NAME} \
-r admin
crux service-create -n ${CEILOMETER_KEYSTONE_USER} -t metering \
-d "Ceilometer Telemetry Service"
crux endpoint-create i--remove-all -n ${CEILOMETER_KEYSTONE_USER} -t metering \
-I "${KEYSTONE_AUTH_PROTOCOL}://${CEILOMETER_API_SERVICE_HOST}:8777" \
-P "${KEYSTONE_AUTH_PROTOCOL}://${PUBLIC_IP}:8777" \
-A "${KEYSTONE_AUTH_PROTOCOL}://${CEILOMETER_API_SERVICE_HOST}:8777"
cfg=/etc/ceilometer/ceilometer.conf
crudini --set $cfg \
DEFAULT connection
"mysql://${CEILOMETER_DB_USER}:${CEILOMETER_DB_PASSWORD}@${MARIADB_SERVICE_HOST}/${CEILOMETER_DB_NAME}"
exec /usr/bin/ceilometer-api
../../../../common/ceilometer/ceilometer-api/start.sh
\ No newline at end of file
#!/bin/bash
set -e
. /opt/kolla/kolla-common.sh
: ${CEILOMETER_DB_USER:=ceilometer}
: ${CEILOMETER_DB_NAME:=ceilometer}
: ${KEYSTONE_AUTH_PROTOCOL:=http}
: ${CEILOMETER_KEYSTONE_USER:=admin}
: ${CEILOMETER_ADMIN_PASSWORD:=kolla}
: ${ADMIN_TENANT_NAME:=admin}
: ${METERING_SECRET:=ceilometer}
: ${RABBIT_PASSWORD:=guest}
check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \
KEYSTONE_ADMIN_SERVICE_PORT KEYSTONE_PUBLIC_SERVICE_HOST \
dump_vars
cat > /openrc <<EOF
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0"
EOF
cfg=/etc/ceilometer/ceilometer.conf
crudini --set $cfg \
DEFAULT rpc_backend rabbit
crudini --set $cfg \
DEFAULT rabbit_host ${RABBITMQ_SERVICE_HOST}
crudini --set $cfg \
DEFAULT rabbit_password ${RABBIT_PASSWORD}
crudini --set $cfg \
keystone_authtoken \
auth_uri \
"http://${KEYSTONE_PUBLIC_SERVICE_HOST}:5000/"
crudini --set $cfg \
keystone_authtoken \
admin_tenant_name \
"${ADMIN_TENANT_NAME}"
crudini --set $cfg \
keystone_authtoken \
admin_user \
"${CEILOMETER_KEYSTONE_USER}"
crudini --set $cfg \
keystone_authtoken \
admin_password \
${CEILOMETER_ADMIN_PASSWORD}
crudini --set $cfg \
service_credentials \
os_auth_url \
${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_PUBLIC_SERVICE_HOST}:5000/
crudini --set $cfg \
service_credentials \
os_username \
ceilometer
crudini --set $cfg \
service_credentials \
os_tenant_name \
service
crudini --set $cfg \
service_credentials \
os_password \
${CEILOMETER_ADMIN_PASSWORD}
crudini --set $cfg \
publisher
metering_secret
${METERING_SECRET}
../../../../common/ceilometer/ceilometer-base/config-ceilometer.sh
\ No newline at end of file
#!/bin/bash
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-ceilometer.sh
check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_AUTH_PROTOCOL \
KEYSTONE_ADMIN_SERVICE_HOST KEYSTONE_ADMIN_SERVICE_PORT
fail_unless_os_service_running keystone
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0"
exec /usr/bin/ceilometer-agent-central
../../../../common/ceilometer/ceilometer-central/start.sh
\ No newline at end of file
#!/bin/bash
set -e
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-ceilometer.sh
exec /usr/bin/ceilometer-collector
../../../../common/ceilometer/ceilometer-collector/start.sh
\ No newline at end of file
#!/bin/bash
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-ceilometer.sh
check_required_vars KEYSTONE_ADMIN_TOKEN RABBITMQ_SERVICE_HOST RABBIT_PASSWORD
fail_unless_os_service_running keystone
# Nova conf settings
crudini --set /etc/nova/nova.conf DEFAULT instance_usage_audit True
crudini --set /etc/nova/nova.conf DEFAULT instance_usage_audit_period hour
crudini --set /etc/nova/nova.conf DEFAULT notify_on_state_change vm_and_task_state
crudini --set /etc/nova/nova.conf DEFAULT notification_driver nova.openstack.common.notifier.rpc_notifier
crudini --set /etc/nova/nova.conf DEFAULT notification_driver ceilometer.compute.nova_notifier
#ceilometer settings
cfg=/etc/ceilometer/ceilometer.conf
crudini --set $cfg publisher_rpc metering_secret ${KEYSTONE_ADMIN_TOKEN}
crudini --set $cfg rabbit_host ${RABBITMQ_SERVICE_HOST}
crudini --set $cfg rabbit_password ${RABBIT_PASSWORD}
exec /usr/bin/ceilometer-agent-compute
../../../../common/ceilometer/ceilometer-compute/start.sh
\ No newline at end of file
#!/bin/bash
set -e
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-ceilometer.sh
exec /usr/bin/ceilometer-agent-notification
../../../../common/ceilometer/ceilometer-notification/start.sh
\ No newline at end of file
#!/bin/sh
RES=0
. /openrc
if ! keystone token-get > /dev/null; then
echo "ERROR: keystone token-get failed" >&2
RES=1
else
if ! cinder list > /dev/null; then
echo "ERROR: cinder list failed" >&2
RES=1
fi
fi
exit $RES
../../../../common/cinder-app/cinder-api/check.sh
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment