class Proxy::Ansible::RemoteExecutionCore::AnsibleRunner

Takes an inventory and runs it through REXCore CommandRunner

Constants

CONNECTION_PROMPT
DEFAULT_REFRESH_INTERVAL

Public Class Methods

new(options, suspended_action:) click to toggle source
Calls superclass method
# File lib/smart_proxy_ansible/remote_execution_core/ansible_runner.rb, line 12
def initialize(options, suspended_action:)
  super(options, :suspended_action => suspended_action)
  @playbook_runner = Proxy::Ansible::Runner::Playbook.new(
    options['ansible_inventory'],
    options['script'],
    options,
    :suspended_action => suspended_action
  )
end

Public Instance Methods

fill_continuous_output(continuous_output) click to toggle source
# File lib/smart_proxy_ansible/remote_execution_core/ansible_runner.rb, line 33
def fill_continuous_output(continuous_output)
  delegated_output.fetch('result', []).each do |raw_output|
    continuous_output.add_raw_output(raw_output)
  end
rescue StandardError => e
  continuous_output.add_exception(_('Error loading data from proxy'), e)
end
kill() click to toggle source
# File lib/smart_proxy_ansible/remote_execution_core/ansible_runner.rb, line 49
def kill
  publish_exit_status(1)
  ::Process.kill('SIGTERM', @command_pid)
  close
end
refresh() click to toggle source
Calls superclass method
# File lib/smart_proxy_ansible/remote_execution_core/ansible_runner.rb, line 41
def refresh
  @command_out = @playbook_runner.command_out
  @command_in = @playbook_runner.command_in
  @command_pid = @playbook_runner.command_pid
  super
  kill if unknown_host_key_fingerprint?
end
start() click to toggle source
# File lib/smart_proxy_ansible/remote_execution_core/ansible_runner.rb, line 22
def start
  @playbook_runner.logger = logger
  @playbook_runner.start
rescue StandardError => e
  logger.error(
    'error while initalizing command'\
    " #{e.class} #{e.message}:\n #{e.backtrace.join("\n")}"
  )
  publish_exception('Error initializing command', e)
end

Private Instance Methods

unknown_host_key_fingerprint?() click to toggle source
# File lib/smart_proxy_ansible/remote_execution_core/ansible_runner.rb, line 57
def unknown_host_key_fingerprint?
  last_output = @continuous_output.raw_outputs.last
  return if last_output.nil?
  last_output['output']&.lines&.last == CONNECTION_PROMPT
end