Sha256: 222d8e150b551652135f83bbb6f77f4a4d6e7ce78466b0064c6f191b1b43dd35

Contents?: true

Size: 866 Bytes

Versions: 1

Compression:

Stored size: 866 Bytes

Contents

# test for existence

class Bard::Provision::HTTP < Bard::Provision
  def call
    print "HTTP:"
    target_host = URI.parse(server.ping.first).host
    if system "curl -s --resolve #{target_host}:80:#{provision_server.ssh_uri.host} http://#{target_host} -I | grep -i \"x-powered-by: phusion passenger\""
      puts " ✓"
    else
      puts " !!! not serving a rails app from #{provision_server.ssh_uri.host}"
    end
  end
  
  private

  def ssh_available? ssh_uri, port: ssh_uri.port
    system "nc -zv #{ssh_uri.host} #{port} 2>/dev/null"
  end

  def ssh_known_host? ssh_uri
    system "grep -q \"$(ssh-keyscan -t ed25519 -p#{ssh_uri.port || 22} #{ssh_uri.host} 2>/dev/null | cut -d ' ' -f 2-3)\" ~/.ssh/known_hosts"
  end

  def add_ssh_known_host! ssh_uri
    system "ssh-keyscan -p#{ssh_uri.port || 22} -H #{ssh_uri.host} >> ~/.ssh/known_hosts"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bard-1.0.0 lib/bard/provision/http.rb