plathrop (owner)

Revisions

gist: 226549 Download_button fork
public
Public Clone URL: git://gist.github.com/226549.git
Embed All Files: show embed
/var/lib/puppet/lib/parser/functions/sha_passwd.rb #
1
2
3
4
5
6
7
8
9
require 'sha1'
require 'base64'
 
module Puppet::Parser::Functions
    newfunction(:sha_passwd, :type => :rvalue) do |args|
        "{SHA}"+Base64.encode64(Digest::SHA1.digest(args[0])).chomp!
    end
end
 
irb session #
1
2
3
4
5
6
7
8
9
10
11
12
s0005:/var/lib/puppet/lib/parser/functions# irb
irb(main):001:0> require 'puppet'
=> true
irb(main):002:0> require 'sha_passwd'
=> []
irb(main):003:0> scope = Puppet::Parser::Scope.new()
=> #<Puppet::Parser::Scope:0x7f7e891a80b0 @ephemeral={}, @defaults={}, @tags=[], @namespaces=[""], @symtable={}>
irb(main):004:0> Puppet::Parser::Functions.function("sha_passwd")
=> "function_sha_passwd"
irb(main):005:0> scope.function_sha_passwd(["foo"])
=> "{SHA}C+7Hteo/D9vJXQ3UfzxbwnXaijM="
 
puppetmasterd --verbose --debug --trace --no-daemonize #
1
2
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
debug: Allowing authenticated client lun0057.digg.internal(10.2.128.71) access to puppetmaster.getconfig
debug: Our client is remote
info: Expiring the node cache of lun0057.digg.internal
info: Not using expired node for lun0057.digg.internal from cache; expired at Wed Nov 04 16:26:27 -0800 2009
info: Caching node for lun0057.digg.internal
debug: importing '/srv/puppet/production/manifests/variables.pp'
debug: importing '/srv/puppet/production/manifests/production-nodes.pp'
debug: importing '/srv/puppet/production/manifests/prodtest-nodes.pp'
debug: importing '/srv/puppet/production/manifests/development-nodes.pp'
debug: Adding code to main on line 38 in file /srv/puppet/production/manifests/site.pp
/usr/lib/ruby/1.8/puppet/parser/ast/function.rb:17:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/vardef.rb:17:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect'
/usr/lib/ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate'
/usr/lib/ruby/1.8/puppet/parser/ast/hostclass.rb:82:in `evaluate_code'
/usr/lib/ruby/1.8/puppet/parser/resource.rb:73:in `evaluate'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:313:in `evaluate_main'
/usr/lib/ruby/1.8/puppet/parser/compiler.rb:92:in `compile'
/usr/lib/ruby/1.8/puppet/parser/interpreter.rb:29:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:88:in `compile'
/usr/lib/ruby/1.8/puppet/util.rb:177:in `benchmark'
/usr/share/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'
/usr/lib/ruby/1.8/puppet/util.rb:176:in `benchmark'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:86:in `compile'
/usr/lib/ruby/1.8/puppet/indirector/catalog/compiler.rb:35:in `find'
/usr/lib/ruby/1.8/puppet/indirector/indirection.rb:198:in `find'
/usr/lib/ruby/1.8/puppet/indirector.rb:51:in `find'
/usr/lib/ruby/1.8/puppet/network/handler/master.rb:65:in `getconfig'
/usr/share/rails/activerecord/lib/../../activesupport/lib/active_support/inflector.rb:283:in `to_proc'
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:52:in `call'
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:52:in `protect_service'
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:85:in `setup_processor'
/usr/lib/ruby/1.8/xmlrpc/server.rb:336:in `call'
/usr/lib/ruby/1.8/xmlrpc/server.rb:336:in `dispatch'
/usr/lib/ruby/1.8/xmlrpc/server.rb:323:in `each'
/usr/lib/ruby/1.8/xmlrpc/server.rb:323:in `dispatch'
/usr/lib/ruby/1.8/xmlrpc/server.rb:366:in `call_method'
/usr/lib/ruby/1.8/xmlrpc/server.rb:378:in `handle'
/usr/lib/ruby/1.8/puppet/network/xmlrpc/processor.rb:44:in `process'
/usr/lib/ruby/1.8/puppet/network/xmlrpc/webrick_servlet.rb:68:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/puppet/network/http/webrick.rb:45:in `listen'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `call'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/usr/lib/ruby/1.8/puppet/network/http/webrick.rb:42:in `listen'
/usr/lib/ruby/1.8/puppet/network/http/webrick.rb:41:in `initialize'
/usr/lib/ruby/1.8/puppet/network/http/webrick.rb:41:in `new'
/usr/lib/ruby/1.8/puppet/network/http/webrick.rb:41:in `listen'
/usr/lib/ruby/1.8/puppet/network/http/webrick.rb:38:in `synchronize'
/usr/lib/ruby/1.8/puppet/network/http/webrick.rb:38:in `listen'
/usr/lib/ruby/1.8/puppet/network/server.rb:131:in `listen'
/usr/lib/ruby/1.8/puppet/network/server.rb:146:in `start'
/usr/lib/ruby/1.8/puppet/daemon.rb:128:in `start'
/usr/lib/ruby/1.8/puppet/application/puppetmasterd.rb:122:in `main'
/usr/lib/ruby/1.8/puppet/application.rb:226:in `send'
/usr/lib/ruby/1.8/puppet/application.rb:226:in `run_command'
/usr/lib/ruby/1.8/puppet/application.rb:217:in `run'
/usr/lib/ruby/1.8/puppet/application.rb:306:in `exit_on_fail'
/usr/lib/ruby/1.8/puppet/application.rb:217:in `run'
/usr/sbin/puppetmasterd:66
err: Unknown function sha_passwd at /srv/puppet/production/manifests/variables.pp:19 on node lun0057.digg.internal