Dears all, I'd got a solution , far away from the best because it's
based on execute method and also because it's not use Group[$groups] -
> User[$username] dependencies way.

 Testing something like this are good :


  $a_groups = inline_template(
              "<% groups.each do |grp| -%> <%= username %>_<%= grp %>,<
% end -%>")

  $usr_groups = split($a_groups, ',')

  updssh::check_groups { $usr_groups: }


  -----

  define updssh::check_groups {
        $arr = split($title, '_')
         $usr = $arr[0]
         $group = $arr[1]

         if ! defined(Group[$group]) {

            group { $group:
                ensure => present
            }
         }
   }

 I'm pretty sure it's a first one version that it's giving to me a
chance to go on.


  Best Regards,
   eduardo.

On 2 jul, 17:06, eduardo <erodr...@gmail.com> wrote:
>  Thanks tim for answer me, The fact is $groups is an array, so when i
> try something like this
>
> ------
>             Group[$groups] -> User[$username]
>
>             user { $username:
>                     comment => "$email",
>                     home    => "/home/$username",
>                     shell   => "/bin/bash",
>                     password => "!!",
>                     groups  => $groups
>             }
>
> ------
>
>  I'd got :
>
>  err: Could not retrieve catalog from remote server: Error 400 on
> SERVER: Could not find resource 'Group[sudo]Group[admin]Group[deploy]'
> for relationship on 'User[ppuser7]' on node casa
>
>  Is there any way to work around ?.
>
>   Regards,
>     eduardo.
>
> On 2 jul, 13:20, Tim Mooney <tim.moo...@ndsu.edu> wrote:
>
>
>
>
>
>
>
> > In regard to: [Puppet Users] groups dependencies at user creation, 
> > eduardo...:
>
> > >  I'm trying to create new users members of some groups so it's need
> > > to ensure they exist before user creation.
>
> > >  I have something like :
>
> > > ----
> > > define updssh::add_user ( $email , $groups  ) {
>
> > >            $username = $title
>
> > >            user { $username:
> > >                    comment => "$email",
> > >                    home    => "/home/$username",
> > >                    shell   => "/bin/bash",
> > >                    password => "!!",
> > >                    groups  => $groups
> > >            }
>
> > > ------
>
> > >  How to ensure groups dependencies at user creation ?.
>
> > If you were just talking about the user's default group, then it would
> > be one of the few cases where puppet establishes an ordering relation
> > for you automatically.  In other words:
>
> >    user { 'foo':
> >      gid => 'bar',
> >    }
>
> > automatically ensures that group 'bar' is present before user 'foo'.
>
> > I don't know if that same thing is true for supplemental groups, but if
> > it's not, I would first try using the -> notation to establish ordering,
> > like this
>
> >    Group[$groups] -> User[$username]
>
> > Does that work for you?
>
> > Tim
> > --
> > Tim Mooney                                             tim.moo...@ndsu.edu
> > Enterprise Computing & Infrastructure                  701-231-1076 (Voice)
> > Room 242-J6, IACC Building                             701-231-8541 (Fax)
> > North Dakota State University, Fargo, ND 58105-5164

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