bin/puppetrun in puppet-0.24.5 vs bin/puppetrun in puppet-0.24.6

- old
+ new

@@ -7,11 +7,11 @@ # # = Usage # # 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 # # This script can be used to connect to a set of machines running +puppetd+ # and trigger them to run their configurations. The most common usage would @@ -106,10 +106,14 @@ # # test:: # 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 # # = Author @@ -152,10 +156,11 @@ [ "--foreground", "-f", GetoptLong::NO_ARGUMENT ], [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], [ "--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 ] ] @@ -166,10 +171,11 @@ options = { :ignoreschedules => false, :foreground => false, :parallel => 1, + :ping => false, :debug => false, :test => false, :all => false, :verbose => true, :fqdn => true @@ -213,10 +219,12 @@ options[:parallel] = Integer(arg) rescue $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" options[:debug] = true else @@ -235,11 +243,11 @@ end # Now parse the config Puppet.parse_config -if Puppet[:node_terminus] = "ldap" +if Puppet[:node_terminus] == "ldap" and (options[:all] or classes) if options[:all] hosts = Puppet::Node.search("whatever").collect { |node| node.name } puts "all: %s" % hosts.join(", ") else hosts = [] @@ -292,15 +300,15 @@ # If we don't have enough children in process and we still have hosts left to # do, then do the next host. 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, :Port => Puppet[:puppetport] )