Compare commits
16 Commits
kamal-prox
...
proxy-with
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46e3085052 | ||
|
|
81f3508507 | ||
|
|
9a16873f21 | ||
|
|
e5ca53db6e | ||
|
|
82a436fa02 | ||
|
|
7be2e7e0ba | ||
|
|
4f7ebd73a3 | ||
|
|
279bda2770 | ||
|
|
aa15fa532a | ||
|
|
276b469c2b | ||
|
|
c10b3fb07a | ||
|
|
f47fd13e5b | ||
|
|
1d8c40f5d2 | ||
|
|
73c78079bc | ||
|
|
cd12f95a97 | ||
|
|
190f4fba28 |
@@ -1,7 +1,7 @@
|
||||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
kamal (2.0.0)
|
||||
kamal (2.1.1)
|
||||
activesupport (>= 7.0)
|
||||
base64 (~> 0.2)
|
||||
bcrypt_pbkdf (~> 1.0)
|
||||
|
||||
@@ -203,7 +203,7 @@ class Kamal::Cli::App < Kamal::Cli::Base
|
||||
run_locally do
|
||||
info "Following logs on #{KAMAL.primary_host}..."
|
||||
|
||||
KAMAL.specific_roles ||= [ "web" ]
|
||||
KAMAL.specific_roles ||= [ KAMAL.primary_role.name ]
|
||||
role = KAMAL.roles_on(KAMAL.primary_host).first
|
||||
|
||||
app = KAMAL.app(role: role, host: host)
|
||||
|
||||
@@ -43,7 +43,12 @@ class Kamal::Commander::Specifics
|
||||
end
|
||||
|
||||
def specified_hosts
|
||||
(specific_hosts || config.all_hosts) \
|
||||
.select { |host| (specific_roles || config.roles).flat_map(&:hosts).include?(host) }
|
||||
specified_hosts = specific_hosts || config.all_hosts
|
||||
|
||||
if (specific_role_hosts = specific_roles&.flat_map(&:hosts)).present?
|
||||
specified_hosts.select { |host| specific_role_hosts.include?(host) }
|
||||
else
|
||||
specified_hosts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,6 +20,8 @@ class Kamal::Configuration
|
||||
|
||||
class << self
|
||||
def create_from(config_file:, destination: nil, version: nil)
|
||||
ENV["KAMAL_DESTINATION"] = destination
|
||||
|
||||
raw_config = load_config_files(config_file, *destination_config_file(config_file, destination))
|
||||
|
||||
new raw_config, destination: destination, version: version
|
||||
|
||||
@@ -29,8 +29,8 @@ ssh:
|
||||
|
||||
# Proxy host
|
||||
#
|
||||
# Specified in the form <host> or <user>@<host>:
|
||||
proxy: root@proxy-host
|
||||
# Specified in the form <host> or <user>@<host>
|
||||
proxy: proxy-host
|
||||
|
||||
# Proxy command
|
||||
#
|
||||
@@ -61,3 +61,10 @@ ssh:
|
||||
# An array of strings, with each element of the array being
|
||||
# a raw private key in PEM format.
|
||||
key_data: [ "-----BEGIN OPENSSH PRIVATE KEY-----" ]
|
||||
|
||||
# Config
|
||||
#
|
||||
# Set to true to load the default OpenSSH config files (~/.ssh/config,
|
||||
# /etc/ssh_config), to false ignore config files, or to a file path
|
||||
# (or array of paths) to load specific configuration. Defaults to true.
|
||||
config: true
|
||||
|
||||
@@ -19,9 +19,9 @@ class Kamal::Configuration::Ssh
|
||||
end
|
||||
|
||||
def proxy
|
||||
if (proxy = ssh_config["proxy"])
|
||||
Net::SSH::Proxy::Jump.new(proxy.include?("@") ? proxy : "root@#{proxy}")
|
||||
elsif (proxy_command = ssh_config["proxy_command"])
|
||||
if proxy = ssh_config["proxy"]
|
||||
Net::SSH::Proxy::Jump.new(proxy)
|
||||
elsif proxy_command = ssh_config["proxy_command"]
|
||||
Net::SSH::Proxy::Command.new(proxy_command)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Kamal
|
||||
VERSION = "2.0.0"
|
||||
VERSION = "2.1.1"
|
||||
end
|
||||
|
||||
@@ -150,6 +150,27 @@ class CommanderTest < ActiveSupport::TestCase
|
||||
assert_equal [ "1.1.1.2" ], @kamal.proxy_hosts
|
||||
end
|
||||
|
||||
test "accessory hosts without filtering" do
|
||||
configure_with(:deploy_with_single_accessory)
|
||||
assert_equal [ "1.1.1.5" ], @kamal.accessory_hosts
|
||||
|
||||
configure_with(:deploy_with_accessories_on_independent_server)
|
||||
assert_equal [ "1.1.1.5", "1.1.1.1", "1.1.1.2" ], @kamal.accessory_hosts
|
||||
end
|
||||
|
||||
test "accessory hosts with role filtering" do
|
||||
configure_with(:deploy_with_single_accessory)
|
||||
@kamal.specific_roles = [ "web" ]
|
||||
assert_equal [], @kamal.accessory_hosts
|
||||
|
||||
configure_with(:deploy_with_accessories_on_independent_server)
|
||||
@kamal.specific_roles = [ "web" ]
|
||||
assert_equal [ "1.1.1.1", "1.1.1.2" ], @kamal.accessory_hosts
|
||||
|
||||
@kamal.specific_roles = [ "workers" ]
|
||||
assert_equal [], @kamal.accessory_hosts
|
||||
end
|
||||
|
||||
private
|
||||
def configure_with(variant)
|
||||
@kamal = Kamal::Commander.new.tap do |kamal|
|
||||
|
||||
@@ -294,7 +294,7 @@ class CommandsAppTest < ActiveSupport::TestCase
|
||||
|
||||
test "run over ssh with proxy" do
|
||||
@config[:ssh] = { "proxy" => "2.2.2.2" }
|
||||
assert_equal "ssh -J root@2.2.2.2 -t root@1.1.1.1 -p 22 'ls'", new_command.run_over_ssh("ls", host: "1.1.1.1")
|
||||
assert_equal "ssh -J 2.2.2.2 -t root@1.1.1.1 -p 22 'ls'", new_command.run_over_ssh("ls", host: "1.1.1.1")
|
||||
end
|
||||
|
||||
test "run over ssh with proxy user" do
|
||||
@@ -304,7 +304,7 @@ class CommandsAppTest < ActiveSupport::TestCase
|
||||
|
||||
test "run over ssh with custom user with proxy" do
|
||||
@config[:ssh] = { "user" => "app", "proxy" => "2.2.2.2" }
|
||||
assert_equal "ssh -J root@2.2.2.2 -t app@1.1.1.1 -p 22 'ls'", new_command.run_over_ssh("ls", host: "1.1.1.1")
|
||||
assert_equal "ssh -J 2.2.2.2 -t app@1.1.1.1 -p 22 'ls'", new_command.run_over_ssh("ls", host: "1.1.1.1")
|
||||
end
|
||||
|
||||
test "run over ssh with proxy_command" do
|
||||
|
||||
@@ -30,7 +30,7 @@ class ConfigurationSshTest < ActiveSupport::TestCase
|
||||
|
||||
test "ssh options with proxy host" do
|
||||
config = Kamal::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "proxy" => "1.2.3.4" }) })
|
||||
assert_equal "root@1.2.3.4", config.ssh.options[:proxy].jump_proxies
|
||||
assert_equal "1.2.3.4", config.ssh.options[:proxy].jump_proxies
|
||||
end
|
||||
|
||||
test "ssh options with proxy host and user" do
|
||||
|
||||
@@ -222,6 +222,13 @@ class ConfigurationTest < ActiveSupport::TestCase
|
||||
assert_equal "my-user", config.registry.username
|
||||
end
|
||||
|
||||
test "destination is loaded into env" do
|
||||
dest_config_file = Pathname.new(File.expand_path("fixtures/deploy_for_dest.yml", __dir__))
|
||||
|
||||
config = Kamal::Configuration.create_from config_file: dest_config_file, destination: "world"
|
||||
assert_equal ENV["KAMAL_DESTINATION"], "world"
|
||||
end
|
||||
|
||||
test "destination yml config merge" do
|
||||
dest_config_file = Pathname.new(File.expand_path("fixtures/deploy_for_dest.yml", __dir__))
|
||||
|
||||
|
||||
38
test/fixtures/deploy_with_accessories_on_independent_server.yml
vendored
Normal file
38
test/fixtures/deploy_with_accessories_on_independent_server.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
service: app
|
||||
image: dhh/app
|
||||
servers:
|
||||
web:
|
||||
- "1.1.1.1"
|
||||
- "1.1.1.2"
|
||||
workers:
|
||||
- "1.1.1.3"
|
||||
- "1.1.1.4"
|
||||
registry:
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
accessories:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
host: 1.1.1.5
|
||||
port: 3306
|
||||
env:
|
||||
clear:
|
||||
MYSQL_ROOT_HOST: '%'
|
||||
secret:
|
||||
- MYSQL_ROOT_PASSWORD
|
||||
files:
|
||||
- test/fixtures/files/my.cnf:/etc/mysql/my.cnf
|
||||
directories:
|
||||
- data:/var/lib/mysql
|
||||
redis:
|
||||
image: redis:latest
|
||||
roles:
|
||||
- web
|
||||
port: 6379
|
||||
directories:
|
||||
- data:/data
|
||||
|
||||
readiness_delay: 0
|
||||
29
test/fixtures/deploy_with_single_accessory.yml
vendored
Normal file
29
test/fixtures/deploy_with_single_accessory.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
service: app
|
||||
image: dhh/app
|
||||
servers:
|
||||
web:
|
||||
- "1.1.1.1"
|
||||
- "1.1.1.2"
|
||||
workers:
|
||||
- "1.1.1.3"
|
||||
- "1.1.1.4"
|
||||
registry:
|
||||
username: user
|
||||
password: pw
|
||||
builder:
|
||||
arch: amd64
|
||||
|
||||
accessories:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
host: 1.1.1.5
|
||||
port: 3306
|
||||
env:
|
||||
clear:
|
||||
MYSQL_ROOT_HOST: '%'
|
||||
secret:
|
||||
- MYSQL_ROOT_PASSWORD
|
||||
files:
|
||||
- test/fixtures/files/my.cnf:/etc/mysql/my.cnf
|
||||
directories:
|
||||
- data:/var/lib/mysql
|
||||
Reference in New Issue
Block a user