puppetlabs/Razor — pull request #437 by calebcase (2013-03-26 23:35:26+00:00)
Title: Script Broker

A simple broker that executes a script on the node. This provides a
lightweight broker with no external service dependencies. It is suitable
for one-time configuration post os install, but also flexible enough to
setup more complicated long term solutions (e.g. local puppet apply).

Features:

* Optionally send auxillary data along with the script.
* Sends the metadata along with the script.
* Fully configurable where the files land on the node.

Interface:

The script will be called with one parameter: The path to the metadata file.
The metadata file contains all the node metadata (including tags) and the
configuration of the script broker (including the paths to local resources). It
is JSON 'pretty' formatted and should be amiable to parsing.

Example:

On the Razor Server:

# cat /root/hello_world.sh
#!/bin/bash
set -e
set -u

echo "Hello World!"
echo "Metadata Path: $1"

# razor broker
Broker Targets:
Name => hello_world
Description => Hello
Plugin => script
UUID => 4kp0o3tchb5NW5pdcV6pRf
Script => /root/hello_world.sh
Script Path => /tmp/razor_script
Data =>
Data Path => /tmp/razor_script_data
Metadata Path => /tmp/razor_script_metadata
Log Path => /tmp/razor_script.log

On the Node after the script broker has run:

# cd /tmp
# ls
razor_complete.log razor_script razor_script.log razor_script_metadata
# cat razor_script.log
Hello World!
Metadata Path: /tmp/razor_script_metadata
# cat /tmp/razor_script_metadata
{
"username": "root",
"password": "electric",
"metadata": {
"razor_tags": "ubuntu-precise,cpus_16,virtualbox_vm,OracleCorporation,nics_1,memsize_1015MiB",
"razor_node_uuid": "49jbMtCv4gn0BLphWfmJ8p",
"razor_active_model_uuid": "4IfYuiaCQ1fY9D1mQUZ0Vr",
"razor_model_uuid": "60WqyDfq9yF3HSSpLWutpf",
"razor_model_name": "ubuntu_precise",
"razor_model_description": "Ubuntu Precise Model",
"razor_model_template": "linux_deploy",
"razor_policy_count": "27"
},
"uuid": "49jbMtCv4gn0BLphWfmJ8p",
"ipaddress": "10.0.1.123",
"script": "/vagrant/echo_script.sh",
"script_path": "/tmp/razor_script",
"data": "",
"data_path": "/tmp/razor_script_data",
"metadata_path": "/tmp/razor_script_metadata",
"log_path": "/tmp/razor_script.log"
}