Skip to content
Jason Heiss edited this page Aug 25, 2014 · 3 revisions

Etch is based on a client/server model where the server normally generates a client's configuration based on a configuration repository stored on the server and basic facts about the client supplied by the client from the Facter library. In other words the configuration is centrally managed and the client has little control over what configuration it receives. However, sometimes you want to allow individual clients to request additions or modifications to the standard configuration. In particular we use this to allow software packages from the tpkg package management tool to request things like accounts, kernel settings and NFS mounts. For example, the mysql package requests a "mysql" user and group. It is up to your etch configuration script or template to do something with the request, so by default requests will be ignored. You can choose to act on the request only under certain circumstances. For example, we only implement account requests for accounts that have already been defined, and only obey requests for human accounts on non-production machines.

Client Side

On the client side requests are created by dropping an file into /var/etch/requests/[path to file]. For example, if you want a request associated with /etc/passwd you'd create a file like /var/etch/requests/etc/passwd/myrequest. The filename within the directory doesn't matter, use whatever helps you keep them straight. For example, with tpkg we creates requests using filenames based on the package that included the request. Anytime the etch client asks the etch server for file configuration the client will include the contents of all files in the request directory.

You can use any format or structure within the request files, we recommend YAML. As a simple example a request for an account might look like:

user: mysql

Server Side

Your script or template will receive any requests from the client in the @local_requests_array variable.

Here's an example for processing requests for users that could go in your etc/passwd/passwd.script, assuming you've defined a method named add_user which reads from your source(s) of accounts and adds the right data to @contents:

@local_requests_array.each do |local_request|
  request = YAML.load(local_request)
  if request.kind_of?(Hash)
    request.each do |key, value|
      if key == 'user' && value && !value.to_s.empty?
        add_user(value.to_s)
      end
    end
  end
end

Older XML Format

The older XML format for local request files is still supported.