Skip to content

Instantly share code, notes, and snippets.

@nickanderson
Created March 5, 2012 21:31
Show Gist options
  • Save nickanderson/1981225 to your computer and use it in GitHub Desktop.
Save nickanderson/1981225 to your computer and use it in GitHub Desktop.
body common control {
bundlesequence => {
"main",
};
inputs => {
"cfengine_stdlib.cf",
};
}
bundle agent main {
methods:
"any" usebundle => rh_set_hostname("node1", "domain.com");
}
bundle agent rh_set_hostname(hostname, domainname){
# Expects desired shorthostname and domain name both as strings;
# Usage:
# vars:
# "hostname" string => "jim";
# "domain" string => "bob.com";
#
# methods:
# "hostname" usebundle => rh_set_hostname("$(hostname)", "$(domain)");
#
files:
"/tmp/network"
edit_line => replace_or_add("HOSTNAME=.*", "HOSTNAME=$(hostname)"),
classes => if_repaired("update_running_hostname"),
comment => "Redhat docs are WRONG, if you set this to fqdn it
will cause the hostname command to return the fqdn
instead of the shorthostname";
"/tmp/network"
edit_line => replace_or_add("NISDOMAIN=.*", "NISDOMAIN=$(domainname)"),
classes => if_repaired("update_running_hostname"),
comment => "Set the domainname";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment