Class: Proxy::Ansible::Runner::Playbook
- Inherits:
-
Dynflow::Runner::CommandRunner
- Object
- Dynflow::Runner::CommandRunner
- Proxy::Ansible::Runner::Playbook
- Defined in:
- lib/smart_proxy_ansible/runner/playbook.rb
Overview
Implements Proxy::Dynflow::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.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/smart_proxy_ansible/runner/playbook.rb', line 16 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.
14 15 16 |
# File 'lib/smart_proxy_ansible/runner/playbook.rb', line 14 def command_in @command_in end |
#command_out ⇒ Object (readonly)
Returns the value of attribute command_out.
14 15 16 |
# File 'lib/smart_proxy_ansible/runner/playbook.rb', line 14 def command_out @command_out end |
#command_pid ⇒ Object (readonly)
Returns the value of attribute command_pid.
14 15 16 |
# File 'lib/smart_proxy_ansible/runner/playbook.rb', line 14 def command_pid @command_pid end |
Instance Method Details
#close ⇒ Object
47 48 49 50 |
# File 'lib/smart_proxy_ansible/runner/playbook.rb', line 47 def close super FileUtils.remove_entry(@working_dir) if @tmp_working_dir end |
#kill ⇒ Object
40 41 42 43 44 45 |
# File 'lib/smart_proxy_ansible/runner/playbook.rb', line 40 def kill publish_data('== TASK ABORTED BY USER ==', 'stdout') publish_exit_status(1) ::Process.kill('SIGTERM', @command_pid) close end |
#start ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/smart_proxy_ansible/runner/playbook.rb', line 27 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 |