Apply configuration from cloud metadata
Python Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Apply configuration from cloud metadata.

What does it do?

it turns a cloud-metadata file like this:

{"keystone": {"database": {"host": "", "user": "keystone", "password": "foobar"}}}

into service config files like this:

connection = mysql://keystone:foobar@
...other settings...


Just pass it the path to a directory tree of templates:

os-config-applier -t /home/me/my_templates


The template directory structure should mimic a root filesystem, and contain templates for only those files you want configured.


~/my_templates$ tree
└── etc
    ├── keystone
    │   └── keystone.conf
    └── mysql
        └── mysql.conf

An example tree can be found here.

If a template is executable it will be treated as an executable template. Otherwise, it will be treated as a mustache template.

Mustache Templates

If you don't need any logic, just some string substitution, use a mustache template.

Metadata settings are accessed with dot ('.') notation:

connection = mysql://{{keystone.database.user}}:{{keystone.database.password}@{{}}/keystone

Executable Templates

Configuration requiring logic is expressed in executable templates.

An executable template is a script which accepts configuration as a json string on standard in, and writes a config file to standard out.

The script should exit non-zero if it encounters a problem, so that os-config-applier knows what's up.

The output of the script will be written to the path corresponding to the executable template's path in the template tree.

#!/usr/bin/env ruby
require 'json'
params = JSON.parse
puts "connection = mysql://#{c['keystone']['database']['user']}:#{c['keystone']['database']['password']}@#{c['keystone']['database']['host']}/keystone"

You could even embed mustache in a heredoc, and use that:

#!/usr/bin/env ruby
require 'json'
require 'mustache'
params = JSON.parse

template = <<-eos
connection = mysql://{{keystone.database.user}}:{{keystone.database.password}}@{{}}/keystone


# tweak params here...

puts Mustache.render(template, params)

Quick Start

# install it
sudo pip install -U git+git://

# grab example templates
git clone git:// /tmp/config

# run it
os-config-applier -t /tmp/config/templates/ -m /tmp/config/cfn-init-data.example -o /tmp/config_output