I'm trying to add a require to the default resource for users in Puppet:

User { require => Mount['/home'] }

Using Puppet 0.25, I get the following error:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '+>'; expected '}' at /home/rpinson/puppetmaster/manifests/foo.pp:71 on node ip-bar.internal

Is there a way to achieve that?


In this case, it might be easier to leverage a define resource instead of resource defaults.

define myuser (
  ... # you certainly need the rest of the user attribute.
) {
  user { $name:
    require => Mount['/home'],
    ... # and the rest of your attributes.

If you declare myuser{ 'johndoe': }, it should also have mount as a requirement.

  • It doesn't work in this case. My use case is: I'm defining partitions and some servers have /home as a separate partition (using LVM). As a result, creating users (whatever they are) requires /home to be mounted on these servers. This is a general requirement, whatever resource triggers the user creation, so I can't use a wrapper for the user type. – ℝaphink Apr 6 '12 at 6:27

Use a resource collector:

User <| |> {
    require +> Mount['/home'],

This adds the requirement to all User instances, but also has a side-effect of realizing any virtual users.

As far is I remember, this is supported in 0.25.

Also, +> operator cannot be used in regular parameter definitions, only in overrides or collectors. Replace those with =>.

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.