0

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?

2
  • I assume line 71 is 'User {...'? Also, '+>' appears to be supported in 0.25: docs.puppetlabs.com/guides/language_guide.html.
    – Kyle Smith
    Apr 4, 2012 at 13:39
  • Yes @KyleSmith, the syntax is supported in 0.25, but it doesn't seem to work unless it's applied in the case of an inheritance.
    – raphink
    Apr 4, 2012 at 13:46

2 Answers 2

0

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.

1
  • 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.
    – raphink
    Apr 6, 2012 at 6:27
0

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 =>.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .