Hello,
I've create my user from Hiera but now wish configure secondary group 
(setting groups value) but i've problem when the secondary group not exists 
in the node and run puppet agent:
  
[..............]
Error 400 on SERVER: Duplicate declaration: Group[test] is already declared 
in file /etc/puppet/modules/users/manifests/add_user.pp:11; cannot 
redeclare at /etc/puppet/modules/users/manifests/add_user.pp:11 on node 
master.example.com
Error: Could not set groups on user[foo]: Execution of '/usr/sbin/usermod 
-G admin,test foo' returned 6: usermod: group 'test' does not exist
[..............]

My hiera class:

[..............]
classes:
     - users
users:
  foo:
    uid:  9001
    user: 'foo'
    realname: 'Foo'
    shell:  '/bin/bash'
    groups: [admin, test]
[..............]

And my class:


[..............]
define users::add_user (
        $uid    = '',
        $user   = '',
        $realname = '',
        $shell = '',
        $groups = []
){
 
#### I setting this params for create groups
     group {$groups:
        ensure => present,
     }
    user { $user:
            uid    => $uid,
            managehome  => true,
            comment  => $realname,
            shell    => $shell,
            groups => $groups,
    }

[..............]

But when i create the group manually in the node and comment params "group" 
from my class, i dont have problem.

Comment
[.............]
     #group {$groups:
      #  ensure => present,
     #}
[.............]

[root@master manifests]# groupadd test
[root@master manifests]# puppet agent --test 
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for master.example.com
Info: Applying configuration version '1401226860'
Notice: /Stage[main]/Users/Users::Add_user[foo]/User[foo]/groups: groups 
changed 'admin' to 'admin,test'
Notice: Finished catalog run in 0.42 seconds

My question

¿How validate that secondary group exists or create if necessary?


Thanks.


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/cbf86284-5f9a-4de8-946b-7d179342d23b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to