From 72448a032742320723ff05d4f8bce90af08db3c9 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 17 Apr 2014 13:18:55 -0700 Subject: [PATCH] Further remote puppet fixes * We need to wrap the call to the shell function in quotes * if command instead of if ! command to fail on error * Be explicit about the delimiter to xargs * Actually, you know, put the m suffix on the timeout so it's not 30 seconds * Have a wrapper function that returns 0 for the parallel runs of all the puppet, otherwise xargs bails out Change-Id: I091e8f53093d358019ae03bfb330280ab8c7cd2e --- modules/openstack_project/manifests/params.pp | 2 +- .../templates/run_remote_puppet.sh.erb | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/openstack_project/manifests/params.pp b/modules/openstack_project/manifests/params.pp index 9350c6802a..06fe370d35 100644 --- a/modules/openstack_project/manifests/params.pp +++ b/modules/openstack_project/manifests/params.pp @@ -18,5 +18,5 @@ class openstack_project::params { fail("Unsupported osfamily: ${::osfamily} The 'openstack_project' module only supports osfamily Debian or RedHat (slaves only).") } } - $allowed_ssh_command = 'timeout -s 9 30 puppet agent --test' + $allowed_ssh_command = 'timeout -s 9 30m puppet agent --test' } diff --git a/modules/openstack_project/templates/run_remote_puppet.sh.erb b/modules/openstack_project/templates/run_remote_puppet.sh.erb index f4369a2c11..a13ac15f9a 100755 --- a/modules/openstack_project/templates/run_remote_puppet.sh.erb +++ b/modules/openstack_project/templates/run_remote_puppet.sh.erb @@ -16,14 +16,16 @@ # This function will properly fail if puppet is disabled on the target host function run_ssh { -ssh -o StrictHostKeyChecking=no root@$1 <%= scope.lookupvar('openstack_project::params::allowed_ssh_command') %> - ret=$? - # Did we timeout - if [ $ret = 124 ]; then - echo "TODO: Timeout instead of other failure. Report this differently." - fi - return $ret + echo ssh -o StrictHostKeyChecking=no root@$1 <%= scope.lookupvar('openstack_project::params::allowed_ssh_command') %> + ssh -o StrictHostKeyChecking=no root@$1 <%= scope.lookupvar('openstack_project::params::allowed_ssh_command') %> } +export -f run_ssh + +function brazenly_run_ssh { + run_ssh $1 + return 0 +} +export -f brazenly_run_ssh FULL_LIST=$(puppet cert list -a | grep '^\+' | awk '{print $2}' | sed 's/"//g') OVERRIDE_LIST=" @@ -42,11 +44,10 @@ cd /opt/config/production # Run things that need to be ordered for host in $OVERRIDE_LIST; do - if ! run_ssh $host ; then + if run_ssh $host ; then break fi done # Now, run everyone else -export -f run_ssh -echo $FILTERED_LIST | xargs -P 10 -n 1 bash -c run_ssh +echo $FILTERED_LIST | xargs -d' ' -P 10 -n 1 -I{} bash -c "brazenly_run_ssh {}"