Host generator: Difference between revisions
Jump to navigation
Jump to search
(Created page with "The '''host generator''' API is a way of automatically and consistly applying scripts to the contents of <code>hostlist.csv</code> to generate files to be installed on cfengine client hosts. A good example of this is the <code>/etc/hostname</code> file. Because <code>hostlist.csv</code> contains both the name and IP address of each known host its contents can be used to create an individual <code>/etc/hostname</code> that cfengine (or <code>cf-agent</code>,...") |
No edit summary |
||
Line 18: | Line 18: | ||
# Generally, the host generators create files in directories in <code>[[/usr/local/warehouse]]</code> from whence <code>[[cf-agent]]</code> collects the files and installs them on the individual hosts. | # Generally, the host generators create files in directories in <code>[[/usr/local/warehouse]]</code> from whence <code>[[cf-agent]]</code> collects the files and installs them on the individual hosts. | ||
At this stage it'd probably be most informative to look at individual host generators on the cfengine hub for more insight on how they work. | At this stage it'd probably be most informative to look at individual host generators on the [[cfengine hub]] for more insight on how they work. |
Revision as of 13:39, 26 July 2022
The host generator API is a way of automatically and consistly applying scripts to the contents of hostlist.csv
to generate files to be installed on cfengine client hosts.
A good example of this is the /etc/hostname
file. Because hostlist.csv
contains both the name and IP address of each known host its contents can be used to create an individual /etc/hostname
that cfengine (or cf-agent
, actually) will install on each host.
Introduction to how host generators work
- On the cfengine hub there is a directory
/usr/local/administration/host.generators
, - Inside this directory there is a subdirectory for each host generator. For example, the host generator for the
/etc/hostname
file for each client host is there and its subdirectory is calledetc_hostname
. As a second example, there's also a host generator for the automounter configuration files and its subdirectory is calledautofs
, - The host generators are invoked by running the
update_hosts
script on the cfengine hub. It:- Invokes the
setup.sh
script in each host generator subdirectory ONCE at the start of each run ofupdate_hosts
, - It then iterates through each host line in
hostlist.csv
and then invokes theadd_host.sh
once per host per host generator passing the scripts the following parameters:- A temporary persistent directory (shared with other generators)
- The unqualified host name
- The IP address of the host
- The host's host classes ('+'-separated)
- The host's file system exports if it's a server ('+'-separated)
- After all host lines have been processed the
finish.sh
script in each host generator subdirectory is executed ONCE.
- Invokes the
- Generally, the host generators create files in directories in
/usr/local/warehouse
from whencecf-agent
collects the files and installs them on the individual hosts.
At this stage it'd probably be most informative to look at individual host generators on the cfengine hub for more insight on how they work.