Hi I would like to perform a simple host name lookup in a template: <% if dbname != "db1" %> master-host = %scope.getip(["db1.maxown.com"]) %> <% end -%> so far I have written a function # getip.rb module Puppet::Parser::Functions newfunction(:getip, :type => :rvalue) do |args| Puppet::Util.execute("/usr/bin/host", args[0]) end end However when I test this with test.pp: # test.pp $ip = Getip[''ec2-176-34-227-1.eu-west-1.compute.amazonaws.com''] notify { $ip: } The run puppet test.pp I get this notice: Getip[ec2-176-34-227-1.eu-west-1.compute.amazonaws.com] notice: /Stage[main]//Notify[Getip[ec2-176-34-227-1.eu- west-1.compute.amazonaws.com]]/message: defined ''message'' as ''Getip[ec2-176-34-227-1.eu-west-1.compute.amazonaws.com]'' notice: Finished catalog run in 0.02 seconds Should I write a Function to perform this simple task or is there a simpler/better way to go about this? TIA Shaun -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Fri, Dec 9, 2011 at 7:43 AM, shaunington <shaun.mccullagh@gmail.com> wrote:> $ip = Getip[''ec2-176-34-227-1.eu-west-1.compute.amazonaws.com'']Never used that syntax... I would try: $ip = getip(''ec2-176-34-227-1.eu-west-1.compute.amazonaws.com'') -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.