On Mon, Aug 15, 2011 at 2:26 PM, Aaron Grewell <aaron.grew...@gmail.com>wrote:

> Have you tried including require => Group['admin'] in the user
> declaration?  I try to perform my Requires at the resource level instead of
> the class level if at all possible.
>
> On Mon, Aug 15, 2011 at 2:04 PM, Jim Nachlin <jim.nach...@gawker.com>wrote:
>
>> Hi all,
>>
>> Using Puppet 2.5, I have a class which creates users:
>>
>> # cat modules/users/manifests/init.pp
>>
>> class users {
>>  user { 'ringo':
>>    ensure     => present,
>>    uid        => '1506',
>>    groups     => ['admin'],
>>    shell      => '/bin/bash',
>>    home       => '/home/ringo',
>>    managehome => true,
>>    password =>
>>
>> '$6$jomSNhWn$AbuCjrUnLgmq5KfGygIcChHxM9Oxodcgv3ngHpbhJdJ4jzbsWt8Aj8aQI6G3WPqFe.mrG42KbD/',
>>  }
>> }
>>
>>
>> And one that creates the group:
>>
>>
>>
>> # cat modules/groups/manifests/init.pp
>>
>> class groups {
>>  group { "admin":
>>    ensure => present,
>>  }
>> }
>>
>>
>> However, the group "admin" needs to be created before the user can be
>> part of it.
>>
>> I have tried adding require => Class['groups'] to the user.  I have
>> tried using the "before" syntax.  Also tried adding a statement at the
>> top of the users init.pp, requiring groups.
>>
>> I can not seem to avoid the error:
>>
>>
>> err: //users/User[ringo]/ensure: change from absent to present failed:
>> Could not create user ringo: Execution of '/usr/sbin/useradd -u 1506
>> -G admin -d /home/ringo -p
>>
>> $6$jomSNhWn$AbuCjrUnLgmq5KfGygIcChHxM9OxoNczO7gtHqsngHpbhJdJ4jzbsWt8Aj8aQI6G3WPqFe.mrG42KbD/
>> -s /bin/bash -m ringo' returned 6: useradd: group 'admin' does not
>> exist
>>
>> Or some version of a "Found dependency cycles in the following
>> relationships" type of error.
>>
>> Any help ensuring that the group dependency is met before users are
>> created, would be appreciated.
>>
>
There is an implicit relationship between managed users and groups in
Puppet.  If you're managing the group 'admin' and the user 'ringo' and ringo
needs to be a part of the 'admin' group, Puppet will do the right thing.

Having said that - you want the 'gid' parameter as that will set the default
group.  'groups' is an array of groups for which ringo is a member, but gid
is what you want here.  Give that a try and see if it works for you.

-Gary


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



-- 

Gary Larizza
Professional Services Engineer
Puppet Labs

Join us for PuppetConf <http://bit.ly/puppetconfsig>, September 22nd and
23rd in Portland, OR!

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

Reply via email to