The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #15230

puppet variables function differently as define arguments

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

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

0%

Category:-
Target version:-
Affected Puppet version: Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

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:

!/usr/bin/puppet

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

}

works

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

History

#1 Updated by Nan Liu about 2 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 2 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