From 651fe05d48395dc41a629de4567383db7c97fbb4 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Thu, 25 Apr 2013 15:18:34 +0200 Subject: [PATCH] Send update component request to proper master host --- .../static-mirroring/static-update-component} | 31 ++++++------------- modules/roles/manifests/static_source.pp | 2 +- 2 files changed, 10 insertions(+), 23 deletions(-) rename modules/roles/{templates/static-mirroring/static-update-component.erb => files/static-mirroring/static-update-component} (72%) diff --git a/modules/roles/templates/static-mirroring/static-update-component.erb b/modules/roles/files/static-mirroring/static-update-component similarity index 72% rename from modules/roles/templates/static-mirroring/static-update-component.erb rename to modules/roles/files/static-mirroring/static-update-component index 2f70cfbb7..7e8475455 100755 --- a/modules/roles/templates/static-mirroring/static-update-component.erb +++ b/modules/roles/files/static-mirroring/static-update-component @@ -41,15 +41,16 @@ if [ "${component%/*}" != "$component" ] ; then fi thishost=$(hostname -f) -srchost="$(awk -v component="$component" '$1 == component {print $2; exit}' "$componentlist")" -srcdir="$(awk -v component="$component" '$1 == component {print $3; exit}' "$componentlist")" +masterhost="$(awk -v component="$component" '$2 == component {print $1; exit}' "$componentlist")" +srchost="$(awk -v component="$component" '$2 == component {print $3; exit}' "$componentlist")" +srcdir="$(awk -v component="$component" '$2 == component {print $4; exit}' "$componentlist")" inextralist="$( awk -v component="$component" -v host="$thishost" ' - $1 == component { - split($4,extra,",") + $2 == component { + split($5,extra,",") for (i in extra) { if (host == extra[i]) { - printf "%s:%s\n", $2, $3 + printf "%s:%s\n", $3, $4 exit } } @@ -71,24 +72,10 @@ if [ "$srchost" = "$thishost" ] && ! [ -d "$srcdir" ]; then exit 1 fi -if [ "`id -nu`" != "staticsync" ]; then - sudo -u staticsync static-update-component "$@" +if [ "`id -nu`" != "staticsync" ] && [ "$masterhost" = "`hostname -f`" ]; then + static-update-component "$@" else - masters=() -<%= -lines = [] -masters = [] -scope.lookupvar('site::localinfo').keys.sort.each do |node| - if scope.lookupvar('site::localinfo')[node]['static_master'] - lines << " masters+=(\"#{node}\")" - end -end -lines.join("\n") -%> - - for master_idx in ${!masters[*]}; do - ssh -o AddressFamily=inet -t -o ServerAliveInterval=300 -o PreferredAuthentications=publickey "${masters[$master_idx]}" static-master-update-component "$component" - done + ssh -o AddressFamily=inet -t -o ServerAliveInterval=300 -o PreferredAuthentications=publickey "$masterhost" static-master-update-component "$component" fi # vim:set et: diff --git a/modules/roles/manifests/static_source.pp b/modules/roles/manifests/static_source.pp index dbdede186..81210e291 100644 --- a/modules/roles/manifests/static_source.pp +++ b/modules/roles/manifests/static_source.pp @@ -4,7 +4,7 @@ class roles::static_source { content => template('roles/static-mirroring/static-mirror-authorized_keys.erb'), } file { '/usr/local/bin/static-update-component': - content => template('roles/static-mirroring/static-update-component.erb'), + source => 'puppet:///modules/roles/static-mirroring/static-update-component', mode => '0555', } file { '/usr/local/bin/static-mirror-ssh-wrap': -- 2.20.1