Merge branch 'static'
authorPeter Palfrader <peter@palfrader.org>
Wed, 19 Dec 2012 21:38:15 +0000 (22:38 +0100)
committerPeter Palfrader <peter@palfrader.org>
Wed, 19 Dec 2012 21:38:15 +0000 (22:38 +0100)
* static:
  static-update-component planet
  static-update-component wrapper

Conflicts:
modules/roles/manifests/static_source.pp

modules/roles/manifests/static_source.pp
modules/roles/templates/static-mirroring/static-update-component.erb [new file with mode: 0755]
modules/sudo/files/sudoers

index 821a6cf..bf012a6 100644 (file)
@@ -3,6 +3,10 @@ class roles::static_source {
        file { '/etc/ssh/userkeys/staticsync':
                content => template('roles/static-mirroring/static-mirror-authorized_keys.erb'),
        }
+       file { '/usr/local/bin/static-mirror-ssh-wrap':
+               source  => "puppet:///modules/roles/static-mirroring/static-mirror-ssh-wrap",
+               mode    => '0555',
+       }
        file { '/usr/local/bin/static-mirror-ssh-wrap':
                source => 'puppet:///modules/roles/static-mirroring/static-mirror-ssh-wrap',
                mode   => '0555',
diff --git a/modules/roles/templates/static-mirroring/static-update-component.erb b/modules/roles/templates/static-mirroring/static-update-component.erb
new file mode 100755 (executable)
index 0000000..9844a5a
--- /dev/null
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+# Copyright (c) 2012 Peter Palfrader
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+componentlist=/etc/static-components.conf
+
+if [ "$#" != 1 ]; then
+  echo >&2 "Usage: $0 <component>"
+  exit 1
+fi
+
+component="$1"
+
+if [ "${component%/*}" != "$component" ] ; then
+  echo >&2 "$0: Invalid component: $component";
+  exit 1
+fi
+
+srchost="$(awk -v component="$component" '$1 == component {print $2; exit}' "$componentlist")"
+srcdir="$(awk -v component="$component" '$1 == component {print $3; exit}' "$componentlist")"
+if [ -z "$srchost" ] || [ -z "$srcdir" ]; then
+  echo >&2 "$0: Invalid component: $component (not found in $componentlist)";
+  exit 1
+fi
+
+if [ "$srchost" = "`hostname -f`" ]; then
+  src="$srcdir"
+else
+  echo >&2 "Component $component is sourced from $srchost, not this host."
+  exit 1
+fi
+
+if ! [ -d "$srcdir" ]; then
+  echo >&2 "Component source directory $srcdir does not exist or is not a directory, or is not accessible."
+  exit 1
+fi
+
+if [ "`id -nu`" != "staticsync" ]; then
+  sudo -u staticsync static-update-component "$component"
+else
+  masters=()
+<%=
+lines = []
+masters = []
+scope.lookupvar('site::localinfo').keys.sort.each do |node|
+    if scope.lookupvar('site::localinfo')[node]['static_master']
+        line << "masters+=(\"#{node}\"}"
+    end
+end
+lines.join("\n")
+%>
+
+  for master_idx in ${!masters[*]}; do
+    ssh "${masters[$master_idx]}" static-master-update-component "$component"
+  done
+fi
+
+# vim:set et:
+# vim:set ts=2:
+# vim:set shiftwidth=2:
+# vim:set syn=sh:
index c99334c..c2ffa8e 100644 (file)
@@ -125,6 +125,8 @@ dak         ALL=(dak-unpriv)        NOPASSWD: ALL
 Defaults:buildd env_reset,env_keep+="APT_CONFIG DEBIAN_FRONTEND"
 buildd         ALL=(ALL)               NOPASSWD: ALL
 
+%planet                senfl=(staticsync)      NOPASSWD: /usr/local/bin/static-update-component planet.debian.org
+
 # The piuparts slave needs to handle chroots
 piupartss      piatti=(ALL)            NOPASSWD: ALL
 # trigger of mirror run for packages