in-conditional with virtualized resource

50 views
Skip to first unread message

Race Boyer

unread,
Mar 3, 2014, 5:33:18 PM3/3/14
to puppet...@googlegroups.com
Hello everyone,

I am trying virtualize my users and that works out just fine, but the problem is I have some aix users that need a particular group. So I thought it would be a good idea to add a conditional to the virtual resource, but I get stuck with this error:

err: Failed to apply catalog: Could not find dependency Group[9231] for User[race] at /etc/puppet/environments/development/modules/admin2/manifests/virtual.pp:17

what I think is happening is that for some reason my group is not being realized (if that's the proper term?) so the manifest is failing. here is the virtual manifest:

# define type for creating virtual user accounts
define admin2::virtual ($uid,$gid,$realname,$pass,$sshkey="") {

 
user { $title:
  ensure     => 'present',
  uid        => $uid,
  gid        => $gid,
  shell      => '/bin/bash',
  home       => "/home/${title}",
  comment    => $realname,
  password   => $pass,
  managehome => true,
  require    => Group[$gid],
}

group { $title:
  gid => $uid,
}

file { "/home/${title}":
  ensure  => directory,
  owner   => $title,
  group   => $gid,
  mode    => '0750',
  require => [ User[$title], Group[$gid] ],
}

if ( $sshkey != "" ) {
 ssh_authorized_key { $title:
  ensure => 'present',
  type => "ssh-rsa",
  key => "$sshkey",
  user => "$title",
  require => User ["$title"],
  name => "$title"
}
}
}


and here is the init.pp
class admin2 {

$gid = $::operatingsystem ? {
   'AIX'      => '1100',
   default    => $gid,
   }


@admin2::virtual { 'race':
  uid      => '9231',
  gid      => '9231',
  realname => 'Race Boyer',
  pass     => 'pass',
  sshkey => 'sshkey'
}

@admin2::virtual { 'dss':
  uid      => '506',
  gid      => '506',
  realname => 'The DSS team',
  pass     => 'pass',
}

}

i started with the virtual lesson from Craig Dunn's blog if anyone can tell me what I did wrong, it would be greatly appreciated.

José Luis Ledesma

unread,
Mar 3, 2014, 5:51:49 PM3/3/14
to puppet...@googlegroups.com

The group resource name is not gid but title, so change the requiere parameter to Group[$title]

Regards

--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/da0359c9-9d9a-40a4-8ccb-cd622019f5e4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Craig Dunn

unread,
Mar 4, 2014, 5:20:45 AM3/4/14
to puppet...@googlegroups.com

If you change "gid => $gid" to "gid => $title" then you don't need any of the require meta parameters in your user, group or file resource declarations, they can be removed.

There is implied dependency between the gid of a user and the title of a group, and between owners/groups of files and their respective user/group resources.

Craig



--
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 puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/da0359c9-9d9a-40a4-8ccb-cd622019f5e4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Enviatics | Automation and configuration management
http://www.enviatics.com | @Enviatics
Puppet Training http://www.enviatics.com/training/

Race Boyer

unread,
Mar 4, 2014, 11:51:57 AM3/4/14
to puppet...@googlegroups.com
thank you very much, you guys are awesome!
Reply all
Reply to author
Forward
0 new messages