Skip to content

Instantly share code, notes, and snippets.

@binford2k
Last active December 26, 2015 19:59
Show Gist options
  • Save binford2k/7205269 to your computer and use it in GitHub Desktop.
Save binford2k/7205269 to your computer and use it in GitHub Desktop.
# BLOWS UP
require 'socket'
Puppet::Parser::Functions.newfunction(:mastername, :type => :rvalue ) do
Socket.gethostname.chomp
end
[root@classroom test]# puppet apply -e 'notice(mastername())'
Error: wrong number of arguments (1 for 0) at line 1 on node classroom.puppetlabs.vm
Wrapped exception:
wrong number of arguments (1 for 0)
Error: wrong number of arguments (1 for 0) at line 1 on node classroom.puppetlabs.vm
[root@classroom test]# puppet apply -e 'notice(mastername())' --trace
Error: wrong number of arguments (1 for 0) at line 1 on node classroom.puppetlabs.vm
/etc/puppetlabs/puppet/modules/test/lib/puppet/parser/functions/mastername.rb:6:in `block in <top (required)>'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/functions.rb:147:in `block (2 levels) in newfunction'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/functions.rb:140:in `block in newfunction'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/function.rb:42:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:25:in `block in evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:20:in `each'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:20:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/function.rb:37:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:15:in `block in evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:10:in `each'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:10:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/resource/type.rb:137:in `evaluate_code'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/resource.rb:81:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:312:in `evaluate_main'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:97:in `block in compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:97:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:29:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:86:in `block in compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:84:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:44:in `find'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/indirection.rb:197:in `find'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application/apply.rb:209:in `main'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application/apply.rb:151:in `run_command'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `block (2 levels) in run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:456:in `plugin_hook'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `block in run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util.rb:504:in `exit_on_fail'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/command_line.rb:132:in `run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/command_line.rb:86:in `execute'
/opt/puppet/bin/puppet:4:in `<main>'
Wrapped exception:
wrong number of arguments (1 for 0)
/etc/puppetlabs/puppet/modules/test/lib/puppet/parser/functions/mastername.rb:6:in `block in <top (required)>'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/functions.rb:147:in `block (2 levels) in newfunction'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/functions.rb:140:in `block in newfunction'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/function.rb:42:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:25:in `block in evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:20:in `each'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:20:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/function.rb:37:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:15:in `block in evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:10:in `each'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:10:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/resource/type.rb:137:in `evaluate_code'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/resource.rb:81:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:312:in `evaluate_main'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:97:in `block in compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:97:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:29:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:86:in `block in compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:84:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:44:in `find'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/indirection.rb:197:in `find'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application/apply.rb:209:in `main'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application/apply.rb:151:in `run_command'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `block (2 levels) in run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:456:in `plugin_hook'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `block in run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util.rb:504:in `exit_on_fail'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/command_line.rb:132:in `run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/command_line.rb:86:in `execute'
/opt/puppet/bin/puppet:4:in `<main>'
Error: wrong number of arguments (1 for 0) at line 1 on node classroom.puppetlabs.vm
/etc/puppetlabs/puppet/modules/test/lib/puppet/parser/functions/mastername.rb:6:in `block in <top (required)>'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/functions.rb:147:in `block (2 levels) in newfunction'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/functions.rb:140:in `block in newfunction'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/function.rb:42:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:25:in `block in evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:20:in `each'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/astarray.rb:20:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/function.rb:37:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:15:in `block in evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:10:in `each'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast/block_expression.rb:10:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/ast.rb:62:in `safeevaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/resource/type.rb:137:in `evaluate_code'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/resource.rb:81:in `evaluate'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:312:in `evaluate_main'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:97:in `block in compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:97:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/parser/compiler.rb:29:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:86:in `block in compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler/none.rb:6:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/profiler.rb:26:in `profile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:84:in `compile'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/catalog/compiler.rb:44:in `find'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/indirector/indirection.rb:197:in `find'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application/apply.rb:209:in `main'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application/apply.rb:151:in `run_command'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `block (2 levels) in run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:456:in `plugin_hook'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `block in run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util.rb:504:in `exit_on_fail'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/application.rb:364:in `run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/command_line.rb:132:in `run'
/opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/util/command_line.rb:86:in `execute'
/opt/puppet/bin/puppet:4:in `<main>'
# works
require 'socket'
Puppet::Parser::Functions.newfunction(:mastername, :type => :rvalue ) do |args|
Socket.gethostname.chomp
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment