NAME

NCM::hostsfile - NCM local hosts file configuration component.

SYNOPSIS

  • Configure()

    Updates the /etc/hosts file with the entries specified within the configuration. The entries in the configuration are keyed by the primary hostname. If an entry describes a hostname which is already in /etc/hosts (either as a primary hostname, or as an alias), then that host entry will be left alone (if takeover is false), or will be completely replaced by the entry specified in the configuration (if takeover is true).

    A comment # NCM is added to each line so that any deletions will also be cleaned up correctly.

    Returns error in case of a failure.

RESOURCES

  • /system/network/domainname

    When specifying hosts within the entries nlist, if a hostname is not FQDN and there are no aliases defined, then an alias will be automatically created using an FQDN formed by joining the shortname with this domain.

  • /software/components/hostsfile/file

    The filename to modify, defaults to /etc/hosts.

  • /software/components/hostsfile/entries

    An nlist, keyed by hostname. The value of each hostname is an nlist containing the following structure:

    • ipaddr

      The IP address of the host.

    • aliases

      A string value of aliases. Multiple aliases should be whitespace separated.

    • comment

      A comment to append to the line within /etc/hosts.

  • /software/components/hostsfile/takeover

    A boolean. If false (the default), then pre-existing host lines in the file which are not tagged with the "NCM" comment will be preserved. If takeover is true, then pre-existing entries for hosts will be taken over and declared to be under NCM control.

EXAMPLES

Example - configuration defined like this:

include 'software/components/hostsfile';
"/software/components/hostsfile/active" = true;
"/software/components/hostsfile/file" = "/etc/hosts.local";
"/software/components/hostsfile/entries" = nlist (
  "tsmstor601.cern.ch", nlist(
      "ipaddr", "192.168.1.101",
      "comment", "TSM DB disks"),
  "tsmstor602.cern.ch", nlist(
      "ipaddr", "192.168.1.102",
      "comment", "TSM Staging disks"),
  );

will modify the /etc/hosts.local file from:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
137.138.45.75           lxfsec1604.cern.ch

to:

# Generated by Quattor component hostsfile
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
137.138.45.75           lxfsec1604.cern.ch
192.168.1.101   tsmstor601.cern.ch tsmstor601 # NCM TSM DB disks
192.168.1.101   tsmstor602.cern.ch tsmstor602 # NCM TSM Staging disks

The syntax below is also possible:

"/software/components/hostsfile/entries/tsmstor603" = nlist(
    "ipaddr", "192.168.1.103",
    "comment", "TSM more disks"
);

or:

"/software/components/hostsfile/entries/tsmstor603/ipaddr" = "192.168.1.103";
"/software/components/hostsfile/entries/tsmstor603/comment" = "Testing";