Update trymcp image
* add ability to specify gateway for Vm (DMZ case) via metadata;
* add missed copy for script adding default keycloak user;
Change-Id: If4e72c775031f23d67a01546c31c3e488ea516bd
Related-Prod: PROD-27660
diff --git a/trymcp-day01-image/files/etc/rc.local b/trymcp-day01-image/files/etc/rc.local
index 6b31cac..58c560c 100644
--- a/trymcp-day01-image/files/etc/rc.local
+++ b/trymcp-day01-image/files/etc/rc.local
@@ -11,9 +11,29 @@
#
# By default this script does nothing.
+update_from_metadata_fields() {
+ local metadataIp="169.254.169.254"
+ local metadataFiels=$(curl -s --connect-timeout 5 169.254.169.254/openstack/latest/meta_data.json | jq -r .meta)
+ if [ -n "${metadataFiels}" ]; then
+ local dmz=$(echo ${metadataFiels} | jq -r .dmz)
+ if [ "${dmz}" == "true" ]
+ local dmzGateway=$(echo ${metadataFiels} | jq -r .dmz_gateway)
+ if [ -n "${dmzGateway}" ]; then
+ local curDefault=$(ip r | grep 'default via' | cut -f 3 -d ' ')
+ if [ "${curDefault}" != "${dmzGateway}" ]; then
+ ip r del default
+ ip r add default via ${dmzGateway}
+ fi
+ fi
+ fi
+ fi
+}
+
if [ ! -f /tmp/bootstrap_interfaces ] && [ -d /srv/salt/reclass/nodes/_generated ]; then
sed -i "s/single_address:.*/single_address: $(hostname -I | cut -d ' ' -f 1)/g" /srv/salt/reclass/nodes/cfg01.*
touch /tmp/bootstrap_interfaces
fi
+update_from_metadata_fields || echo "Can't update settings from metadata fields"
+
exit 0
diff --git a/trymcp-day01-image/scripts/salt.sh b/trymcp-day01-image/scripts/salt.sh
index f2e7027..9ae4d09 100644
--- a/trymcp-day01-image/scripts/salt.sh
+++ b/trymcp-day01-image/scripts/salt.sh
@@ -27,6 +27,7 @@
docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/cicd/phpldapadmin:${MCP_VERSION}"
docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/model-generator/operations-api:${MCP_VERSION}"
docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/model-generator/operations-ui:${MCP_VERSION}"
+docker pull "docker-prod-local.artifactory.mirantis.com/mirantis/cicd/mysql:${MCP_VERSION}"
# Mirror images below into artifactory
docker pull jboss/keycloak:4.5.0.Final
docker pull jboss/keycloak-proxy:3.4.2.Final
diff --git a/trymcp-day01-image/template.json b/trymcp-day01-image/template.json
index 021c13f..0cee60b 100644
--- a/trymcp-day01-image/template.json
+++ b/trymcp-day01-image/template.json
@@ -30,6 +30,11 @@
"destination": "/opt/bootstrap.saltstack.com.sh"
},
{
+ "type": "file",
+ "source": "files/opt/add_keycloak_service_user.sh",
+ "destination": "/opt/add_keycloak_service_user.sh"
+ },
+ {
"environment_vars": [
"UBUNTU_BASEURL={{ user `ubuntu_baseurl` }}",
"PACKER_OFFLINE_BUILD=true"