summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAJ Christensen <aj@junglist.gen.nz>2008-08-08 21:48:18 +1200
committerJames Turnbull <james@lovedthanlost.net>2008-08-17 14:26:58 +1000
commitb1ad596ec0aa3158d70f84d5b1e002f972d3ec71 (patch)
tree37ff59f09f688e9a397afc9eefee193d0f23d99e /bin
parent6676b6b104e3f60dd14be18cbfb91b4cd96ec06e (diff)
downloadpuppet-b1ad596ec0aa3158d70f84d5b1e002f972d3ec71.tar.gz
puppet-b1ad596ec0aa3158d70f84d5b1e002f972d3ec71.tar.xz
puppet-b1ad596ec0aa3158d70f84d5b1e002f972d3ec71.zip
Add the -P/--ping option to puppetrun, fixes #1501
Turns on the ICMP echo testing against the target host. Defaults to off. 111111111
Diffstat (limited to 'bin')
-rwxr-xr-xbin/puppetrun22
1 files changed, 15 insertions, 7 deletions
diff --git a/bin/puppetrun b/bin/puppetrun
index f1e30245b..f33c7f8a1 100755
--- a/bin/puppetrun
+++ b/bin/puppetrun
@@ -9,7 +9,7 @@
#
# puppetrun [-a|--all] [-c|--class <class>] [-d|--debug] [-f|--foreground]
# [-h|--help] [--host <host>] [--no-fqdn] [--ignoreschedules]
-# [-t|--tag <tag>] [--test]
+# [-t|--tag <tag>] [--test] [-p|--ping]
#
# = Description
#
@@ -108,6 +108,10 @@
# Print the hosts you would connect to but do not actually connect. This
# option requires LDAP support at this point.
#
+# ping::
+#
+# Do a ICMP echo against the target host. Skip hosts that don't respond to ping.
+#
# = Example
#
# sudo puppetrun -p 10 --host host1 --host host2 -t remotefile -t webserver
@@ -154,6 +158,7 @@ flags = [
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
[ "--host", GetoptLong::REQUIRED_ARGUMENT ],
[ "--parallel", "-p", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--ping", "-P", GetoptLong::NO_ARGUMENT ],
[ "--no-fqdn", "-n", GetoptLong::NO_ARGUMENT ],
[ "--test", GetoptLong::NO_ARGUMENT ],
[ "--version", "-V", GetoptLong::NO_ARGUMENT ]
@@ -168,6 +173,7 @@ options = {
:ignoreschedules => false,
:foreground => false,
:parallel => 1,
+ :ping => false,
:debug => false,
:test => false,
:all => false,
@@ -215,6 +221,8 @@ begin
$stderr.puts "Could not convert %s to an integer" % arg.inspect
exit(23)
end
+ when "--ping"
+ options[:ping] = true
when "--foreground"
options[:foreground] = true
when "--debug"
@@ -294,12 +302,12 @@ while go
if children.length < options[:parallel] and ! todo.empty?
host = todo.shift
pid = fork do
- # First make sure the client is up
- out = %x{ping -c 1 #{host}}
-
- unless $? == 0
- $stderr.print "Could not contact %s\n" % host
- next
+ if options[:ping]
+ out = %x{ping -c 1 #{host}}
+ unless $? == 0
+ $stderr.print "Could not contact %s\n" % host
+ next
+ end
end
client = Puppet::Network::Client.runner.new(
:Server => host,