Issue #8066 has been updated by Gary Larizza.

I forgot to mention that this was in Puppet Enterprise 1.0, which is indeed 
2.6.4.  I'll have to upgrade and check in 2.6.5 or higher.
----------------------------------------
Bug #8066: Setting $name as a default value in a define results in 'main'
https://projects.puppetlabs.com/issues/8066

Author: Gary Larizza
Status: Unreviewed
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


This bug was found by a student named Dan in the Chicago Public Training this 
week.

If you create a defined resource type and set the default value of a parameter 
to $name, it will set the value to 'main' instead of the actual $name value.  
You CAN use $name in the body of the defined resource type, but setting it in 
the parameters results in 'main'.  See the sample code below:

##do_user.pp:

    define definition::do_user($gid=$name){
      notify {$name:
        message => "The Name is ${name} and GID is ${gid}.",
      }
    }

##init.pp

    definition::do_user{
      'wahoo':;
      'boohoo':
        gid => 'tada';
    }


This results in the following:

    info: Applying configuration version '1308797860'
    notice: The Name is wahoo and GID is main. 
    notice: /Stage[main]//Definition::Do_user[wahoo]/Notify[wahoo]/message: 
defined 'message' as 'The Name is wahoo and GID is main.'
    notice: The Name is boohoo and GID is tada.
    notice: /Stage[main]//Definition::Do_user[boohoo]/Notify[boohoo]/message: 
defined 'message' as 'The Name is boohoo and GID is tada.'

This, however, works properly:

##do_user.pp

    define definition::do_user(){
      $gid = $name
      notify {$name:
        message => "The Name is ${name} and GID is ${gid}.",
      }
    }

##init.pp

    definition::do_user{
      'wahoo':;
      'boohoo':;
    }

Result of the run:


    info: Applying configuration version '1308798227'
    notice: The Name is wahoo and GID is wahoo.
    notice: /Stage[main]//Definition::Do_user[wahoo]/Notify[wahoo]/message: 
defined 'message' as 'The Name is wahoo and GID is wahoo.'
    notice: The Name is boohoo and GID is boohoo.
    notice: /Stage[main]//Definition::Do_user[boohoo]/Notify[boohoo]/message: 
defined 'message' as 'The Name is boohoo and GID is boohoo.'



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" 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-bugs?hl=en.

Reply via email to