Module: ForemanAnsible::Concerns::JobInvocationHelper

Extended by:
ActiveSupport::Concern
Included in:
Api::V2::HostgroupsControllerExtensions, Api::V2::HostsControllerExtensions, HostgroupsControllerExtensions, HostsControllerExtensions
Defined in:
app/controllers/foreman_ansible/concerns/job_invocation_helper.rb

Overview

Helpers to compose the JobInvocation in other controllers

Instance Method Summary collapse

Instance Method Details

#job_composer(feature_name, target) ⇒ Object

Raises:

  • (::Foreman::Exception)


9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/foreman_ansible/concerns/job_invocation_helper.rb', line 9

def job_composer(feature_name, target)
  composer = ::JobInvocationComposer.for_feature(feature_name, target)
  return composer if composer.save
  msg = if target.blank?
          N_('There are no Ansible roles to play')
        else
          format(N_('Could not run Ansible roles for %{host}'),
                 :host => target)
        end
  raise ::Foreman::Exception.new(msg)
end