Project

General

Profile

Download (979 Bytes) Statistics
| Branch: | Tag: | Revision:

foreman_pipeline / app / lib / actions / foreman_pipeline / jenkins / wait_host_ready.rb @ be52ca64

1
module Actions
2
  module ForemanPipeline
3
    module Jenkins
4
      class WaitHostReady < WaitAndPoll
5
        include Mixins::SshExtension
6

    
7
        private
8
        
9
        def poll_external_task
10
          status = nil
11
          ip = Socket::getaddrinfo(input[:jenkins_instance_hostname], 'www', nil, Socket::SOCK_STREAM)[0][3]          
12
          Net::SSH.start(ip, 'root', :keys => [input.fetch(:cert_path)]) do |ssh|
13
            status = ssh_exec!(ssh, command)
14
          end
15
          
16
          output[:jenkins_ip] = ip
17
          output[:result] = status
18
          status[2].to_i == 0
19
        end
20

    
21
        def command
22
          c = []
23
          c << "sudo -u jenkins ssh -i #{input[:jenkins_home]}/.ssh/#{input[:jenkins_instance_hostname]} -o StrictHostKeyChecking=no root@#{input[:host_ip]}"
24
          c << "'echo"
25
          c << echo
26
          c << "'"
27
          c.join(" ")
28
        end
29

    
30
        def echo
31
          '"host ready yet?"'
32
        end
33

    
34
      end
35
    end
36
  end
37
end