From: Peter Palfrader Date: Sun, 9 Dec 2012 11:30:43 +0000 (+0100) Subject: Move static-mirroring templates into their own dir X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=3693942d822dc7a6428525a84d994d5338a34fc0;p=mirror%2Fdsa-puppet.git Move static-mirroring templates into their own dir --- diff --git a/modules/roles/manifests/static_master.pp b/modules/roles/manifests/static_master.pp index e1d61a141..df11d6a42 100644 --- a/modules/roles/manifests/static_master.pp +++ b/modules/roles/manifests/static_master.pp @@ -1,7 +1,7 @@ class roles::static_master inherits roles::static_base { file { '/etc/ssh/userkeys/staticsync': - content => template('roles/static-master-authorized_keys.erb'), + content => template('roles/static-mirroring/static-master-authorized_keys.erb'), ; '/usr/local/bin/static-master-run': source => "puppet:///modules/roles/static-mirroring/static-master-run", @@ -17,7 +17,7 @@ class roles::static_master inherits roles::static_base { ; '/etc/static-clients.conf': - content => template('roles/static-clients.conf.erb'), + content => template('roles/static-mirroring/static-clients.conf.erb'), ; } } diff --git a/modules/roles/manifests/static_source.pp b/modules/roles/manifests/static_source.pp index a3b61034b..e44624b99 100644 --- a/modules/roles/manifests/static_source.pp +++ b/modules/roles/manifests/static_source.pp @@ -1,7 +1,7 @@ class roles::static_source inherits roles::static_base { file { '/etc/ssh/userkeys/staticsync': - content => template('roles/static-mirror-authorized_keys.erb'), + content => template('roles/static-mirroring/static-mirror-authorized_keys.erb'), ; '/usr/local/bin/static-mirror-ssh-wrap': source => "puppet:///modules/roles/static-mirroring/static-mirror-ssh-wrap", diff --git a/modules/roles/templates/static-clients.conf.erb b/modules/roles/templates/static-clients.conf.erb deleted file mode 100644 index edbf31365..000000000 --- a/modules/roles/templates/static-clients.conf.erb +++ /dev/null @@ -1,19 +0,0 @@ -## -## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. -## - -<%= - -mirrors = [] -scope.lookupvar('site::localinfo').keys.sort.each do |node| - if scope.lookupvar('site::localinfo')[node]['static_mirror'] - mirrors << node - end -end - - -mirrors.join("\n") -# vim:set et: -# vim:set sts=4 ts=4: -# vim:set shiftwidth=4: -%> diff --git a/modules/roles/templates/static-master-authorized_keys.erb b/modules/roles/templates/static-master-authorized_keys.erb deleted file mode 100644 index 9d01eef2f..000000000 --- a/modules/roles/templates/static-master-authorized_keys.erb +++ /dev/null @@ -1,42 +0,0 @@ -## -## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. -## - -<%= -def getstaticsynckey(host) - key = nil - begin - facts = YAML.load(File.open("/var/lib/puppet/yaml/facts/#{host}.yaml").read) - return facts.values['staticsync_key'] - rescue Exception => e - end - return key -end - -mirrors = [] -scope.lookupvar('site::localinfo').keys.sort.each do |node| - if scope.lookupvar('site::localinfo')[node]['static_mirror'] or scope.lookupvar('site::localinfo')[node]['static_source'] - key = getstaticsynckey(node) - mirrors << { 'node' => node, 'addr' => scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'], 'key' => key} - end -end - - -lines = [] -for m in mirrors: - lines << '# ' + m['node'] - if m['key'].nil? - lines << "# no key for node" - else - lines << "command=\"/usr/local/bin/static-master-ssh-wrap #{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") -# vim:set et: -# vim:set sts=4 ts=4: -# vim:set shiftwidth=4: -%> diff --git a/modules/roles/templates/static-mirror-authorized_keys.erb b/modules/roles/templates/static-mirror-authorized_keys.erb deleted file mode 100644 index 74bb7d597..000000000 --- a/modules/roles/templates/static-mirror-authorized_keys.erb +++ /dev/null @@ -1,42 +0,0 @@ -## -## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. -## - -<%= -def getstaticsynckey(host) - key = nil - begin - facts = YAML.load(File.open("/var/lib/puppet/yaml/facts/#{host}.yaml").read) - return facts.values['staticsync_key'] - rescue Exception => e - end - return key -end - -masters = [] -scope.lookupvar('site::localinfo').keys.sort.each do |node| - if scope.lookupvar('site::localinfo')[node]['static_master'] - key = getstaticsynckey(node) - masters << { 'node' => node, 'addr' => scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'], 'key' => key} - end -end - - -lines = [] -for m in masters: - lines << '# ' + m['node'] - if m['key'].nil? - lines << "# no key for node" - else - lines << "command=\"/usr/local/bin/static-mirror-ssh-wrap /srv/static.debian.org #{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") -# vim:set et: -# vim:set sts=4 ts=4: -# vim:set shiftwidth=4: -%> diff --git a/modules/roles/templates/static-mirroring/static-clients.conf.erb b/modules/roles/templates/static-mirroring/static-clients.conf.erb new file mode 100644 index 000000000..edbf31365 --- /dev/null +++ b/modules/roles/templates/static-mirroring/static-clients.conf.erb @@ -0,0 +1,19 @@ +## +## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. +## + +<%= + +mirrors = [] +scope.lookupvar('site::localinfo').keys.sort.each do |node| + if scope.lookupvar('site::localinfo')[node]['static_mirror'] + mirrors << node + end +end + + +mirrors.join("\n") +# vim:set et: +# vim:set sts=4 ts=4: +# vim:set shiftwidth=4: +%> diff --git a/modules/roles/templates/static-mirroring/static-master-authorized_keys.erb b/modules/roles/templates/static-mirroring/static-master-authorized_keys.erb new file mode 100644 index 000000000..9d01eef2f --- /dev/null +++ b/modules/roles/templates/static-mirroring/static-master-authorized_keys.erb @@ -0,0 +1,42 @@ +## +## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. +## + +<%= +def getstaticsynckey(host) + key = nil + begin + facts = YAML.load(File.open("/var/lib/puppet/yaml/facts/#{host}.yaml").read) + return facts.values['staticsync_key'] + rescue Exception => e + end + return key +end + +mirrors = [] +scope.lookupvar('site::localinfo').keys.sort.each do |node| + if scope.lookupvar('site::localinfo')[node]['static_mirror'] or scope.lookupvar('site::localinfo')[node]['static_source'] + key = getstaticsynckey(node) + mirrors << { 'node' => node, 'addr' => scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'], 'key' => key} + end +end + + +lines = [] +for m in mirrors: + lines << '# ' + m['node'] + if m['key'].nil? + lines << "# no key for node" + else + lines << "command=\"/usr/local/bin/static-master-ssh-wrap #{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") +# vim:set et: +# vim:set sts=4 ts=4: +# vim:set shiftwidth=4: +%> diff --git a/modules/roles/templates/static-mirroring/static-mirror-authorized_keys.erb b/modules/roles/templates/static-mirroring/static-mirror-authorized_keys.erb new file mode 100644 index 000000000..74bb7d597 --- /dev/null +++ b/modules/roles/templates/static-mirroring/static-mirror-authorized_keys.erb @@ -0,0 +1,42 @@ +## +## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE. +## + +<%= +def getstaticsynckey(host) + key = nil + begin + facts = YAML.load(File.open("/var/lib/puppet/yaml/facts/#{host}.yaml").read) + return facts.values['staticsync_key'] + rescue Exception => e + end + return key +end + +masters = [] +scope.lookupvar('site::localinfo').keys.sort.each do |node| + if scope.lookupvar('site::localinfo')[node]['static_master'] + key = getstaticsynckey(node) + masters << { 'node' => node, 'addr' => scope.lookupvar('site::allnodeinfo')[node]['ipHostNumber'], 'key' => key} + end +end + + +lines = [] +for m in masters: + lines << '# ' + m['node'] + if m['key'].nil? + lines << "# no key for node" + else + lines << "command=\"/usr/local/bin/static-mirror-ssh-wrap /srv/static.debian.org #{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") +# vim:set et: +# vim:set sts=4 ts=4: +# vim:set shiftwidth=4: +%>