Module: Puppet::Util::HostProp
- Defined in:
- lib/puppet/util/host_prop.rb
Overview
defines a shortcut to create properties with a single IP address or hostname as value
Instance Method Summary collapse
Instance Method Details
#newhostprop(name, options = {}, &block) ⇒ Object
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 36 |
# File 'lib/puppet/util/host_prop.rb', line 7 def newhostprop(name, = {}, &block) newproperty(name, ) do # TODO: We should replace this here with a proper Class # the current handling is just bad include Puppet::Util::NetworkDevice::IPCalc newvalues(:absent, /^((([a-z]|[0-9]|\-)+)\.)+([a-z])+$/i) validate do |value| return true if value == :absent return true if parse(value) return true if (/^((([a-z]|[0-9]|\-)+)\.)+([a-z])+$/i).match value self.fail "Invalid Hostname: #{value.inspect}" end munge do |value| if value == :absent :absent elsif parse(value) parse(value)[1] else value end end class_eval(&block) if block end end |