Method: Actions::ForemanPatch::Invocation::Action#plan

Defined in:
app/lib/actions/foreman_patch/invocation/action.rb

#plan(host, feature_name, required = true, **input_values) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/lib/actions/foreman_patch/invocation/action.rb', line 41

def plan(host, feature_name, required = true, **input_values)
  action_subject(host, feature_name: feature_name, required: required, **input_values)

  invocation = TemplateInvocation.new(template, **input_values)

  provider = template.provider
  proxy_selector = provider.required_proxy_selector_for(template) || ::RemoteExecutionProxySelector.new

  proxy = proxy_selector.determine_proxy(host, template.provider_type.to_s)

  renderer = InputTemplateRenderer.new(template, host, invocation)
  script = renderer.render
  raise _('Failed rendering template: %s') % renderer.error_message unless script

  additional_options = {
    hostname: provider.find_ip_or_hostname(host),
    execution_timeout_interval: template.execution_timeout_interval,
    script: script,
    secrets: provider.secrets(host),
  }
  action_options = provider.proxy_command_options(invocation, host).merge(additional_options)

  sequence do
    plan_delegated_action(proxy, provider.proxy_action_class, action_options)
    plan_self
  end
end