Module: Orchestration::SSH
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/foreman_remote_execution/orchestration/ssh.rb
Instance Method Summary collapse
- #drop_from_known_hosts(proxy_id) ⇒ Object
- #queue_ssh_destroy ⇒ Object
- #should_drop_from_known_hosts? ⇒ Boolean
- #ssh_destroy ⇒ Object
Instance Method Details
#drop_from_known_hosts(proxy_id) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/concerns/foreman_remote_execution/orchestration/ssh.rb', line 11 def drop_from_known_hosts(proxy_id) _, _, target = host_kind_target return true if target.nil? proxy = ::SmartProxy.find(proxy_id) begin proxy.drop_host_from_known_hosts(target) rescue RestClient::ResourceNotFound => e # ignore 404 when known_hosts entry is missing or the module was not enabled Foreman::Logging.exception "Proxy failed to delete SSH known_hosts for #{name}, #{ip}", e, :level => :error rescue => e Rails.logger.warn e. return false end true end |
#queue_ssh_destroy ⇒ Object
39 40 41 |
# File 'app/models/concerns/foreman_remote_execution/orchestration/ssh.rb', line 39 def queue_ssh_destroy should_drop_from_known_hosts? && ssh_destroy end |
#should_drop_from_known_hosts? ⇒ Boolean
43 44 45 46 |
# File 'app/models/concerns/foreman_remote_execution/orchestration/ssh.rb', line 43 def should_drop_from_known_hosts? host, = host_kind_target host && !host.new_record? && host.build && host.changes.key?('build') end |
#ssh_destroy ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/concerns/foreman_remote_execution/orchestration/ssh.rb', line 28 def ssh_destroy logger.debug "Scheduling SSH known_hosts cleanup" host, _kind, _target = host_kind_target proxies = host.remote_execution_proxies('SSH').values proxies.flatten.uniq.each do |proxy| queue.create(id: queue_id(proxy.id), name: _("Remove SSH known hosts for %s") % self, priority: 200, action: [self, :drop_from_known_hosts, proxy.id]) end end |