Skip to content

Instantly share code, notes, and snippets.

@boundvariable
Created June 30, 2011 01:04
Show Gist options
  • Save boundvariable/1055418 to your computer and use it in GitHub Desktop.
Save boundvariable/1055418 to your computer and use it in GitHub Desktop.
Puppet node definitions via CouchDB
{
"_id": "a58af3e3e43733657152f59865021e0f",
"_rev": "28-c7d4a44d4c176886cf742ebec4876550",
"classes": [
"balancer"
],
"host": "example.com",
"directors": [
{
"name": "temp",
"backends": [
{
"name": "example",
"ip": ""
}
]
}
],
"ip": "192.168.0.99",
"stomp_server": "192.168.0.33",
"user": "system"
}
#!/usr/bin/env ruby
require 'rubygems'
require 'couchrest'
require 'yaml'
@db = CouchRest.database!("user:pass@your.couchdb.provider.com/nodes")
@db.view("list/all")['rows'].reject { | node | node['key']['host'] != ARGV[0] }.each do | node |
@classes = [] + node['key']['classes'].to_a
@node_definition = {
"classes" => @classes,
"environment" => "production",
"parameters" => node['key']
}
puts @node_definition.to_yaml
end
class balancer {
include varnish
include mcollective
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment