Class: ForemanAnsibleCore::Runner::Playbook
- Inherits:
-
ForemanTasksCore::Runner::CommandRunner
- Object
- ForemanTasksCore::Runner::CommandRunner
- ForemanAnsibleCore::Runner::Playbook
- Defined in:
- lib/foreman_ansible_core/runner/playbook.rb
Overview
Implements ForemanTasksCore::Runner::Base interface for running Ansible playbooks, used by the Foreman Ansible plugin and Ansible proxy
Instance Attribute Summary collapse
-
#command_in ⇒ Object
readonly
Returns the value of attribute command_in.
-
#command_out ⇒ Object
readonly
Returns the value of attribute command_out.
-
#command_pid ⇒ Object
readonly
Returns the value of attribute command_pid.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(inventory, playbook, options = {}, suspended_action:) ⇒ Playbook
constructor
A new instance of Playbook.
- #kill ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(inventory, playbook, options = {}, suspended_action:) ⇒ Playbook
Returns a new instance of Playbook.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/foreman_ansible_core/runner/playbook.rb', line 15 def initialize(inventory, playbook, = {}, suspended_action:) super :suspended_action => suspended_action @inventory = rebuild_secrets(inventory, [:secrets]) unknown_hosts.each do |host| add_to_known_hosts(host) end @playbook = playbook @options = initialize_dirs end |
Instance Attribute Details
#command_in ⇒ Object (readonly)
Returns the value of attribute command_in.
13 14 15 |
# File 'lib/foreman_ansible_core/runner/playbook.rb', line 13 def command_in @command_in end |
#command_out ⇒ Object (readonly)
Returns the value of attribute command_out.
13 14 15 |
# File 'lib/foreman_ansible_core/runner/playbook.rb', line 13 def command_out @command_out end |
#command_pid ⇒ Object (readonly)
Returns the value of attribute command_pid.
13 14 15 |
# File 'lib/foreman_ansible_core/runner/playbook.rb', line 13 def command_pid @command_pid end |
Instance Method Details
#close ⇒ Object
46 47 48 49 |
# File 'lib/foreman_ansible_core/runner/playbook.rb', line 46 def close super FileUtils.remove_entry(@working_dir) if @tmp_working_dir end |
#kill ⇒ Object
39 40 41 42 43 44 |
# File 'lib/foreman_ansible_core/runner/playbook.rb', line 39 def kill publish_data('== TASK ABORTED BY USER ==', 'stdout') publish_exit_status(1) ::Process.kill('SIGTERM', @command_pid) close end |
#start ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/foreman_ansible_core/runner/playbook.rb', line 26 def start write_inventory write_playbook command = CommandCreator.new(inventory_file, playbook_file, @options).command logger.debug('[foreman_ansible] - Initializing Ansible Runner') Dir.chdir(@ansible_dir) do initialize_command(*command) logger.debug("[foreman_ansible] - Running command '#{command.join(' ')}'") end end |