hi all, I wanted to create multiple set of users in my client in one go. how to do it? i tried with ''define'' but there is a problem with it. /modules/functions/usermanagement.pp ---------------------------------------------------------- * define createUsers($username, $group, $home, $host) { $sshDir = ".ssh" $pub_key = "id_rsa.pub" realize( Group[$group], User[$username], ) file { "${home}/${username}": ensure => directory, owner => $username, group => $group, mode => 750, require => User["${username}"], } file { "${home}/${username}/${sshDir}": ensure => directory, owner => $username, group => $group, mode => 700, require => File["${home}/${username}"], } file { "${home}/${username}/$sshDir/authorized_keys": ensure => present, owner => $username, group => $group, mode => 600, require => File["${home}/${username}/.ssh"], source => "puppet:///myfiles/$pub_key.${username}", }* /modules/functions/staffmanagement.pp ---------------------------------------------------------- * class mystaff { createUsers{ "realizingUser": # defined function in above file username => "xxxx", group => "gggg", home => "/home", host => "x.x.x.x", } } * It is working for 1 user but calling createUsers for more than 1 user is not possible with this, Can any one guide me how make it possible. or if you have the same thing in past please share with me. Thanks & Regards M.Haris Farooque --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Saurabh Verma
2009-Nov-05 12:06 UTC
[Puppet Users] Re: Creating Multiple Users using ''define''
I use this like this --(saurabh.ve@puppet)-(~/puppet/modules/users/manifests)-- --(0)> cat init.pp class users::common { group { "t-sysad": ensure => present, } @file { "/etc/sudoers": owner => root, group => root, mode => 440, source => [ "puppet:///users/$project/sudoers.$hostname" , "puppet:///users/$project/sudoers" , "puppet:///users/sudoers.$hostname" , "puppet:///users/sudoers" , ] } } define users::add ( $username , $groupname = "" , $shell = "", $password = "" , $ensure , $login = false ) { user { "$username": ensure => "$ensure" , groups => "$groupname" , shell => "$shell" , password => "$password", require => Group["t-sysad"] , } if $login != false { file { "/home/$username" : ensure => directory , mode => 644 , owner => $username , group => $username , before => [ File["/home/$username/.ssh"] , File["/home/$username/.ssh/authorized_keys"] , File["/home/$username/.bashrc"] ] , } file { "/home/$username/.ssh" : ensure => directory , mode => 644 , owner => $username , group => $username , } file { "/home/$username/.ssh/authorized_keys": ensure => present , source => "puppet:///users/authorized_keys/$username" , mode => 644 , require => [ User["$username"] , File["/home/$username/.ssh"] ] , owner => $username , group => $username , } file { "/home/$username/.bashrc": ensure => present , source => [ "puppet:///users/user_bashrc.$username" , "puppet:///users/user_bashrc" ] , mode => 644, owner => "$username", group => "$username", require => User["$username"] , } } } --(saurabh.ve@puppet)-(~/puppet/manifests/production/common/nodes)-- --(1)> cat common_users.pp class sysad_users { include users::common users::add { "user4": username => "user4" , groupname => "t-sysad" , shell => "/bin/bash" , ensure => present , login => true } users::add { "user3": username => "user3" , groupname => "t-sysad" , shell => "/bin/bash" , ensure => present , login => true } users::add { "user2": username => "user2" , groupname => "t-sysad" , shell => "/bin/bash" , ensure => present , login => true } users::add { "user1": username => "user1" , groupname => "t-sysad" , shell => "/bin/bash" , ensure => present , login => true } users::add { "nagios": username => "nagios" , ensure => present , login => false } } This works fine for me , you can make necessary modification as per your need . Thanks ~saurabh On 11/5/2009 4:48 PM, M.F.Haris wrote:> hi all, > I wanted to create multiple set of users in my client in one go. how > to do it? i tried with ''define'' but there is a problem with it. > > /modules/functions/usermanagement.pp > ---------------------------------------------------------- > / > define createUsers($username, $group, $home, $host) > { > $sshDir = ".ssh" > $pub_key = "id_rsa.pub" > > realize( > Group[$group], > User[$username], > ) > file { "${home}/${username}": > ensure => directory, > owner => $username, > group => $group, > mode => 750, > require => User["${username}"], > } > file { "${home}/${username}/${sshDir}": > ensure => directory, > owner => $username, > group => $group, > mode => 700, > require => File["${home}/${username}"], > } > file { "${home}/${username}/$sshDir/authorized_keys": > ensure => present, > owner => $username, > group => $group, > mode => 600, > require => File["${home}/${username}/.ssh"], > source => "puppet:///myfiles/$pub_key.${username}", > }/ > > > /modules/functions/staffmanagement.pp > ---------------------------------------------------------- > / > class mystaff > { > createUsers{ "realizingUser": # defined function in above file > username => "xxxx", > group => "gggg", > home => "/home", > host => "x.x.x.x", > } > } > / > It is working for 1 user but calling createUsers for more than 1 user > is not possible with this, Can any one guide me how make it possible. > or if you have the same thing in past please share with me. > > Thanks & Regards > M.Haris Farooque > > > >--~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
jcbollinger
2009-Nov-05 14:28 UTC
[Puppet Users] Re: Creating Multiple Users using ''define''
On Nov 5, 5:18 am, "M.F.Haris" <mfha...@gmail.com> wrote:> hi all, > I wanted to create multiple set of users in my client in one go. how to do > it? i tried with ''define'' but there is a problem with it.> define createUsers($username, $group, $home, $host) > { > $sshDir = ".ssh" > $pub_key = "id_rsa.pub" > > realize( > Group[$group], > User[$username], > ) > file { "${home}/${username}":[...]> file { "${home}/${username}/${sshDir}":[...]> file { "${home}/${username}/$sshDir/authorized_keys":[...]> class mystaff > { > createUsers{ "realizingUser": # defined function in above file > username => "xxxx", > group => "gggg", > home => "/home", > host => "x.x.x.x", > }}> It is working for 1 user but calling createUsers for more than 1 user is not > possible with this, Can any one guide me how make it possible. or if you > have the same thing in past please share with me.It sounds like you may be using the same name for each invocation of the definition (the "realizingUser" part). The names must be unique. I don''t see you using the $name or $title variables anywhere in the definition body, so does the name actually have any significance in your current implementation? You could try rewriting it like this: # Note: removed the $username parameter define createUsers($group, $home, $host) { realize( Group[$group], # Note: $name instead of $username User[$name], ) # Declarations of user-associated file resources, etc. ... } You would then invoke it like so: class mystaff { # Note: "xxxx" is the username of the user to create createUsers{ "xxxx": group => "gggg", home => "/home", host => "x.x.x.x", } # ... } --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
hi all, I am trying to create a set of users on my AIX node and trying to get their authorized_keys which are already hosted on my server with name like, myuser_id_ds.pub. Currently i am managing 2 nodes (1. Suse Enterprise 2. AIX). I defined the ''source'' file paths in 2 separate contexts in fileserver.conf; [AIX] path myfiles/users/ssh/ allow *.another.mydomain.com [SLES] path myfiles/users/*keys*/ssh/ allow *.mydomain.com but when I run puppet then it ended successfully on my SLES node but encountered failure on AIX node; with following err; /* Could not describe _/AIX/_id_rsa.pub.rkramer: Fileserver module ''AIX'' not mounted*/ in my code i have defined the ''source'' with $filserver variable as: case $operatingsystem { "AIX": { $fileserver = "AIX" } default: { $fileserver = "SLES" } } file { "${home}/${username}/.ssh/authorized_keys": source => "puppet:///$fileserver/$pub_key.${username}", .... } why AIX is not able to get the source path from my fileserver.conf while SLES is running absolutely fine? and how can I do it? I have to run similar configuration across different servers so I can only deal it with case statement. looking forward for your help Thanks --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---