module DefaultHostgroupBaseHostPatch::Overrides
Public Instance Methods
Source
# File lib/default_hostgroup_base_host_patch.rb, line 14 def import_facts(facts, source_proxy = nil, without_alias = false) # rubocop:enable Metrics/AbcSize,Metrics/CyclomaticComplexity # Load the facts anyway, hook onto the end of it result = super(facts, source_proxy) # Module#prepend removes the import_facts_without_match_hostgroup method, so use # a flag to return here if needed return result if without_alias # Check settings are created return result unless settings_exist? Rails.logger.debug 'DefaultHostgroupMatch: performing Hostgroup match' return result unless host_new_or_forced? return result unless host_has_no_hostgroup_or_forced? facts_map = SETTINGS[:default_hostgroup][:facts_map] new_hostgroup = find_match(facts_map) return result unless new_hostgroup host.hostgroup = new_hostgroup host.environment = new_hostgroup.environment if (Setting[:force_host_environment] == true) && (facts[:_type] == :puppet) host.save(validate: false) Rails.logger.info "DefaultHostgroupMatch: #{facts['hostname']} added to #{new_hostgroup}" result end
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
Calls superclass method