Sha256: f1b5b8a9aac1d7da4928c7077f5bb1cbfb0f2f10d750e8ce266b486f2b38e340

Contents?: true

Size: 866 Bytes

Versions: 14

Compression:

Stored size: 866 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?
    rescue # Failures when parsing the log indicates it's not an Ansible report
      false
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
foreman_ansible-1.5.2 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.5.1 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.5.0 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.4.6 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.4.5 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.4.3 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.4.2 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.4.1 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.4.0 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.3.1 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.3.0 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.2.1 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.2 app/helpers/foreman_ansible/ansible_reports_helper.rb
foreman_ansible-1.1 app/helpers/foreman_ansible/ansible_reports_helper.rb