Issue #12904 has been updated by Patrick Carlisle.

Status changed from Unreviewed to Needs More Information

What is the exact error? Can you paste output when run with --debug?
----------------------------------------
Bug #12904: Deprecation warning about var not being fully qualified, yet it is 
local to scope of block in ERB
https://projects.puppetlabs.com/issues/12904#change-56759

Author: Joe McDonagh
Status: Needs More Information
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


Take this code example:

<pre>
   &lt;Proxy balancer://lpm/&gt;
<% scope.function_getinfo('Class', 'berkleemedia::lpm', 'fqdn').each do |host| 
-%>
      BalancerMember http://<%= host -%> retry=1
<% end -%>
      ProxySet lbmethod=byrequests
      SetEnv force-proxy-request-1.0 1
      SetEnv proxy-nokeepalive 1
   &lt;/Proxy&gt;
</pre>

I'm getting deprecations warnings that "host" isn't fully qualified, which is 
really weird since its scope is just in that block. Not sure if this matters 
but here is the custom function getinfo code:

<pre>
require 'puppet/rails'
require 'puppet/rails/fact_value'

module Puppet::Parser::Functions
  newfunction(:getinfo,
  :type => :rvalue,
  :doc => "This is a function that will return an array of information based
  on what you ask for. For example this call:
  
    getinfo('Class', 'httpd', 'ec2_public_ipv4')
  
  will return a list of the ec2_public_ipv4 fact values for any node that has
  the resource Class['httpd']. If you leave off the third argument, fqdn will be
  assumed. Also note you can pass an environment to this function, but likely
  you won't need to because by default it will find the node's environment and
  use that. ") do |args|

    resource_type = args[0]
    resource_title  = args[1]
    return_info = args[2]
    environment = args[3]

    return_info ||= "fqdn"
    environment ||= lookupvar("::environment")

    raise Puppet::ParseError, ("getinfo(): wrong number of arguments 
(#{args.length}; must be >= 2)") if args.length < 2

    info = [ ]

    info = Puppet::Rails::FactValue.find_by_sql("
             SELECT fv.value from fact_values fv, fact_names fn, resources r, 
hosts h
             WHERE fn.name = '#{return_info}'
               AND h.environment = '#{environment}'
               AND h.id = r.host_id
               AND r.restype = '#{resource_type}'
               AND r.title = '#{resource_title}'
               AND fv.host_id = h.id
               AND fv.fact_name_id = fn.id;
           ")

    info.map! { |i| i.value }

    info
  end
end
</pre>


-- 
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