fix template
authorPeter Palfrader <peter@palfrader.org>
Sat, 14 Feb 2015 14:11:57 +0000 (15:11 +0100)
committerPeter Palfrader <peter@palfrader.org>
Sat, 14 Feb 2015 14:11:57 +0000 (15:11 +0100)
modules/roles/templates/buildd_master_wb-authorized_keys.erb

index 67267c9..04f0c1e 100644 (file)
@@ -4,35 +4,36 @@
 
 <%=
 def getbuilddkey(host)
-    key = nil
-    begin
-        facts = YAML.load(File.open("/var/lib/puppet/yaml/facts/#{host}.yaml").read)
-        return facts.values['buildd_key']
-    rescue Exception => e
-    end
-    return key
+  key = nil
+  begin
+    facts = YAML.load(File.open("/var/lib/puppet/yaml/facts/#{host}.yaml").read)
+    return facts.values['buildd_key']
+  rescue Exception => e
+  end
+  return key
 end
 
 allnodeinfo = scope.lookupvar('site::allnodeinfo')
-roles = scope.lookupvar('site::roles')
+buildds = []
 
-mirrors = []
-roles['buildd'].each do |node|
-        key = getbuilddkey(node)
-        mirrors << { 'node' => node, 'addr' => allnodeinfo[node]['ipHostNumber'], 'key' => key}
+allnodeinfo.keys.sort.each do |node|
+  next unless scope.lookupvar('site::allnodeinfo')[node]['purpose']
+  next unless scope.lookupvar('site::allnodeinfo')[node]['purpose'].include?('buildd')
+  key = getbuilddkey(node)
+  buildds << { 'node' => node, 'addr' => allnodeinfo[node]['ipHostNumber'], 'key' => key}
 end
 
 lines = []
-for m in mirrors do
-    lines << '# ' + m['node']
-    if m['key'].nil?
-        lines << "# no key for node"
-    else
-        lines << "command=\"/srv/wanna-build/bin/wanna-build --ssh-wrapper  #{m['node']}\"," +
-                 'no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-user-rc,' +
-                 'from="' + m['addr'].join(',') + '" ' +
-                 m['key']
-    end
+for m in buildds do
+  lines << '# ' + m['node']
+  if m['key'].nil?
+    lines << "# no key for node"
+  else
+    lines << "command=\"/srv/wanna-build/bin/wanna-build --ssh-wrapper  #{m['node']}\"," +
+             'no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-user-rc,' +
+             'from="' + m['addr'].join(',') + '" ' +
+             m['key']
+  end
 end
 
 lines.join("\n")