diff --git a/docker/centos/binary/heat/heat-api-cfn/Dockerfile b/docker/centos/binary/heat/heat-api-cfn/Dockerfile index 18a7e369d0..b26302a4f5 100644 --- a/docker/centos/binary/heat/heat-api-cfn/Dockerfile +++ b/docker/centos/binary/heat/heat-api-cfn/Dockerfile @@ -9,4 +9,6 @@ RUN yum -y install \ ADD ./start.sh /start.sh ADD ./check.sh /check.sh +COPY config-internal.sh config-external.sh /opt/kolla/ + CMD ["/start.sh"] diff --git a/docker/centos/binary/heat/heat-api-cfn/config-external.sh b/docker/centos/binary/heat/heat-api-cfn/config-external.sh new file mode 120000 index 0000000000..d1d0848001 --- /dev/null +++ b/docker/centos/binary/heat/heat-api-cfn/config-external.sh @@ -0,0 +1 @@ +../../../../common/heat/heat-api-cfn/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/heat/heat-api-cfn/config-internal.sh b/docker/centos/binary/heat/heat-api-cfn/config-internal.sh new file mode 120000 index 0000000000..280210245e --- /dev/null +++ b/docker/centos/binary/heat/heat-api-cfn/config-internal.sh @@ -0,0 +1 @@ +../../../../common/heat/heat-api-cfn/config-internal.sh \ No newline at end of file diff --git a/docker/centos/binary/heat/heat-api/Dockerfile b/docker/centos/binary/heat/heat-api/Dockerfile index 407aee601d..e7a4214dd2 100644 --- a/docker/centos/binary/heat/heat-api/Dockerfile +++ b/docker/centos/binary/heat/heat-api/Dockerfile @@ -11,4 +11,6 @@ RUN yum -y install \ ADD ./start.sh /start.sh ADD ./check.sh /check.sh +COPY config-internal.sh config-external.sh /opt/kolla/ + CMD ["/start.sh"] diff --git a/docker/centos/binary/heat/heat-api/config-external.sh b/docker/centos/binary/heat/heat-api/config-external.sh new file mode 120000 index 0000000000..bfc23ba354 --- /dev/null +++ b/docker/centos/binary/heat/heat-api/config-external.sh @@ -0,0 +1 @@ +../../../../common/heat/heat-api/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/heat/heat-api/config-internal.sh b/docker/centos/binary/heat/heat-api/config-internal.sh new file mode 120000 index 0000000000..e13addbc92 --- /dev/null +++ b/docker/centos/binary/heat/heat-api/config-internal.sh @@ -0,0 +1 @@ +../../../../common/heat/heat-api/config-internal.sh \ No newline at end of file diff --git a/docker/centos/binary/heat/heat-engine/Dockerfile b/docker/centos/binary/heat/heat-engine/Dockerfile index b97454e705..d22d1ae3ae 100644 --- a/docker/centos/binary/heat/heat-engine/Dockerfile +++ b/docker/centos/binary/heat/heat-engine/Dockerfile @@ -10,4 +10,7 @@ RUN yum -y install \ && yum clean all ADD ./start.sh /start.sh + +COPY config-internal.sh config-external.sh /opt/kolla/ + CMD ["/start.sh"] diff --git a/docker/centos/binary/heat/heat-engine/config-external.sh b/docker/centos/binary/heat/heat-engine/config-external.sh new file mode 120000 index 0000000000..a620c9e5ba --- /dev/null +++ b/docker/centos/binary/heat/heat-engine/config-external.sh @@ -0,0 +1 @@ +../../../../common/heat/heat-engine/config-external.sh \ No newline at end of file diff --git a/docker/centos/binary/heat/heat-engine/config-internal.sh b/docker/centos/binary/heat/heat-engine/config-internal.sh new file mode 120000 index 0000000000..b79835025c --- /dev/null +++ b/docker/centos/binary/heat/heat-engine/config-internal.sh @@ -0,0 +1 @@ +../../../../common/heat/heat-engine/config-internal.sh \ No newline at end of file diff --git a/docker/common/heat/heat-api-cfn/config-external.sh b/docker/common/heat/heat-api-cfn/config-external.sh new file mode 100755 index 0000000000..91d5742f19 --- /dev/null +++ b/docker/common/heat/heat-api-cfn/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/heat-api-cfn/heat.conf" +TARGET="/etc/heat/heat.conf" +OWNER="heat" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/heat/heat-api-cfn/config-internal.sh b/docker/common/heat/heat-api-cfn/config-internal.sh new file mode 100755 index 0000000000..bcd72250b4 --- /dev/null +++ b/docker/common/heat/heat-api-cfn/config-internal.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-heat.sh + +check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ + HEAT_CFN_KEYSTONE_USER HEAT_CFN_KEYSTONE_PASSWORD \ + KEYSTONE_AUTH_PROTOCOL KEYSTONE_ADMIN_SERVICE_PORT \ + ADMIN_TENANT_NAME HEAT_API_CFN_SERVICE_HOST \ + HEAT_API_CFN_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" + +crux user-create -n ${HEAT_CFN_KEYSTONE_USER} \ + -p ${HEAT_CFN_KEYSTONE_PASSWORD} \ + -t ${ADMIN_TENANT_NAME} \ + -r admin + +crux endpoint-create --remove-all -n ${HEAT_CFN_KEYSTONE_USER} -t cloudformation \ + -I "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_CFN_SERVICE_HOST}:${HEAT_API_CFN_SERVICE_PORT}/v1" \ + -P "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_CFN_SERVICE_HOST}:${HEAT_API_CFN_SERVICE_PORT}/v1" \ + -A "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_CFN_SERVICE_HOST}:${HEAT_API_CFN_SERVICE_PORT}/v1" + +exec /usr/bin/heat-api-cfn diff --git a/docker/common/heat/heat-api-cfn/start.sh b/docker/common/heat/heat-api-cfn/start.sh index bcd72250b4..716527c80e 100755 --- a/docker/common/heat/heat-api-cfn/start.sh +++ b/docker/common/heat/heat-api-cfn/start.sh @@ -1,28 +1,13 @@ #!/bin/bash -set -e +set -o errexit -. /opt/kolla/kolla-common.sh -. /opt/kolla/config-heat.sh +CMD="/usr/bin/heat-api-cfn" +ARGS="" -check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ - HEAT_CFN_KEYSTONE_USER HEAT_CFN_KEYSTONE_PASSWORD \ - KEYSTONE_AUTH_PROTOCOL KEYSTONE_ADMIN_SERVICE_PORT \ - ADMIN_TENANT_NAME HEAT_API_CFN_SERVICE_HOST \ - HEAT_API_CFN_SERVICE_PORT +# Loading common functions. +source /opt/kolla/kolla-common.sh -fail_unless_os_service_running keystone +# Config-internal script exec out of this function, it does not return here. +set_configs -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 ${HEAT_CFN_KEYSTONE_USER} \ - -p ${HEAT_CFN_KEYSTONE_PASSWORD} \ - -t ${ADMIN_TENANT_NAME} \ - -r admin - -crux endpoint-create --remove-all -n ${HEAT_CFN_KEYSTONE_USER} -t cloudformation \ - -I "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_CFN_SERVICE_HOST}:${HEAT_API_CFN_SERVICE_PORT}/v1" \ - -P "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_CFN_SERVICE_HOST}:${HEAT_API_CFN_SERVICE_PORT}/v1" \ - -A "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_CFN_SERVICE_HOST}:${HEAT_API_CFN_SERVICE_PORT}/v1" - -exec /usr/bin/heat-api-cfn +exec $CMD $ARGS diff --git a/docker/common/heat/heat-api/config-external.sh b/docker/common/heat/heat-api/config-external.sh new file mode 100755 index 0000000000..ca5d73e909 --- /dev/null +++ b/docker/common/heat/heat-api/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/heat-api/heat-api.conf" +TARGET="/etc/heat/heat-api.conf" +OWNER="heat" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/heat/heat-api/config-internal.sh b/docker/common/heat/heat-api/config-internal.sh new file mode 100755 index 0000000000..b57aaa710b --- /dev/null +++ b/docker/common/heat/heat-api/config-internal.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-heat.sh + +check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ + HEAT_KEYSTONE_USER HEAT_KEYSTONE_PASSWORD \ + KEYSTONE_AUTH_PROTOCOL ADMIN_TENANT_NAME \ + HEAT_API_SERVICE_HOST PUBLIC_IP + +fail_unless_os_service_running keystone + +export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}" +export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:35357/v2.0" +crux user-create -n ${HEAT_KEYSTONE_USER} \ + -p ${HEAT_KEYSTONE_PASSWORD} \ + -t ${ADMIN_TENANT_NAME} \ + -r admin + +crux endpoint-create --remove-all -n ${HEAT_KEYSTONE_USER} -t orchestration \ + -I "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_SERVICE_HOST}:8004/v1/%(tenant_id)s" \ + -P "${KEYSTONE_AUTH_PROTOCOL}://${PUBLIC_IP}:8004/v1/%(tenant_id)s" \ + -A "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_SERVICE_HOST}:8004/v1/%(tenant_id)s" + +# will use crux after https://github.com/larsks/crux/issues/1 is implemented +openstack role list --os-token="${KEYSTONE_ADMIN_TOKEN}" --os-url $SERVICE_ENDPOINT -f csv | tail -n +2 | awk -F, '{print $2}' | grep heat_stack_user || keystone role-create --name heat_stack_user + +exec /usr/bin/heat-api diff --git a/docker/common/heat/heat-api/start.sh b/docker/common/heat/heat-api/start.sh index b57aaa710b..6dd14d17e5 100755 --- a/docker/common/heat/heat-api/start.sh +++ b/docker/common/heat/heat-api/start.sh @@ -1,29 +1,13 @@ #!/bin/bash -set -e +set -o errexit -. /opt/kolla/kolla-common.sh -. /opt/kolla/config-heat.sh +CMD="/usr/bin/heat-api" +ARGS="" -check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ - HEAT_KEYSTONE_USER HEAT_KEYSTONE_PASSWORD \ - KEYSTONE_AUTH_PROTOCOL ADMIN_TENANT_NAME \ - HEAT_API_SERVICE_HOST PUBLIC_IP +# Loading common functions. +source /opt/kolla/kolla-common.sh -fail_unless_os_service_running keystone +# Config-internal script exec out of this function, it does not return here. +set_configs -export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}" -export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:35357/v2.0" -crux user-create -n ${HEAT_KEYSTONE_USER} \ - -p ${HEAT_KEYSTONE_PASSWORD} \ - -t ${ADMIN_TENANT_NAME} \ - -r admin - -crux endpoint-create --remove-all -n ${HEAT_KEYSTONE_USER} -t orchestration \ - -I "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_SERVICE_HOST}:8004/v1/%(tenant_id)s" \ - -P "${KEYSTONE_AUTH_PROTOCOL}://${PUBLIC_IP}:8004/v1/%(tenant_id)s" \ - -A "${KEYSTONE_AUTH_PROTOCOL}://${HEAT_API_SERVICE_HOST}:8004/v1/%(tenant_id)s" - -# will use crux after https://github.com/larsks/crux/issues/1 is implemented -openstack role list --os-token="${KEYSTONE_ADMIN_TOKEN}" --os-url $SERVICE_ENDPOINT -f csv | tail -n +2 | awk -F, '{print $2}' | grep heat_stack_user || keystone role-create --name heat_stack_user - -exec /usr/bin/heat-api +exec $CMD $ARGS diff --git a/docker/common/heat/heat-engine/config-external.sh b/docker/common/heat/heat-engine/config-external.sh new file mode 100755 index 0000000000..bde0ffe0de --- /dev/null +++ b/docker/common/heat/heat-engine/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/heat-engine/heat.conf" +TARGET="/etc/heat/heat.conf" +OWNER="heat" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/heat/heat-engine/config-internal.sh b/docker/common/heat/heat-engine/config-internal.sh new file mode 100755 index 0000000000..0cafbc480c --- /dev/null +++ b/docker/common/heat/heat-engine/config-internal.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-heat.sh +. /openrc + +check_required_vars HEAT_DB_NAME HEAT_DB_USER HEAT_DB_PASSWORD \ + INIT_HEAT_DB HEAT_DOMAIN_PASS +fail_unless_db + +if [ "${INIT_HEAT_DB}" == "true" ]; then + mysql -h ${MARIADB_SERVICE_HOST} -u root -p${DB_ROOT_PASSWORD} mysql <