class Proxy::Salt::SaltRunner

Implements the SaltRunner to be used by foreman_remote_execution

Constants

DEFAULT_REFRESH_INTERVAL

Attributes

jid[R]

Public Class Methods

new(options, suspended_action) click to toggle source
Calls superclass method
# File lib/smart_proxy_salt/salt_runner.rb, line 12
def initialize(options, suspended_action)
  super(options, :suspended_action => suspended_action)
  @options = options
end

Public Instance Methods

kill() click to toggle source
# File lib/smart_proxy_salt/salt_runner.rb, line 23
def kill
  publish_data('== TASK ABORTED BY USER ==', 'stdout')
  publish_exit_status(1)
  ::Process.kill('SIGTERM', @command_pid)
end
publish_data(data, type) click to toggle source
Calls superclass method
# File lib/smart_proxy_salt/salt_runner.rb, line 29
def publish_data(data, type)
  if @jid.nil? && (match = data.match(/jid: ([0-9]+)/))
    @jid = match[1]
  end
  super
end
publish_exit_status(status) click to toggle source
Calls superclass method
# File lib/smart_proxy_salt/salt_runner.rb, line 36
def publish_exit_status(status)
  # If there was no salt job associated with this run, mark the job as failed
  status = 1 if @jid.nil?
  super status
end
start() click to toggle source
# File lib/smart_proxy_salt/salt_runner.rb, line 17
def start
  command = generate_command
  logger.debug("Running command '#{command.join(' ')}'")
  initialize_command(*command)
end

Private Instance Methods

generate_command() click to toggle source
# File lib/smart_proxy_salt/salt_runner.rb, line 44
def generate_command
  saltfile_path = ::Proxy::Salt::Plugin.settings[:saltfile]
  command = %w[salt --show-jid]
  command << "--saltfile=#{saltfile_path}" if File.file?(saltfile_path)
  command << @options['name']
  command << 'state.template_str'
  command << @options['script']
  command
end