Skip to content

Instantly share code, notes, and snippets.

@rubiojr
Created October 1, 2009 11:18
Show Gist options
  • Save rubiojr/198908 to your computer and use it in GitHub Desktop.
Save rubiojr/198908 to your computer and use it in GitHub Desktop.
// Match all nodes with FQDN ending in example.com
function(doc) {
if(doc.attributes.fqdn) {
var prefix = doc.attributes.fqdn.match(/^.*example.com$/);
if(prefix) {
emit(prefix, null);
}
}
}
// Match all nodes with virtualization role "host"
function(doc) {
if(doc.attributes.virtualization && doc.attributes.virtualization.role) {
if(doc.attributes.virtualization.role == 'host'){
emit(doc.attributes.fqdn, 'is a host');
}
}
}
// Find all nodes with run_list > 0 (i.e. with recipies, roles applied)
function(doc) {
if (doc.chef_type == "node") {
if (doc['run_list'].length > 0) {
emit(doc.name, doc['run_list']); }
}
}
// Find all nodes with run_list == 0 (i.e. with recipies, roles applied)
function(doc) {
if (doc.chef_type == "node") {
if (doc['run_list'].length == 0) {
emit(doc.name, doc['run_list']); }
}
}
// Find all RedHat Enterprise Linux 4 nodes
function(doc) {
if (doc.chef_type == "node") {
platform = doc.attributes.platform
pversion = doc.attributes.platform_version
if (platform == 'redhat' && pversion == '4') {
emit(doc.name, 'RHEL 4'); }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment