Provide an override level for os-apply-config

This allows elements to override the templates provided by other
elements using templates in post-os-apply-config. For example, the
logstash element provides a very basic logstash.conf. This change allows
another element to easily substitute a more useful version.

README.md has been rewritten as it was fairly sparse to begin with.

Change-Id: I14a103bf16554dc42b9c8ba1d4fefcacf6f07786
This commit is contained in:
Alexis Lee 2014-04-09 13:08:43 +01:00
parent 361e659e70
commit bf95d722f0
2 changed files with 30 additions and 12 deletions

View File

@ -1,6 +1,18 @@
Install os-apply-config.
os-apply-config
---------------
The contents of any os-config-applier or os-apply-config subdirectories in
templates will be installed into the default template directory automatically.
This element consists of two main parts, an install.d script to install
templates and an os-refresh-config script to invoke os-apply-config (thereby
applying the templates).
An os-refresh-config hook is created to invoke os-apply-config automatically.
The install.d script looks for directories named:
* os-config-applier - for back-compatibilty, lower precedence
* os-apply-config - the default choice
* post-os-apply-config - higher precedence
Files from these directories will be copied into a templates directory in the
target image, respecting structure.
The os-refresh-config script runs at level 50, if you are writing
os-refresh-config scripts for your own element which rely on templates having
been applied, ensure you use a higher level.

View File

@ -1,13 +1,19 @@
#!/bin/bash
# Note that this relies on the detail that all elements share one dir
# inside the chroot. This will copy all the files that elements have
# added to element/os-config-applier or element/os-apply-config into the
# appropriate location.
# This script will copy the templates to the appropriate location.
# Note that the implementation relies on the detail that all elements
# share one dir inside the chroot.
set -eux
set -o pipefail
TEMPLATE_ROOT=$(os-apply-config --print-templates)
TEMPLATE_SOURCE=$(dirname $0)/../os-config-applier
TEMPLATE_SOURCE_PREFIX=$(dirname $0)/..
mkdir -p $TEMPLATE_ROOT
[ -d $TEMPLATE_SOURCE ] && rsync --exclude='.*.swp' -Cr $TEMPLATE_SOURCE/ $TEMPLATE_ROOT/
TEMPLATE_SOURCE=$(dirname $0)/../os-apply-config
[ -d $TEMPLATE_SOURCE ] && rsync --exclude='.*.swp' -Cr $TEMPLATE_SOURCE/ $TEMPLATE_ROOT/
for BN in os-config-applier \
os-apply-config \
post-os-apply-config; do
TEMPLATE_SOURCE=${TEMPLATE_SOURCE_PREFIX}/${BN}
if [[ -d "${TEMPLATE_SOURCE}" ]]; then
rsync --exclude='.*.swp' -Cr $TEMPLATE_SOURCE/ $TEMPLATE_ROOT/
fi
done