Module: DefaultHostgroupBaseHostPatch::Overrides
- Defined in:
- lib/default_hostgroup_base_host_patch.rb
Instance Method Summary collapse
-
#import_facts(facts, source_proxy = nil, without_alias = false) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity.
Instance Method Details
#import_facts(facts, source_proxy = nil, without_alias = false) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
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 43 |
# 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 |