# File lib/puppet/application/kick.rb, line 102
102:   def run_for_host(host)
103:     if options[:ping]
104:       out = %x{ping -c 1 #{host}}
105:       unless $CHILD_STATUS == 0
106:         $stderr.print "Could not contact #{host}\n"
107:         next
108:       end
109:     end
110: 
111:     require 'puppet/run'
112:     Puppet::Run.indirection.terminus_class = :rest
113:     port = Puppet[:puppetport]
114:     url = ["https://#{host}:#{port}", "production", "run", host].join('/')
115: 
116:     print "Triggering #{host}\n"
117:     begin
118:       run_options = {
119:         :tags => @tags,
120:         :background => ! options[:foreground],
121:         :ignoreschedules => options[:ignoreschedules]
122:       }
123:       run = Puppet::Run.new( run_options ).save( url )
124:       puts "Getting status"
125:       result = run.status
126:       puts "status is #{result}"
127:     rescue => detail
128:       puts detail.backtrace if Puppet[:trace]
129:       $stderr.puts "Host #{host} failed: #{detail}\n"
130:       exit(2)
131:     end
132: 
133:     case result
134:     when "success";
135:       exit(0)
136:     when "running"
137:       $stderr.puts "Host #{host} is already running"
138:       exit(3)
139:     else
140:       $stderr.puts "Host #{host} returned unknown answer '#{result}'"
141:       exit(12)
142:     end
143:   end