Skip to content

Instantly share code, notes, and snippets.

@tzz
Created January 8, 2015 13:27
Show Gist options
  • Save tzz/5d33615a07243bf6448e to your computer and use it in GitHub Desktop.
Save tzz/5d33615a07243bf6448e to your computer and use it in GitHub Desktop.
bundle agent main
{
methods:
"" usebundle => servers;
"" usebundle => serverp("ubuntu-server");
"" usebundle => serverp("fellini");
}
bundle common servers
{
vars:
"regex[test]" string => ".*teste.*|.*server.*";
"regex[video]" string => "video\d-.*";
"types" slist => getindices("regex");
}
bundle agent serverp(name)
{
classes:
"server_$(servers.types)"
expression => regcmp("$(servers.regex[$(servers.types)])", $(name));
"server"
handle => "server_check",
expression => regcmp("$(servers.regex[$(servers.types)])", $(name));
"workstation" not => "server";
reports:
"$(name) is identified as server type: $(servers.types)"
ifvarclass => "server_$(servers.types)";
workstation::
"$(name) is a WORKSTATION";
server::
"$(name) is a SERVER";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment