Class: ForemanAnsibleCore::Runner::AnsibleRunner
- Inherits:
-
ForemanTasksCore::Runner::Parent
- Object
- ForemanTasksCore::Runner::Parent
- ForemanAnsibleCore::Runner::AnsibleRunner
- Includes:
- ForemanTasksCore::Runner::Command
- Defined in:
- lib/foreman_ansible_core/runner/ansible_runner.rb
Instance Method Summary collapse
-
#initialize(input, suspended_action:) ⇒ AnsibleRunner
constructor
A new instance of AnsibleRunner.
- #refresh ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(input, suspended_action:) ⇒ AnsibleRunner
Returns a new instance of AnsibleRunner.
8 9 10 11 12 13 14 |
# File 'lib/foreman_ansible_core/runner/ansible_runner.rb', line 8 def initialize(input, suspended_action:) super input, :suspended_action => suspended_action @inventory = rebuild_secrets(rebuild_inventory(input), input) @playbook = input.values.first[:input][:action_input][:script] @root = working_dir @verbosity_level = input.values.first[:input][:action_input][:verbosity_level] end |
Instance Method Details
#refresh ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/foreman_ansible_core/runner/ansible_runner.rb', line 23 def refresh return unless super @counter ||= 1 @uuid ||= File.basename(Dir["#{@root}/artifacts/*"].first) job_event_dir = File.join(@root, 'artifacts', @uuid, 'job_events') loop do files = Dir["#{job_event_dir}/*.json"].map do |file| num = File.basename(file)[/\A\d+/].to_i unless file.include?('partial') [file, num] end files_with_nums = files.select { |(_, num)| num && num >= @counter }.sort_by(&:last) break if files_with_nums.empty? logger.debug("[foreman_ansible] - processing event files: #{files_with_nums.map(&:first).inspect}}") files_with_nums.map(&:first).each { |event_file| handle_event_file(event_file) } @counter = files_with_nums.last.last + 1 end end |
#start ⇒ Object
16 17 18 19 20 21 |
# File 'lib/foreman_ansible_core/runner/ansible_runner.rb', line 16 def start prepare_directory_structure write_inventory write_playbook start_ansible_runner end |