Sha256: 98139bb4a92731529412d7fa65224d3a412b43c36a3382aa7481de8008e864e9

Contents?: true

Size: 715 Bytes

Versions: 6

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

module ForemanAnsible
  # Scans ConfigReports after import for indicators of an Ansible report and
  # sets the origin of the report to 'Ansible'
  class AnsibleReportScanner
    class << self
      def add_reporter_data(report, raw); end

      def identify_origin(raw)
        'Ansible' if ansible_report?(raw)
      end

      def ansible_report?(raw)
        raw['reporter'] == 'ansible' || ansible_legacy_report?(raw['logs'])
      end

      def ansible_legacy_report?(logs)
        return false if logs.blank?
        logs.any? do |log|
          log['log'].fetch('messages', {}).
            fetch('message', '') =~ /"_ansible_parsed"/
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_ansible-6.2.0 app/services/foreman_ansible/ansible_report_scanner.rb
foreman_ansible-6.1.1 app/services/foreman_ansible/ansible_report_scanner.rb
foreman_ansible-6.0.2 app/services/foreman_ansible/ansible_report_scanner.rb
foreman_ansible-6.1.0 app/services/foreman_ansible/ansible_report_scanner.rb
foreman_ansible-6.0.1 app/services/foreman_ansible/ansible_report_scanner.rb
foreman_ansible-6.0.0 app/services/foreman_ansible/ansible_report_scanner.rb