Class: Proxy::Ansible::RemoteExecutionCore::AnsibleRunner
- Inherits:
-
Dynflow::Runner::CommandRunner
- Object
- Dynflow::Runner::CommandRunner
- Proxy::Ansible::RemoteExecutionCore::AnsibleRunner
- Defined in:
- lib/smart_proxy_ansible/remote_execution_core/ansible_runner.rb
Overview
Takes an inventory and runs it through REXCore CommandRunner
Constant Summary collapse
- DEFAULT_REFRESH_INTERVAL =
1
- CONNECTION_PROMPT =
'Are you sure you want to continue connecting (yes/no)? '
Instance Method Summary collapse
- #fill_continuous_output(continuous_output) ⇒ Object
-
#initialize(options, suspended_action:) ⇒ AnsibleRunner
constructor
A new instance of AnsibleRunner.
- #kill ⇒ Object
- #refresh ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(options, suspended_action:) ⇒ AnsibleRunner
Returns a new instance of AnsibleRunner.
12 13 14 15 16 17 18 19 20 |
# File 'lib/smart_proxy_ansible/remote_execution_core/ansible_runner.rb', line 12 def initialize(, suspended_action:) super(, :suspended_action => suspended_action) @playbook_runner = Proxy::Ansible::Runner::Playbook.new( ['ansible_inventory'], ['script'], , :suspended_action => suspended_action ) end |
Instance Method Details
#fill_continuous_output(continuous_output) ⇒ Object
33 34 35 36 37 38 39 |
# 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 ⇒ Object
49 50 51 52 53 |
# 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 ⇒ Object
41 42 43 44 45 46 47 |
# 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 ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# 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.}:\n #{e.backtrace.join("\n")}" ) publish_exception('Error initializing command', e) end |