I'm using Puppet in my environment to automatically configure the Linux servers. There are many puppet modules configured and it works like a charm. There's a motivation to allow a specific user (nagios) to read some specific logs. Nagios and NRPE are being installed by the relevant puppet module and that module also creates the nagios user. Once the nagios user is created, I want puppet to add it to a group called users.

But then when I come to think of it, I don't know by which order puppet loads the modules, so if it will try to add the nagios user to the users group before the nagios module have been loaded and the nagios user has been created then there will be an error as the user doesn't exist yet.

My question, is how can I enforce the Nagios module to be loaded first for example?

Thanks in advance

  • The specific example is a non-issue. If you assign ownerships to files, Puppet will go out of its way to detect if the user and group are under its management. If so, a dependency is automatically established. The group and user are managed prior to the file(s) in question, and in the case of an error with either the user or group, the files will not be touched at all. – Felix Frank Jan 2 '15 at 12:34

This can be done with options like require etc. (https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html).

One example from the link:

package { 'openssh-server':
  ensure => present,
  before => File['/etc/ssh/sshd_config'],

would make sure that the file /etc/ssh/sshd_config defined in another resource would only be applied after openssh-server is installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.