Hello good people. Env: puppet 2.6.4, facter 1.5.8 I''m trying to set a variable in a defaults resource like this. In the password attribute I set the $name variable which I hoped would be the the user name. I can see now that this evaluates to the class name. Are their any other approaches to get the variable to evaluate to the user name. I tried using an inline template and qualifying the variable but couldn''t get the user name. I figured it was an error in my inline template. User { password_min_age => "7", password_max_age => "90", password => generate(''/site/bin/grabass.rb'', ''-u'', "$name"), } TIA. deet. -- 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.
Jonathan Barber
2010-Dec-22 23:42 UTC
Re: [Puppet Users] use of variable in resource defaults
On 22 December 2010 19:38, deet <someword@gmail.com> wrote:> Hello good people. > Env: puppet 2.6.4, facter 1.5.8 > > I''m trying to set a variable in a defaults resource like this. In > the password attribute I set the $name variable which I hoped would be > the the user name. I can see now that this evaluates to the class > name. Are their any other approaches to get the variable to evaluate > to the user name. I tried using an inline template and qualifying the > variable but couldn''t get the user name. I figured it was an error in > my inline template.You can''t do this at the moment, hopefully in the future you will be able to: http://projects.puppetlabs.com/issues/5061 For now, you have to create a define to wrap the user in (untested): define my_user { user { $name: ... password => generate(''/site/bin/grabass.rb'', ''-u'', $name), } }> User { > password_min_age => "7", > password_max_age => "90", > password => generate(''/site/bin/grabass.rb'', ''-u'', > "$name"), > } > > TIA. deet.-- Jonathan Barber <jonathan.barber@gmail.com> -- 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.
On 12/23/2010 12:42 AM, Jonathan Barber wrote:> On 22 December 2010 19:38, deet <someword@gmail.com> wrote: >> Hello good people. >> Env: puppet 2.6.4, facter 1.5.8 >> >> I''m trying to set a variable in a defaults resource like this. In >> the password attribute I set the $name variable which I hoped would be >> the the user name. I can see now that this evaluates to the class >> name. Are their any other approaches to get the variable to evaluate >> to the user name. I tried using an inline template and qualifying the >> variable but couldn''t get the user name. I figured it was an error in >> my inline template. > > You can''t do this at the moment, hopefully in the future you will be able to: > http://projects.puppetlabs.com/issues/5061That issue is similar, but the problem here is related more strongly to http://projects.puppetlabs.com/issues/5259 So I have to say - hopefully this is *not* going to be possible any time soon.> For now, you have to create a define to wrap the user in (untested): > define my_user { > user { $name: > ... > password => generate(''/site/bin/grabass.rb'', ''-u'', $name), > } > }I agree with this completely. Cheers, Felix -- 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.
Jonathan Barber
2010-Dec-23 11:01 UTC
Re: [Puppet Users] use of variable in resource defaults
On 23 December 2010 09:30, Felix Frank <felix.frank@alumni.tu-berlin.de> wrote:> On 12/23/2010 12:42 AM, Jonathan Barber wrote: >> On 22 December 2010 19:38, deet <someword@gmail.com> wrote: >>> Hello good people. >>> Env: puppet 2.6.4, facter 1.5.8 >>> >>> I''m trying to set a variable in a defaults resource like this. In >>> the password attribute I set the $name variable which I hoped would be >>> the the user name. I can see now that this evaluates to the class >>> name. Are their any other approaches to get the variable to evaluate >>> to the user name. I tried using an inline template and qualifying the >>> variable but couldn''t get the user name. I figured it was an error in >>> my inline template. >> >> You can''t do this at the moment, hopefully in the future you will be able to: >> http://projects.puppetlabs.com/issues/5061 > > That issue is similar, but the problem here is related more strongly to > http://projects.puppetlabs.com/issues/5259Ah, I vaguely remembered this ticket but conflated them when I looked for it. I see the point you make in the ticket; would there be similar problems with having a variable with a different name representing the same concept? I guess it would be quite a a large change in how variable scoping works, so wouldn''t be very clean from that point of view. I was thinking of a macro system as a solution, but then I saw that the puppet wiki glossary suggests defines can be considered as a type of macro - so I guess that is the way to do it. Cheers> So I have to say - hopefully this is *not* going to be possible any time > soon. > >> For now, you have to create a define to wrap the user in (untested): >> define my_user { >> user { $name: >> ... >> password => generate(''/site/bin/grabass.rb'', ''-u'', $name), >> } >> } > > I agree with this completely. > > Cheers, > Felix-- Jonathan Barber <jonathan.barber@gmail.com> -- 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.