NCM::hostsfile - NCM local hosts file configuration component.
/etc/hostsfile 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).
### NCMis added to each line so that any deletions will also be cleaned up correctly.
Returns error in case of a failure.
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.
The filename to modify, defaults to
An nlist, keyed by hostname. The value of each hostname is an nlist containing the following structure:
The IP address of the host.
A string value of aliases. Multiple aliases should be whitespace separated.
A comment to append to the line within
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.
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 22.214.171.124 lxfsec1604.cern.ch
### 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 126.96.36.199 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" );
"/software/components/hostsfile/entries/tsmstor603/ipaddr" = "192.168.1.103"; "/software/components/hostsfile/entries/tsmstor603/comment" = "Testing";