Re: [Puppet Users] Dynamically extending the group membership of a custom system user

2012-02-13 Thread Gabriel Filion
Hello,

On 12-02-13 07:59 AM, Christian Requena wrote:
> I need to expand the membership of a custom system user depending on the
> availability of some group on the target system i.e.
> 
>user {
> "logger":
> name => "logger",
> ensure => "present",
> groups => ["adm", "wheel", "this _group_ if it exists"],
> shell => "/bin/bash";
> }
> 
> The "this _group_ if it exists" entry only works, if the group was
> already create.  I need to expand the list of groups depending on the
> availability of some groups like i.e.
> 
>   user {
> "logger":
> name => "logger",
> ensure => "present",
> [ 'mongodv', 'postgres', 'custom', 'www' ].each do | g |
> g.exist? _groups < g.to_s
> end
> groups => _groups
> shell => "/bin/bash";
> }
> 
> I know that is totally wrong, but I just want to describe what I'm
> aiming to.

One thing you could do would be to create a custom fact that would
harvest those groups that are present and that you need to add to your
users. (I can't help you too much with how to implement this, though,
since my ruby is at the level of baby steps)

In your manifests, you would then have to split the string returned by
the fact into an array and add this array to your static list of groups.

-- 
Gabriel Filion

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] Dynamically extending the group membership of a custom system user

2012-02-13 Thread Christian Requena

Hello,

I need to expand the membership of a custom system user depending on the 
availability of some group on the target system i.e.


   user {
"logger":
name => "logger",
ensure => "present",
groups => ["adm", "wheel", "this _group_ if it exists"],
shell => "/bin/bash";
}

The "this _group_ if it exists" entry only works, if the group was 
already create.  I need to expand the list of groups depending on the 
availability of some groups like i.e.


  user {
"logger":
name => "logger",
ensure => "present",
[ 'mongodv', 'postgres', 'custom', 'www' ].each do | g |
g.exist? _groups < g.to_s
end
groups => _groups
shell => "/bin/bash";
}

I know that is totally wrong, but I just want to describe what I'm 
aiming to.


Thanks!
Christian

--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.