Hi, I have a problem with getting puppet to do what I want. I''ve written a module which I configure via a define, and one of the define''s settings is an array of all user names that are supposed to act as admins of this particular service this module is rolling out, like this: application::config { "app_1": app-admin => ["user1","user2], } application:config { "app_2": app-admin => ["user1","user2,"user3"], } Now this application has a config file, which I''ve made member of a certain group, and I want to add above users to this group: define application::config ( $app-admin ) { group { "$title": ensure => present, system => true, } file { "/etc/$title/app.conf": group => "$title", [...] User<| title == $app-admin |> { groups +> "$title", } So the last User<| |> collection is not adding this group to all app- admin users, but only to "user1". Seems like it is unable to handle arrays. Is there a good reason for that? How can I get this done? Thanks Stephan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
In playing around with something like this, I was able to tag the users and then use the tags to realize the correct set of users: @user { "user1": tag => [ ''app_1'' , ''app_2'' ]; "user2": tag => [ ''app_1'' , ''app_2'' ]; "user3": tag => [ ''app_2'' ]; } Then, you can use this to realize them: User <| tag == $title |> { groups +> "$title", } If you find another way to do it, please let me know. This would work ok for a few apps, but doesn''t scale well. Best, Jeremy -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/ANsV9m10C-oJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Oct 11, 4:38 am, Stephan <stephan.eckwei...@admin.ox.ac.uk> wrote:> User<| title == $app-admin |> { > groups +> "$title", > }Stephan, I think you might want an "in" expression: http://docs.puppetlabs.com/guides/language_guide.html#in-expressions I''ve never tried these with the collection operator, but it would look something like: User<| title in $app-admin |> { groups +> "$title", } Does that work? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Tue, Oct 11, 2011 at 5:48 PM, Nick Fagerlund < nick.fagerlund@puppetlabs.com> wrote:> I''ve never tried these with the collection operator, but it would look > something like: > > User<| title in $app-admin |> { > groups +> "$title", > } > > Does that work? >I wish it did. However, what you proposed results in an error. I think the collection is expecting a attribute name on the left. Error 400 on SERVER: Could not parse for environment production: Syntax error at ''in''; expected ''|>'' Jeremy -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Oct 11, 9:47 pm, jdk <jeremy.ki...@gmail.com> wrote:> In playing around with something like this, I was able to tag the users and > then use the tags to realize the correct set of users:Thanks for the reply, I had a look into that, the problem is that I originally create this user via a define somewhere else. If I would do that I would have to configure my app at 2 different places which I want to avoid. I''ve ended up doing it like this: User<| title == $app-admin[0] |> { groups +> "$title", } User<| title == $app-admin[1] |> { groups +> "$title", } User<| title == $app-admin[2] |> { groups +> "$title", } Then I mention in a comment in the define that builds this app, that the maximum number of users is 3. If you want more, you have to copy and paste above lines a couple times in the config of the application. It''s ugly, but I don''t expect many users in there anyways. Maybe Puppetlabs one day support arrays in here to get rid of this ugly code. Thanks again -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
> I wish it did. However, what you proposed results in an error. I think the > collection is expecting a attribute name on the left. > > Error 400 on SERVER: Could not parse for environment production: Syntax > error at ''in''; expected ''|>''Seems to be as designed. I found this statement: "The only comparisons available are equality and non-equality (using the == and != operators, respectively), and you can join these comparisons using or and and." in http://docs.puppetlabs.com/guides/virtual_resources.html#how-to-realize-resources -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
> Thanks for the reply, I had a look into that, the problem is that I > originally create this user via a define somewhere else. If I would do > that I would have to configure my app at 2 different places which I > want to avoid. I''ve ended up doing it like this: > > User<| title == $app-admin[0] |> { > groups +> "$title", > } >I think I''ve got it! You need a helper define: define application::realize_users ($groups) { User <| title == $name |> { groups +> $groups, } } Then, to realize your array of users: define application::config ( $app-admin ) { <snip> application::realize_users { $app-admin: groups => $title } } I think that will work for you. I was able to implement it for our particular problem and it worked, but we also are trying to change shells and home directories, so it''s a little more complicated than you need. Good luck, Jeremy -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/3IHIgG-rmyMJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.