From 2b29ca61834e4135308401d8c792ecd34bc96564 Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Fri, 1 Mar 2013 16:41:45 -0800 Subject: [PATCH] Integrate os-refresh-config with heat-cfntools * Provide entry point for Heat Metadata to drive os-refresh-config * Use os-config-applier for configuring heat cfn tools Change-Id: Ie38b932173948f1e7c414c48caa1b037916bef84 --- .../element-deps | 2 +- .../os-config-applier/etc/cfn/cfn-hup.conf | 5 +++++ .../os-config-applier/etc/cfn/hooks.conf | 8 ++++++++ elements/os-refresh-config/README.md | 16 ++++++++++++++++ .../install.d/60-os-refresh-config-hup | 8 -------- .../os-refresh-config/install.d/cfn-hup.conf | 5 ----- elements/os-refresh-config/install.d/hooks.conf | 5 ----- 7 files changed, 30 insertions(+), 19 deletions(-) rename elements/{os-refresh-config => heat-cfntools}/element-deps (50%) create mode 100644 elements/heat-cfntools/os-config-applier/etc/cfn/cfn-hup.conf create mode 100644 elements/heat-cfntools/os-config-applier/etc/cfn/hooks.conf delete mode 100755 elements/os-refresh-config/install.d/60-os-refresh-config-hup delete mode 100644 elements/os-refresh-config/install.d/cfn-hup.conf delete mode 100644 elements/os-refresh-config/install.d/hooks.conf diff --git a/elements/os-refresh-config/element-deps b/elements/heat-cfntools/element-deps similarity index 50% rename from elements/os-refresh-config/element-deps rename to elements/heat-cfntools/element-deps index 5aee3bbb..e375b247 100644 --- a/elements/os-refresh-config/element-deps +++ b/elements/heat-cfntools/element-deps @@ -1,2 +1,2 @@ -heat-cfntools os-config-applier +os-refresh-config diff --git a/elements/heat-cfntools/os-config-applier/etc/cfn/cfn-hup.conf b/elements/heat-cfntools/os-config-applier/etc/cfn/cfn-hup.conf new file mode 100644 index 00000000..b923f1d5 --- /dev/null +++ b/elements/heat-cfntools/os-config-applier/etc/cfn/cfn-hup.conf @@ -0,0 +1,5 @@ +[main] +stack={{heat.stack.name}} +credential-file=/var/lib/cloud/data/cfn-credentials +region={{heat.stack.region}} +interval=10 diff --git a/elements/heat-cfntools/os-config-applier/etc/cfn/hooks.conf b/elements/heat-cfntools/os-config-applier/etc/cfn/hooks.conf new file mode 100644 index 00000000..cb50b08b --- /dev/null +++ b/elements/heat-cfntools/os-config-applier/etc/cfn/hooks.conf @@ -0,0 +1,8 @@ +{{#heat.refresh}} +[os-refresh-config-{{resource}}] +triggers=post.add,post.delete.post.update +path=Resources.{{resource}}.Metadata +action=os-refresh-config +runas=root + +{{/heat.refresh}} diff --git a/elements/os-refresh-config/README.md b/elements/os-refresh-config/README.md index 6122ad5e..be72c3db 100644 --- a/elements/os-refresh-config/README.md +++ b/elements/os-refresh-config/README.md @@ -14,3 +14,19 @@ it into one of the following directories: /opt/stack/os-refresh-config/migration.d /opt/stack/os-refresh-config/post-configure.d ``` + +If you want to have os-refresh-config run on any updates to a particular +Resource in the heat stack, you will need at the minimum the following snippet +of json in this instance's Metadata: + +{ + "OpenStack::Config": { + "heat": + "access_key_id": {"Ref": "ApiKeyResource"}, + "secret_key": {"Fn::GetAtt": [ "ApiKeyResource", "SecretAccessKey" ]}, + "refresh": [ {"resource": "SomeResource"} ], + "stack": {Ref: 'AWS::Stack'}, + "region": {Ref: 'AWS::Region'} + } + } +} diff --git a/elements/os-refresh-config/install.d/60-os-refresh-config-hup b/elements/os-refresh-config/install.d/60-os-refresh-config-hup deleted file mode 100755 index fb7c3eb5..00000000 --- a/elements/os-refresh-config/install.d/60-os-refresh-config-hup +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Note that this install.d script must be run after os-config-applier's -# install script so that we can make use of os-config-apply -set -eu -script_home=$(dirname $0) -template_home=$(os-config-applier --print-templates)/etc/cfn -install -o root -g root -m 0644 -D $script_home/cfn-hup.conf $template_home/cfn-hup.conf -install -o root -g root -m 0644 -D $script_home/hooks.conf $template_home/hooks.d/os-refresh-config.conf diff --git a/elements/os-refresh-config/install.d/cfn-hup.conf b/elements/os-refresh-config/install.d/cfn-hup.conf deleted file mode 100644 index 5db7d8a5..00000000 --- a/elements/os-refresh-config/install.d/cfn-hup.conf +++ /dev/null @@ -1,5 +0,0 @@ -[main] -stack={{OpenStack::Heat::Stack.Name}} -credential-file=/var/lib/cloud/data/cfn-credentials -region={{OpenStack::Heat::Stack.Region}} -interval=10 diff --git a/elements/os-refresh-config/install.d/hooks.conf b/elements/os-refresh-config/install.d/hooks.conf deleted file mode 100644 index 9f9290e6..00000000 --- a/elements/os-refresh-config/install.d/hooks.conf +++ /dev/null @@ -1,5 +0,0 @@ -[os-refresh-config] -triggers=post.add,post.delete.post.update -path=Resources.{{OpenStack::Heat::Stack.RefreshResource}}.Metadata -action=os-refresh-config -runas=root