On 23 December 2010 09:30, Felix Frank <[email protected]> wrote:
> On 12/23/2010 12:42 AM, Jonathan Barber wrote:
>> On 22 December 2010 19:38, deet <[email protected]> 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/5259

Ah, 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 <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to