Sha256: dc88f81f41e31b4b83cb07cf91b9a64eaa238a70e3192723b09ec8e1edeb6272

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

class RundeckFormatter
  attr_reader :host

  delegate :comment, :name, :arch, :environment, :os, :facts_hash, :puppetclasses_names, :params, :to => :host
  delegate :logger, :to => :Rails

  def initialize(host)
    @host = host
  end

    def output
    rdecktags = puppetclasses_names.map { |k| "class=#{k}" }
    unless params['rundeckfacts'].empty?
      rdecktags += params['rundeckfacts'].gsub(/\s+/, '').split(',').map { |rdf| "#{rdf}=" + (facts_hash[rdf] || 'undefined') }
    end

    {name => {'description' => comment, 'hostname' => name, 'nodename' => name,
              'Environment' => environment.name,
              'osArch' => arch.name, 'osFamily' => os.family, 'osName' => os.name,
              'osVersion' => os.release, 'tags' => rdecktags,
              'username' => params['rundeckuser'] || 'root'}
    }
  rescue => e
    logger.warn "Failed to fetch rundeck info for #{to_s}: #{e}"
    {}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_host_rundeck-0.0.2 app/services/rundeck_formatter.rb