Sha256: 694604a7154d07e9846b8dac880ce50863ef239e96446f796015db3e2f398b73
Contents?: true
Size: 1.59 KB
Versions: 9
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true module Actions module ForemanAcd # DeployAllHosts implements a Foreman Task EntryAction class DeployAllHosts < Actions::EntryAction def plan(app_instance, safe_deploy) action_subject(app_instance, :safe_deploy => safe_deploy) plan_self(:id => app_instance.id) end def run output[:status] = 'IN PROGRESS' app_instance = ::ForemanAcd::AppInstance.find(input.fetch(:id)) safe_deploy = input.fetch(:safe_deploy) # Goal: all, safe_deploy or nothing begin if safe_deploy ::Foreman::Logging.logger('foreman_acd').info "Start to safe deploy hosts of the app #{app_instance}" else ::Foreman::Logging.logger('foreman_acd').info "Start to deploy all hosts of the app #{app_instance}" end app_deployer = ::ForemanAcd::AppDeployer.new(app_instance) output[:data] = app_deployer.deploy(safe_deploy) output[:status] = 'SUCCESS' rescue StandardError => e ::Foreman::Logging.logger('foreman_acd').error "Error while deploying hosts for application instance '#{app_instance.name}'. Clean up all other hosts: #{e}" app_instance.clean_all_hosts output[:status] = 'FAILURE' raise "Error while deploying hosts for application instance '#{app_instance.name}': (#{e.message})" end end def finalize; end def rescue_strategy Dynflow::Action::Rescue::Fail end def humanized_name _('Deploy application instance hosts') end end end end
Version data entries
9 entries across 9 versions & 1 rubygems