Puppet Function: validate_sysctl_value
- Defined in:
- lib/puppet/parser/functions/validate_sysctl_value.rb
- Function type:
- Ruby 3.x API
Overview
Validate that the passed value is correct for the passed
sysctl
key.
If a key is not known, simply returns that the value is valid.
3 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 36 37 38 39 |
# File 'lib/puppet/parser/functions/validate_sysctl_value.rb', line 3 newfunction(:validate_sysctl_value, :arity => 2, :doc => <<-ENDHEREDOC) do |args| # BEGIN: recognized value methods Validate that the passed value is correct for the passed `sysctl` key. If a key is not known, simply returns that the value is valid. @example validate_sysctl_value('kernel.core_pattern','some_random_pattern %p') @return [Nil] ENDHEREDOC def self.kernel__core_pattern(val) method = 'kernel.core_pattern' if val.length > 128 then raise(Puppet::Error,"Values for #{method} must be less than 129 characters") end if val =~ /\|\s*(.*)/ then begin function_validate_absolute_path([$1]) rescue(Puppet::Error) raise(Puppet::Error,"Piped commands for #{method} must have an absolute path") end end end # END: recognized value methods # Need the 'validate_absolute_path' function from stdlib. Puppet::Parser::Functions.autoloader.loadall key = args[0].to_s.gsub('.','__') val = args[1].to_s self.send(key,val) if self.respond_to?(key) end |