The Puppet Labs Issue Tracker has Moved:

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using See the following page for information on filing tickets with JIRA:

Bug #15230

puppet variables function differently as define arguments

Added by James Shubin over 3 years ago. Updated about 3 years ago.

Status:RejectedStart date:06/26/2012
Priority:NormalDue date:
Assignee:-% Done:


Target version:-
Affected Puppet version: Branch:

We've Moved!

Ticket tracking is now hosted in JIRA:


Puppet code and variables have no “order”. This allows you to do clever things in puppet, which is why it is elegant. This doesn’t seem to apply fully to define variables. All of the following examples should work, but only #3 does. Example code below:


this doesn’t work

define smart_define1(

    $foo = ['bar', "name=${bar}"],
    $bar = 'something',

) {

    notice $foo


define smart_define2(

    $foo = ['bar', "name=${cooltest}"],

) {

    notice $foo

    #$cooltest = "doesn't work: ${name}"    # this doesn't work
    $cooltest = 'this does not work!'       # this doesn't work



define smart_define3(

    $foo = ['bar', "name=${name}"],

) {

    notice $foo


smart_define3 { ‘thisisaname’:


HTH, James

d.pp - The example code shown in description. (446 Bytes) James Shubin, 06/26/2012 09:01 am


#1 Updated by Nan Liu over 3 years ago

Variables are order dependent. The example below $var will be :undef.

$var = $foo
$foo = 1

The behavior you are requesting won’t be available until futures is implemented in puppet.

#2 Updated by eric sorenson about 3 years ago

  • Status changed from Unreviewed to Rejected

Closing, as Nan said this may come up as a result of a larger rewrite.

Also available in: Atom PDF