Puppet Function: ip_is_me
- Defined in:
- lib/puppet/parser/functions/ip_is_me.rb
- Function type:
- Ruby 3.x API
Overview
Detect if an IP address is contained in the passed whitespace delimited
String
.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet/parser/functions/ip_is_me.rb', line 4 newfunction(:ip_is_me, :type => :rvalue, :doc => <<-EOM) do |args| Puppet::Parser::Functions.autoloader.load( File.(File.dirname(__FILE__) + '/host_is_me.rb') Detect if an IP address is contained in the passed whitespace delimited `String`. @return [Boolean] EOM ) require 'ipaddr' if args.class.eql?(Array) then f_args = args.dup else f_args = args.split(/\s/) end f_args << "127.0.0.1" f_args << "::1" f_args.delete_if { |x| retval=true begin IPAddr.new(x) rescue ArgumentError retval=false end retval } function_host_is_me(f_args) end |