From: Peter Palfrader Date: Sat, 14 Feb 2015 14:11:57 +0000 (+0100) Subject: fix template X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=4a66c3d9d40bfa56b2cea78eb2817ed124dcaab9;p=mirror%2Fdsa-puppet.git fix template --- diff --git a/modules/roles/templates/buildd_master_wb-authorized_keys.erb b/modules/roles/templates/buildd_master_wb-authorized_keys.erb index 67267c934..04f0c1e71 100644 --- a/modules/roles/templates/buildd_master_wb-authorized_keys.erb +++ b/modules/roles/templates/buildd_master_wb-authorized_keys.erb @@ -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")