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

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 https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Bug #17434

Specifying explicit top scope for variable will return local value if the variable has no value at top scope

Added by Nick Fagerlund over 3 years ago. Updated about 3 years ago.

Status:ClosedStart date:
Priority:ImmediateDue date:
Assignee:Patrick Carlisle% Done:

0%

Category:-
Target version:1.2.0
Keywords:backlog Affected Hiera Version:
Branch:https://github.com/puppetlabs/hiera/pull/116

We've Moved!

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


Description

In Puppet, $module_name is a local variable with no value at top scope. But interpolating %{::module_name} from Hiera will get the local value instead of the empty string it should get.

# /var/lib/hiera
---
test_parser_vars: "module_name is %{::module_name}"

# $modulepath/hiera_test/init.pp
class hiera_test {
  notify {'test notice':
    message => hiera('test_parser_vars'),
  }
  notify {'other test':
    message => "Testing module name scope. top: ${::module_name} local: ${module_name}"
  }
}

nick@magpie:~/.puppet/hieradata$ puppet apply -e 'include hiera_test'
Testing module name scope. top:  local: hiera_test
/Stage[main]/Hiera_test/Notify[other test]/message: defined 'message' as 'Testing module name scope. top:  local: hiera_test'
module_name is hiera_test
/Stage[main]/Hiera_test/Notify[test notice]/message: defined 'message' as 'module_name is hiera_test
Finished catalog run in 0.19 seconds

%{::something} in Hiera should always get the same value that $::something does in Puppet; this test shows that it doesn’t do that.

Tested w/ Puppet 3.0.1-ish and Hiera 1.1.0.


Related issues

Related to Hiera - Bug #17433: Interpolating local variable blocks future interpolation ... In Topic Branch Pending Review
Related to Hiera - Bug #20642: 1.1.2 -> 1.2.1 breaks hierachy specified at node level Rejected

History

#1 Updated by Patrick Carlisle about 3 years ago

  • Status changed from Unreviewed to Accepted
  • Assignee set to Patrick Carlisle

#2 Updated by Patrick Carlisle about 3 years ago

  • Status changed from Accepted to In Topic Branch Pending Review

https://github.com/puppetlabs/hiera/pull/114

I think I’ve fixed this by reverting https://github.com/puppetlabs/hiera/pull/29. As far as I can tell, this was an attempt to squash our (buggy, now fixed) deprecation warning based on the misunderstanding that using :: was just another style of accessing variables, rather than having important and distinct semantics. Does this seem consistent to you, nick?

#3 Updated by Patrick Carlisle about 3 years ago

When this is reviewed i’d appreciate some serious check of my logic. I found this code hard to follow and I’m not sure I’m not breaking something.

#4 Updated by Anonymous about 3 years ago

  • Priority changed from Normal to Immediate

#5 Updated by Anonymous about 3 years ago

  • Keywords set to backlog

#6 Updated by Anonymous about 3 years ago

  • Branch set to https://github.com/puppetlabs/hiera/pull/116

I’ve built on top of Patrick’s revert and added a slew of tests around the desired behavior. https://github.com/puppetlabs/hiera/pull/116

#7 Updated by eric sorenson about 3 years ago

  • Target version set to 1.2.0

Pulling this back in for 1.2.0.

#8 Updated by Patrick Carlisle about 3 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

Merged in fd2209d

#9 Updated by Matthaus Owens about 3 years ago

  • Status changed from Merged - Pending Release to Closed

Released in Hiera 1.2.0

Also available in: Atom PDF