class DockerComposeDeploy::Actions::Hosts

Public Instance Methods

hijack() click to toggle source
# File lib/docker_compose_deploy/actions/hosts.rb, line 5
def hijack
  return unless DockerComposeDeploy.config.domains.any?

  shell.notify("Creating hosts entries for test_domains")

  host_entries = ["localhost", "vagrant"] + DockerComposeDeploy.config.domains
  Tempfile.open do |f|
    host_entries.each do |host|
      f.puts("127.0.0.1 #{host}")
    end
    f.close
    shell.scp!(f.path, "#{connection}:/tmp/hosts")
    shell.ssh!("sudo mv /tmp/hosts /etc/hosts")
    shell.notify("Wrote to /etc/hosts on test server:")
    shell.puts(`cat #{f.path}`)
  end
end

Private Instance Methods

connection() click to toggle source
# File lib/docker_compose_deploy/actions/hosts.rb, line 25
def connection
  DockerComposeDeploy.config.connection
end