Skip to content

Instantly share code, notes, and snippets.

@lutter
lutter / server-microkernel.md
Last active Dec 25, 2015
Some thoughts on evolving the Server/Microkernel protocol
View server-microkernel.md

Today

The main point of interaction between server and microkernel is the /svc/checkin/:id endpoint. It currently expects that the Microkernel peridoically posts the following JSON to that URL:

{
  "facts": { ... facts hash ... }
}
View unbind_node.rb
command :unbind_node do |data|
data['name'] or error 400,
:error => "Supply 'name' to indicate which node to unbind"
if node = Razor::Data::Node.find_by_name(data['name'])
if node.policy
policy_name = node.policy.name
node.log_append(:event => :unbind, :policy => policy_name)
node.policy = nil
node.bound = false
node.save
View gist:9142098
diff --git a/app.rb b/app.rb
index ae74307..75f43f2 100644
--- a/app.rb
+++ b/app.rb
@@ -505,6 +505,21 @@ class Razor::App < Sinatra::Base
command :create_repo do |data|
check_permissions! "commands:create-repo:#{data['name']}"
+
+ unless data['name'].is_a? String
View view.yaml
nodes:
short:
layout: table
columns:
name:
dhcp_mac:
format: mac
tags:
format: tag_names
policy:
@lutter
lutter / README.md
Created Jun 25, 2014
Hook design document
View README.md

Hooks

Hooks provide a way to be notified of certain events during the operation of the Razor server; the behavior of a hook is defined by a hook type.

File layout for a hook type

Similar to brokers and tasks, hook types are defined through a .hook directory and files within that directory:

View script.sh
> gem install pe-razor-client
> export RAZOR_API=http://razor-server:8080/api
# Use any mirror listed here: http://isoredirect.centos.org/centos/6/isos/x86_64/
# This will take a while, since it will download the ISO and unpack it. The response
# will mention a command, which you can use to check the progress/errors of the
# download via 'razor commands NNN'
> razor create-repo --name centos-6.5 --task centos \
--iso-url http://mirror.anl.gov/pub/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso
# A tag that will match any machine
> razor create-tag --name any --rule '["=", 1, 1]'
@lutter
lutter / deps.pp
Created Sep 17, 2014
Collection-based dependencies
View deps.pp
define echo {
exec { "echo-$name":
command => "/usr/bin/echo $name"
}
}
Foo <| color == 'green' |> -> echo { "yo": } -> Foo <| color == 'red' |>
define foo($color) {
notice("foo[$name]: $color")
View nc-match-no-override.clj
(defn is-in-env?
"Return true if node N is in the desired environment according to the
subtree rooted at G. The following helpers are used:
(good? g) - true if g sets the environment to the desired one
(bad? g) - (not (good? g)) Note that this includes groups that do
not set the environment at all
(matches? n g) - true if the node N matches G's rule
(children g) - a list of G's child groups
Ignores environment trumps/override"
View pe-helpers.clj
(ns user
(:require [puppetlabs.http.client.sync :as http]
[clojure.java.io :as io]
[cheshire.core :as json]))
(def dir "/home/lutter/code/deployer/LOCAL/puppet-master/ssl")
(def config
{
:ssl-config
View lamp.pp
application lamp (
$parameter = 'default',
){
$names = [ 'one', 'two' 'three' ]
$names.each |name| {
site::apache { $name:
export => Http[$name],
}