]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/roles/templates/ssh_upload_buildd-uploader-authorized_keys.erb
add ssh-wrapper + userkeys config for buildd rsync uploads
[dsa-puppet.git] / modules / roles / templates / ssh_upload_buildd-uploader-authorized_keys.erb
1 ##
2 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
3 ##
4
5 <%=
6 def getbuilddkey(host)
7   key = nil
8   begin
9     facts = YAML.load(File.open("/var/lib/puppet/yaml/facts/#{host}.yaml").read)
10     return facts.values['buildd_key']
11   rescue Exception => e
12   end
13   return key
14 end
15
16 allnodeinfo = scope.lookupvar('site::allnodeinfo')
17 buildds = []
18
19 allnodeinfo.keys.sort.each do |node|
20   next unless scope.lookupvar('site::allnodeinfo')[node]['purpose']
21   next unless scope.lookupvar('site::allnodeinfo')[node]['purpose'].include?('buildd')
22   key = getbuilddkey(node)
23   buildds << { 'node' => node, 'addr' => allnodeinfo[node]['ipHostNumber'], 'key' => key}
24 end
25
26 lines = []
27 for m in buildds do
28   lines << '# ' + m['node']
29   if m['key'].nil?
30     lines << "## no key for node"
31   else
32     lines << "command=\"/home/buildd-uploader/rsync-ssh-wrap #{m['node'].split('.')[0]}\"," +
33              'no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-user-rc,' +
34              'from="' + m['addr'].join(',') + '" ' +
35              m['key']
36   end
37 end
38
39 lines.join("\n")
40 # vim:set et:
41 # vim:set sts=4 ts=4:
42 # vim:set shiftwidth=4:
43 %>