I''m new to puppet. I''m trying to use some real case examples to better understand how Puppet works. Here''s my case: exec { "usermod -d /home/hadoop -s /bin/bash hadoop": unless => "test `grep ^hadoop /etc/passwd | awk -F: ''{print $6}''` == ''/home/hadoop''" } The idea is the usermod would only get executed if the user''s home directory was something other then /home/hadoop. But I see in the client logs that regardless of the condition, the usermod command gets run each and every time. Any tips on what I''m doing wrong? Thanks! -jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
2009/5/7 Jeremy Hansen <jeremy@skidrow.la>:> > > I''m new to puppet. I''m trying to use some real case examples to better > understand how Puppet works. > > Here''s my case: > > exec { "usermod -d /home/hadoop -s /bin/bash hadoop": > unless => "test `grep ^hadoop /etc/passwd | awk -F: ''{print > $6}''` == ''/home/hadoop''" > } > > The idea is the usermod would only get executed if the user''s home > directory was something other then /home/hadoop. But I see in the > client logs that regardless of the condition, the usermod command gets > run each and every time. > > Any tips on what I''m doing wrong? > > Thanks! > -jeremy >Well, you might want to use the user type: user { "hadoop": home => "/home/hadoop", } Though more generally it would be interesting to know why that test is failing even if the user''s homedir is set correctly. Which version of puppet are you using? I assume you''ve run that command on the command line and gotten the correct exit value? .r'' --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RijilV wrote:> 2009/5/7 Jeremy Hansen <jeremy@skidrow.la>: > >> I''m new to puppet. I''m trying to use some real case examples to better >> understand how Puppet works. >> >> Here''s my case: >> >> exec { "usermod -d /home/hadoop -s /bin/bash hadoop": >> unless => "test `grep ^hadoop /etc/passwd | awk -F: ''{print >> $6}''` == ''/home/hadoop''" >> } >> >> The idea is the usermod would only get executed if the user''s home >> directory was something other then /home/hadoop. But I see in the >> client logs that regardless of the condition, the usermod command gets >> run each and every time. >> >> Any tips on what I''m doing wrong? >> >> Thanks! >> -jeremy >> >> > > > Well, you might want to use the user type: > > user { "hadoop": > home => "/home/hadoop", > } > > Though more generally it would be interesting to know why that test is > failing even if the user''s homedir is set correctly. Which version of > puppet are you using? I assume you''ve run that command on the command > line and gotten the correct exit value? >Of course right after writing this mail, I found the user functions and that works perfectly, but like you said, I would still like to understand why this didn''t work. I have other such tests I''d like to run. puppet-server-0.24.8-1.el5.1 puppet-0.24.8-1.el5.1 Thanks -jeremy> .r'' > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeremy Hansen wrote:> I''m new to puppet. I''m trying to use some real case examples to better > understand how Puppet works. > > Here''s my case: > > exec { "usermod -d /home/hadoop -s /bin/bash hadoop": > unless => "test `grep ^hadoop /etc/passwd | awk -F: ''{print $6}''` == ''/home/hadoop''" > }I''d check to be sure that puppet hasn''t expanded the $6 before it ever reaches the awk command. You might need to escape it using \$6 or re-work the ''unless'' to use single quotes. -- Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Despite the high cost of living, it remains a popular item.
Todd Zullinger wrote:> Jeremy Hansen wrote: > >> I''m new to puppet. I''m trying to use some real case examples to better >> understand how Puppet works. >> >> Here''s my case: >> >> exec { "usermod -d /home/hadoop -s /bin/bash hadoop": >> unless => "test `grep ^hadoop /etc/passwd | awk -F: ''{print $6}''` == ''/home/hadoop''" >> } >> > > I''d check to be sure that puppet hasn''t expanded the $6 before it ever > reaches the awk command. You might need to escape it using \$6 or > re-work the ''unless'' to use single quotes. > >Not only that, but you need to fully qualify exec statements, or set path to like /bin:/usr/bin. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- Installping puppet with kickstart -- Cannot find local fact /proc/cpuinfo
- large file download, timeout?
- New user - Issue using Generic::Mkuser in the ghoneycutt/generic module.
- How come that module is not executed in Windows?
- Allowing puppet to drop privileges for a manifest