Module: ForemanSalt::Concerns::HostManagedExtensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/foreman_salt/concerns/host_managed_extensions.rb
Instance Method Summary collapse
- #handle_salt ⇒ Object
- #params_with_salt_proxy ⇒ Object
- #salt_master ⇒ Object
- #salt_module_ids ⇒ Object
- #salt_modules ⇒ Object
- #saltrun! ⇒ Object
- #set_hostgroup_defaults_with_salt_proxy ⇒ Object
- #smart_proxy_ids_with_salt_proxy ⇒ Object
Instance Method Details
#handle_salt ⇒ Object
15 16 17 18 |
# File 'app/models/foreman_salt/concerns/host_managed_extensions.rb', line 15 def handle_salt return true unless salt? salt_autosign_create end |
#params_with_salt_proxy ⇒ Object
20 21 22 23 24 |
# File 'app/models/foreman_salt/concerns/host_managed_extensions.rb', line 20 def params_with_salt_proxy params = params_without_salt_proxy params["salt_master"] = salt_master unless salt_master.blank? params end |
#salt_master ⇒ Object
36 37 38 |
# File 'app/models/foreman_salt/concerns/host_managed_extensions.rb', line 36 def salt_master salt_proxy.to_s end |
#salt_module_ids ⇒ Object
31 32 33 34 |
# File 'app/models/foreman_salt/concerns/host_managed_extensions.rb', line 31 def salt_module_ids return super unless hostgroup [super + hostgroup.salt_module_ids].flatten end |
#salt_modules ⇒ Object
26 27 28 29 |
# File 'app/models/foreman_salt/concerns/host_managed_extensions.rb', line 26 def salt_modules return super unless hostgroup [super + hostgroup.salt_modules].flatten end |
#saltrun! ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/foreman_salt/concerns/host_managed_extensions.rb', line 40 def saltrun! unless salt_proxy.present? errors.add(:base, _("No Salt master defined - can't continue")) logger.warn "Unable to execute salt run, no salt proxies defined" return false end ProxyAPI::Salt.new({:url => salt_proxy.url}).highstate name rescue => e errors.add(:base, _("Failed to execute state.highstate: %s") % e) false end |
#set_hostgroup_defaults_with_salt_proxy ⇒ Object
52 53 54 55 56 |
# File 'app/models/foreman_salt/concerns/host_managed_extensions.rb', line 52 def set_hostgroup_defaults_with_salt_proxy return unless hostgroup assign_hostgroup_attributes(%w{salt_proxy_id salt_environment_id}) set_hostgroup_defaults_without_salt_proxy end |
#smart_proxy_ids_with_salt_proxy ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/models/foreman_salt/concerns/host_managed_extensions.rb', line 58 def smart_proxy_ids_with_salt_proxy ids = smart_proxy_ids_without_salt_proxy [salt_proxy, hostgroup.try(:salt_proxy)].compact.each do |proxy| ids << proxy.id end ids end |