Class: Actions::Staypuft::Host::PuppetRun
- Inherits:
-
Dynflow::Action
- Object
- Dynflow::Action
- Actions::Staypuft::Host::PuppetRun
- Defined in:
- app/lib/actions/staypuft/host/puppet_run.rb
Instance Method Summary collapse
Instance Method Details
#plan(host) ⇒ Object
20 21 22 23 |
# File 'app/lib/actions/staypuft/host/puppet_run.rb', line 20 def plan(host) Type! host, ::Host::Base plan_self host_id: host.id, name: host.name end |
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/lib/actions/staypuft/host/puppet_run.rb', line 25 def run host = ::Host.find(input.fetch(:host_id)) # try puppetrun 3 times result = false tries = 0 while !result && tries < 3 result = host.puppetrun! tries += 1 output[:errors] = host.errors. unless result end # we need executed_at for both success and failure cases # to allow skipping of the action in case of failure output[:executed_at] = DateTime.now.iso8601 output[:tries] = tries output[:result] = result unless result fail(::Staypuft::Exception, "Puppet run failed for host: #{host.id}") end end |