Git Product home page Git Product logo

os-config-applier's Introduction

os-config-applier

Apply configuration from cloud metadata.

What does it do?

it turns a cloud-metadata file like this:

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

into service config files like this:

[sql]
connection = mysql://keystone:[email protected]/keystone
...other settings...

Usage

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

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

Templates

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

e.g.

~/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:

[sql]
connection = mysql://{{keystone.database.user}}:{{keystone.database.password}@{{keystone.database.host}}/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 STDIN.read
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 STDIN.read

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

[log]
...
eos

# tweak params here...

puts Mustache.render(template, params)

Quick Start

# install it
sudo pip install -U git+git://github.com/tripleo/os-config-applier.git

# grab example templates
git clone git://github.com/tripleo/openstack-config-templates /tmp/config

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

os-config-applier's People

Contributors

echohead avatar spamaps avatar rbtcollins avatar

Watchers

 avatar James Cloos avatar

Forkers

emonty

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.