Sha256: 277d9426ac7ededc9baf65ed9da1fa170112b0730bc9fb17ce227fe3735ed11d

Contents?: true

Size: 886 Bytes

Versions: 5

Compression:

Stored size: 886 Bytes

Contents

module ForemanAnsible
  # This module takes the config reports stored in Foreman for Ansible and
  # modifies them to be properly presented in views
  module AnsibleReportsHelper
    def module_name(log)
      JSON.parse(log.source.value)['module_name']
    end

    def module_args(log)
      JSON.parse(log.source.value)['module_args']
    end

    def ansible_module_message(log)
      paragraph_style = 'margin:0px;font-family:Menlo,Monaco,Consolas,monospace'
      safe_join(
        JSON.parse(log.message.value).except('invocation').map do |name, value|
          next if value.blank?
          content_tag(:p, "#{name}: #{value}", :style => paragraph_style)
        end
      )
    end

    def ansible_report?(log)
      module_name(log).present?
      # Failures when parsing the log indicates it's not an Ansible report
    rescue StandardError
      false
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_ansible-2.0.4 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-2.0.3 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-2.0.2 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-2.0.1 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-2.0.0 app/helpers/foreman_ansible/ansible_reports_helper.rb