Add a bootstrap_host_exec CMD

Adds a simple command line utility that will exist in all TripleO
containers (we may need this in a variety of places) so that we
can quickly figure out whether a command should execute on the
bootstrap node (or not).

For example:
  ./bootstrap_host_exec heat_engine heat-manage db_sync

would only execute the DB sync for heat on the bootstrap node.
Internally the script uses hieradata to determine when to run the
supplied command.

Also, adds openstack-tripleo-common to the base container image so we
can use it in a variety of container images.

Related-Bug: #1688380
Change-Id: If25f217bbb592edab4e1dde53ca99ed93c0e146c
This commit is contained in:
Dan Prince 2017-05-09 09:00:07 -04:00
parent b571285b42
commit cdc5a35a7f
2 changed files with 24 additions and 8 deletions

View File

@ -5,17 +5,14 @@
{% set base_yum_url_packages_override = [] %}
{% set base_yum_repo_keys_override = [] %}
{% set base_centos_binary_packages_append = ['puppet'] %}
{% set nova_scheduler_packages_append = ['openstack-tripleo-common'] %}
# Required for mistral-db-populate to load tripleo custom actions on
# the undercloud
{% set mistral_api_packages_append = ['openstack-tripleo-common'] %}
{% set mistral_engine_packages_append = ['openstack-tripleo-common'] %}
# add tripleo-common to base packages for the bootstrap_host_exec command
# tripleo-common is also required by Nova scheduler (for tripleo filters)
# and Mistral for the Undercloud
{% set base_centos_binary_packages_append = ['puppet', 'openstack-tripleo-common'] %}
# NOTE: Mistral executor needs to run nova-manage cells_v2 commands on
# the undercloud baremetal workflows.
{% set mistral_executor_packages_append = ['openstack-tripleo-common', 'openstack-nova-common'] %}
{% set mistral_executor_packages_append = ['openstack-nova-common'] %}
# FIXME (kolla review to add ceilometer to swift proxy image)
{% set swift_proxy_server_packages_append = ['openstack-ceilometer-common'] %}

19
scripts/bootstrap_host_exec Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -e
SERVICE_NAME=$1
if [ -z "$SERVICE_NAME" ]; then
echo "Please supply a valid service name."
exit 1
fi
shift
if [ -z "$*" ]; then
echo "Please supply a valid 'command' to run as an argument."
exit 1
fi
HOSTNAME=$(/bin/hostname -s)
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${SERVICE_NAME}_short_bootstrap_node_name")
if [[ "$HOSTNAME" == "$SERVICE_NODEID" ]]; then
eval $*
else
echo "Skipping execution since this is not the bootstrap node for this service."
fi