Sha256: 078a1e3ddda1e18cf6e8296ef1e5a09f0212de74b352bf3f741d308ccf00f763
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
class RundeckFormatter attr_reader :host delegate :comment, :name, :arch, :environment, :os, :facts_hash, :puppetclasses_names, :params, :hostgroup, :organization, :location, :info, :to => :host delegate :logger, :to => :Rails def initialize(host, include_enc_output = false) @host = host @include_enc_output = include_enc_output end def output rdecktags = puppetclasses_names.map { |k| "class=#{k}" } unless params['rundeckfacts'].empty? rdecktags += format_tags(params,'rundeckfacts', facts_hash) end unless params['rundeckglobalparams'].empty? rdecktags += format_tags(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' => rdecktags, '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 def format_tags params, tag, tag_location params[tag].gsub(/\s+/, '').split(',').map { |rdf| "#{rdf}=" + (tag_location[rdf] || 'undefined') } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
foreman_host_rundeck-0.0.3 | app/services/rundeck_formatter.rb |