Hi, I''ve been using puppet for about a week and a half now, and it''s definitely making my life a lot easier. I''m using 0.24.1 and I''ve run into a small snag. I''m trying to write some code to make sure user home directories exist for users in LDAP. I''m trying to get their uid, gid and home directory from getent with something like: $uid = generate("/usr/bin/getentfield passwd $title 3") getentfield is a bash script that basically does a getent $1 $2 | cut -d : -f $3. When I try running the generate, I get: Generators can only contain alphanumerics, file separators, and dashes I figured it might be a variable interpolation thing, so I tried taking $title out. I got the same error on the same line number. Then I tried a plain generate("/usr/bin/getentfield") and it executed. Are spaces really not allowed in generate calls? Doesn''t that sort of make generate useless? I''m guessing/hoping it''s a typo in a regex somewhere.. If there''s a better way to get external information, I''d gladly use that instead.. Thanks! _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Gary, Are you using Linux? If so, why not use the PAM setting to create the home directory if it isn''t present? http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/sag-pam_mkhomedir.html T On Jan 23, 2008 1:28 PM, Gary Richardson <gary.richardson@gmail.com> wrote:> Hi, > > I''ve been using puppet for about a week and a half now, and it''s definitely > making my life a lot easier. I''m using 0.24.1 and I''ve run into a small > snag. > > I''m trying to write some code to make sure user home directories exist for > users in LDAP. I''m trying to get their uid, gid and home directory from > getent with something like: > > > $uid = generate("/usr/bin/getentfield passwd $title 3") > > getentfield is a bash script that basically does a getent $1 $2 | cut -d : > -f $3. > > When I try running the generate, I get: > > Generators can only contain alphanumerics, file separators, and dashes > > I figured it might be a variable interpolation thing, so I tried taking > $title out. I got the same error on the same line number. > > Then I tried a plain generate("/usr/bin/getentfield") and it executed. > > Are spaces really not allowed in generate calls? Doesn''t that sort of make > generate useless? I''m guessing/hoping it''s a typo in a regex somewhere.. > > If there''s a better way to get external information, I''d gladly use that > instead.. > > Thanks! > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users > >
Yes, I''m pretty much exclusively using CentOS 5. There''s a bit of a race condition using pam_mkhomedir. I want to use key based ssh auth only, so I need to put the ssh keys in place first. I plan on having puppet pull the ssh keys out of ldap as well. I''ve done it this way in the past and it works better than using the LPK patch for ssh (I want to avoid patching SSH to make this work). On Jan 23, 2008 11:08 AM, Trevor Vaughan <peiriannydd@gmail.com> wrote:> Gary, > > Are you using Linux? > > If so, why not use the PAM setting to create the home directory if it > isn''t present? > > > http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/sag-pam_mkhomedir.html > > T > > On Jan 23, 2008 1:28 PM, Gary Richardson <gary.richardson@gmail.com> > wrote: > > Hi, > > > > I''ve been using puppet for about a week and a half now, and it''s > definitely > > making my life a lot easier. I''m using 0.24.1 and I''ve run into a small > > snag. > > > > I''m trying to write some code to make sure user home directories exist > for > > users in LDAP. I''m trying to get their uid, gid and home directory from > > getent with something like: > > > > > > $uid = generate("/usr/bin/getentfield passwd $title 3") > > > > getentfield is a bash script that basically does a getent $1 $2 | cut -d > : > > -f $3. > > > > When I try running the generate, I get: > > > > Generators can only contain alphanumerics, file separators, and dashes > > > > I figured it might be a variable interpolation thing, so I tried taking > > $title out. I got the same error on the same line number. > > > > Then I tried a plain generate("/usr/bin/getentfield") and it executed. > > > > Are spaces really not allowed in generate calls? Doesn''t that sort of > make > > generate useless? I''m guessing/hoping it''s a typo in a regex somewhere.. > > > > If there''s a better way to get external information, I''d gladly use that > > instead.. > > > > Thanks! > > _______________________________________________ > > Puppet-users mailing list > > Puppet-users@madstop.com > > https://mail.madstop.com/mailman/listinfo/puppet-users > > > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users >_______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Ah, I found that LPK really did end up being the easiest way to go with this. In this case, it sounds like you might need to drop it into an external script or an exec to do all of the work. Good luck! Trevor On Jan 23, 2008 2:17 PM, Gary Richardson <gary.richardson@gmail.com> wrote:> Yes, I''m pretty much exclusively using CentOS 5. > > There''s a bit of a race condition using pam_mkhomedir. I want to use key > based ssh auth only, so I need to put the ssh keys in place first. I plan on > having puppet pull the ssh keys out of ldap as well. I''ve done it this way > in the past and it works better than using the LPK patch for ssh (I want to > avoid patching SSH to make this work). > > > > On Jan 23, 2008 11:08 AM, Trevor Vaughan <peiriannydd@gmail.com> wrote: > > Gary, > > > > Are you using Linux? > > > > If so, why not use the PAM setting to create the home directory if it > > isn''t present? > > > > > http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/sag-pam_mkhomedir.html > > > > T > > > > > > > > > > On Jan 23, 2008 1:28 PM, Gary Richardson < gary.richardson@gmail.com> > wrote: > > > Hi, > > > > > > I''ve been using puppet for about a week and a half now, and it''s > definitely > > > making my life a lot easier. I''m using 0.24.1 and I''ve run into a small > > > snag. > > > > > > I''m trying to write some code to make sure user home directories exist > for > > > users in LDAP. I''m trying to get their uid, gid and home directory from > > > getent with something like: > > > > > > > > > $uid = generate("/usr/bin/getentfield passwd $title 3") > > > > > > getentfield is a bash script that basically does a getent $1 $2 | cut -d > : > > > -f $3. > > > > > > When I try running the generate, I get: > > > > > > Generators can only contain alphanumerics, file separators, and dashes > > > > > > I figured it might be a variable interpolation thing, so I tried taking > > > $title out. I got the same error on the same line number. > > > > > > Then I tried a plain generate("/usr/bin/getentfield") and it executed. > > > > > > Are spaces really not allowed in generate calls? Doesn''t that sort of > make > > > generate useless? I''m guessing/hoping it''s a typo in a regex somewhere.. > > > > > > If there''s a better way to get external information, I''d gladly use that > > > instead.. > > > > > > Thanks! > > > _______________________________________________ > > > Puppet-users mailing list > > > Puppet-users@madstop.com > > > https://mail.madstop.com/mailman/listinfo/puppet-users > > > > > > > > _______________________________________________ > > Puppet-users mailing list > > Puppet-users@madstop.com > > https://mail.madstop.com/mailman/listinfo/puppet-users > > > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users > >
Generate doesn''t shell out in a traditional sense. I''m not quite yet a ruby guy so I''m not very good at explaining what it really does, but I do something like this to work around it. generate("/bin/sh", "-c", "grep ^${name} /etc/passwd | cut -d: -f6") C On 1/23/08, Gary Richardson <gary.richardson@gmail.com> wrote:> > Hi, > > I''ve been using puppet for about a week and a half now, and it''s > definitely making my life a lot easier. I''m using 0.24.1 and I''ve run into > a small snag. > > I''m trying to write some code to make sure user home directories exist for > users in LDAP. I''m trying to get their uid, gid and home directory from > getent with something like: > > $uid = generate("/usr/bin/getentfield passwd $title 3") > > > > getentfield is a bash script that basically does a getent $1 $2 | cut -d : > -f $3. > > > When I try running the generate, I get: > > > Generators can only contain alphanumerics, file separators, and dashes > > > > I figured it might be a variable interpolation thing, so I tried taking > $title out. I got the same error on the same line number. > > > Then I tried a plain generate("/usr/bin/getentfield") and it executed. > > > Are spaces really not allowed in generate calls? Doesn''t that sort of make > generate useless? I''m guessing/hoping it''s a typo in a regex somewhere.. > > > If there''s a better way to get external information, I''d gladly use that > instead.. > > > Thanks! > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users > >-- stickm@gmail.com -==< Stick >==- _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Brilliant. That did the trick. Thanks! On Jan 23, 2008 11:47 AM, Chris MacLeod <stickm@gmail.com> wrote:> Generate doesn''t shell out in a traditional sense. I''m not quite yet a > ruby guy so I''m not very good at explaining what it really does, but I do > something like this to work around it. > generate("/bin/sh", "-c", "grep ^${name} /etc/passwd | cut -d: -f6") > > C > > On 1/23/08, Gary Richardson <gary.richardson@gmail.com> wrote: > > > Hi, > > > > I''ve been using puppet for about a week and a half now, and it''s > > definitely making my life a lot easier. I''m using 0.24.1 and I''ve run > > into a small snag. > > > > I''m trying to write some code to make sure user home directories exist > > for users in LDAP. I''m trying to get their uid, gid and home directory from > > getent with something like: > > > > $uid = generate("/usr/bin/getentfield passwd $title 3") > > > > > > > > getentfield is a bash script that basically does a getent $1 $2 | cut -d > > : -f $3. > > > > > > When I try running the generate, I get: > > > > > > Generators can only contain alphanumerics, file separators, and dashes > > > > > > > > I figured it might be a variable interpolation thing, so I tried taking > > $title out. I got the same error on the same line number. > > > > > > Then I tried a plain generate("/usr/bin/getentfield") and it executed. > > > > > > Are spaces really not allowed in generate calls? Doesn''t that sort of > > make generate useless? I''m guessing/hoping it''s a typo in a regex > > somewhere.. > > > > > > If there''s a better way to get external information, I''d gladly use that > > instead.. > > > > > > Thanks! > > > > _______________________________________________ > > Puppet-users mailing list > > Puppet-users@madstop.com > > https://mail.madstop.com/mailman/listinfo/puppet-users > > > > > > > -- > stickm@gmail.com > -==< Stick >==- > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users > >_______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
I hit another snag with this. It seems that generate() doesn''t strip the \n''s off the end of the output. I was trying to: exec { ["mkhomedir -s $skel -u $uid -g $gid -h $home_dir -m $mode"] : and it kept trying to execute mkhomedir -s /etc/skel, then -u 1000, then -g 1000 etc.. Is there a way to strip the \n off of a variable inside puppet? Would this be considered a bug with generate? I''ve worked around it by having my getentfield script use echo -n on the final output. Thanks. On Jan 23, 2008 12:52 PM, Gary Richardson <gary.richardson@gmail.com> wrote:> Brilliant. That did the trick. > Thanks! > > > On Jan 23, 2008 11:47 AM, Chris MacLeod <stickm@gmail.com> wrote: > > > Generate doesn''t shell out in a traditional sense. I''m not quite yet a > > ruby guy so I''m not very good at explaining what it really does, but I do > > something like this to work around it. > > generate("/bin/sh", "-c", "grep ^${name} /etc/passwd | cut -d: -f6") > > > > C > > > > On 1/23/08, Gary Richardson <gary.richardson@gmail.com> wrote: > > > > > Hi, > > > > > > I''ve been using puppet for about a week and a half now, and it''s > > > definitely making my life a lot easier. I''m using 0.24.1 and I''ve run > > > into a small snag. > > > > > > I''m trying to write some code to make sure user home directories exist > > > for users in LDAP. I''m trying to get their uid, gid and home directory from > > > getent with something like: > > > > > > $uid = generate("/usr/bin/getentfield passwd $title 3") > > > > > > > > > > > > getentfield is a bash script that basically does a getent $1 $2 | cut > > > -d : -f $3. > > > > > > > > > When I try running the generate, I get: > > > > > > > > > Generators can only contain alphanumerics, file separators, and dashes > > > > > > > > > > > > > > > I figured it might be a variable interpolation thing, so I tried > > > taking $title out. I got the same error on the same line number. > > > > > > > > > Then I tried a plain generate("/usr/bin/getentfield") and it executed. > > > > > > > > > Are spaces really not allowed in generate calls? Doesn''t that sort of > > > make generate useless? I''m guessing/hoping it''s a typo in a regex > > > somewhere.. > > > > > > > > > If there''s a better way to get external information, I''d gladly use > > > that instead.. > > > > > > > > > Thanks! > > > > > > _______________________________________________ > > > Puppet-users mailing list > > > Puppet-users@madstop.com > > > https://mail.madstop.com/mailman/listinfo/puppet-users > > > > > > > > > > > > -- > > stickm@gmail.com > > -==< Stick >==- > > > > _______________________________________________ > > Puppet-users mailing list > > Puppet-users@madstop.com > > https://mail.madstop.com/mailman/listinfo/puppet-users > > > > >_______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On Jan 24, 2008, at 8:38 AM, Gary Richardson wrote:> I hit another snag with this. It seems that generate() doesn''t strip > the \n''s off the end of the output. I was trying to: > > exec { ["mkhomedir -s $skel -u $uid -g $gid -h $home_dir -m $mode"] : > > and it kept trying to execute mkhomedir -s /etc/skel, then -u 1000, > then -g 1000 etc.. Is there a way to strip the \n off of a variable > inside puppet? Would this be considered a bug with generate?Use a function insead of a generator; then you have total control of the output. See the wiki page that''s something like WritingYourOwnFunctions. -- Men never do evil so completely and cheerfully as when they do it from a religious conviction. --Blaise Pascal --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com