Class: RundeckFormatter
- Inherits:
-
Object
- Object
- RundeckFormatter
- Defined in:
- app/services/rundeck_formatter.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #format_tags(params, tag, tag_location) ⇒ Object
-
#initialize(host, include_enc_output = false) ⇒ RundeckFormatter
constructor
A new instance of RundeckFormatter.
- #output ⇒ Object
Constructor Details
#initialize(host, include_enc_output = false) ⇒ RundeckFormatter
Returns a new instance of RundeckFormatter.
8 9 10 11 |
# File 'app/services/rundeck_formatter.rb', line 8 def initialize(host, include_enc_output = false) @host = host @include_enc_output = include_enc_output end |
Instance Attribute Details
#host ⇒ Object (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
#format_tags(params, tag, tag_location) ⇒ Object
44 45 46 |
# File 'app/services/rundeck_formatter.rb', line 44 def params, tag, tag_location params[tag].gsub(/\s+/, '').split(',').map { |rdf| "#{rdf}=" + (tag_location[rdf] || 'undefined') } end |
#output ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/services/rundeck_formatter.rb', line 13 def output = puppetclasses_names.map { |k| "class=#{k}" } unless params['rundeckfacts'].empty? += (params,'rundeckfacts', facts_hash) end unless params['rundeckglobalparams'].empty? += (params, 'rundeckglobalparams', params) end rundeck_hash = { 'description' => comment, 'hostname' => name, 'nodename' => name, 'osArch' => arch.name, 'osFamily' => os.family, 'osName' => os.name, 'osVersion' => os.release, 'tags' => , 'username' => params['rundeckuser'] || 'root'} rundeck_hash['Hostgroup'] = hostgroup.name unless hostgroup.nil? rundeck_hash['Environment'] = environment.name unless environment.nil? rundeck_hash['Enc_output'] = info if @include_enc_output if SETTINGS[:locations_enabled] rundeck_hash['Location'] = location.name unless location.nil? end if SETTINGS[:organizations_enabled] rundeck_hash['Organization'] = organization.name unless organization.nil? end { name => rundeck_hash } rescue => e logger.warn "Failed to fetch rundeck info for #{to_s}: #{e}" {} end |