Search code examples
puppet

Possible to have node local configuration file


is it possible to use a node local config file (hiera?) that is used by the puppet master to compile the update list during a puppet run?

My usecase is that puppet will make changes to users .bashrc file and to the users home directory, but I would like to be able to control which users using a file on the actual node itself, not in the site.pp manifest.


Solution

  • is it possible to use a node local config file (hiera?) that is used by the puppet master to compile the update list during a puppet run?

    Sure, there are various ways to do this.

    My usecase is that puppet will make changes to users .bashrc file and to the users home directory, but I would like to be able to control which users using a file on the actual node itself, not in the site.pp manifest.

    All information the master has about the current state of the target node comes in the form of node facts, provided to it by the node in its catalog request. A local file under local control, whose contents should be used to influence the contents of the node's own catalog, would fall into that category. Puppet supports structured facts (facts whose values have arbitrarily-nested list and/or hash structure), which should be sufficient for communicating the needed data to the master.

    There are two different ways to add your own facts to those that Puppet will collect by default:

    • Write a Ruby plugin for Facter, and let Puppet distribute it automatically to nodes, or

    • Write an external fact program or script in the language of your choice, and distribute it to nodes as an ordinary file resource

    Either variety could read your data file and emit a corresponding fact (or facts) in appropriate form. The Facter documentation contains details about how to write facts of both kinds; "custom facts" (Facter plugins written in Ruby) integrate a bit more cleanly, but "external facts" work almost as well and are easier for people who are unfamiliar with Ruby.


    In principle, you could also write a full-blown custom type and accompanying provider, and let the provider, which runs on the target node, take care of reading the appropriate local files. This would be a lot more work, and it would require structuring the solution a bit differently than you described. I do not recommend it for your problem, but I mention it for completeness.