Class: RundeckFormatter

Inherits:
Object
  • Object
show all
Defined in:
app/services/rundeck_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ RundeckFormatter

Returns a new instance of RundeckFormatter.



7
8
9
# File 'app/services/rundeck_formatter.rb', line 7

def initialize(host)
  @host = host
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



2
3
4
# File 'app/services/rundeck_formatter.rb', line 2

def host
  @host
end

Instance Method Details

#outputObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/rundeck_formatter.rb', line 11

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