Traefik hosts can now be more than just web
This commit is contained in:
@@ -3,17 +3,17 @@ require "mrsk/cli/base"
|
||||
class Mrsk::Cli::Traefik < Mrsk::Cli::Base
|
||||
desc "boot", "Boot Traefik on servers"
|
||||
def boot
|
||||
on(MRSK.config.role(:web).hosts) { execute *MRSK.traefik.run, raise_on_non_zero_exit: false }
|
||||
on(MRSK.config.traefik_hosts) { execute *MRSK.traefik.run, raise_on_non_zero_exit: false }
|
||||
end
|
||||
|
||||
desc "start", "Start existing Traefik on servers"
|
||||
def start
|
||||
on(MRSK.config.role(:web).hosts) { execute *MRSK.traefik.start, raise_on_non_zero_exit: false }
|
||||
on(MRSK.config.traefik_hosts) { execute *MRSK.traefik.start, raise_on_non_zero_exit: false }
|
||||
end
|
||||
|
||||
desc "stop", "Stop Traefik on servers"
|
||||
def stop
|
||||
on(MRSK.config.role(:web).hosts) { execute *MRSK.traefik.stop, raise_on_non_zero_exit: false }
|
||||
on(MRSK.config.traefik_hosts) { execute *MRSK.traefik.stop, raise_on_non_zero_exit: false }
|
||||
end
|
||||
|
||||
desc "restart", "Restart Traefik on servers"
|
||||
@@ -24,7 +24,7 @@ class Mrsk::Cli::Traefik < Mrsk::Cli::Base
|
||||
|
||||
desc "details", "Display details about Traefik containers from servers"
|
||||
def details
|
||||
on(MRSK.config.role(:web).hosts) { |host| puts "Traefik Host: #{host}\n" + capture(*MRSK.traefik.info, verbosity: Logger::INFO) + "\n\n" }
|
||||
on(MRSK.config.traefik_hosts) { |host| puts "Traefik Host: #{host}\n" + capture(*MRSK.traefik.info, verbosity: Logger::INFO) + "\n\n" }
|
||||
end
|
||||
|
||||
desc "logs", "Show last 100 log lines from Traefik on servers"
|
||||
@@ -36,7 +36,7 @@ class Mrsk::Cli::Traefik < Mrsk::Cli::Base
|
||||
def remove
|
||||
invoke :stop
|
||||
|
||||
on(MRSK.config.role(:web).hosts) do
|
||||
on(MRSK.config.traefik_hosts) do
|
||||
execute *MRSK.traefik.remove_container
|
||||
execute *MRSK.traefik.remove_image
|
||||
end
|
||||
|
||||
@@ -71,6 +71,10 @@ class Mrsk::Configuration
|
||||
role(:web).hosts.first
|
||||
end
|
||||
|
||||
def traefik_hosts
|
||||
roles.select(&:running_traefik?).flat_map(&:hosts)
|
||||
end
|
||||
|
||||
|
||||
def version
|
||||
@version ||= ENV["VERSION"] || `git rev-parse HEAD`.strip
|
||||
|
||||
@@ -31,6 +31,10 @@ class Mrsk::Configuration::Role
|
||||
specializations["cmd"]
|
||||
end
|
||||
|
||||
def running_traefik?
|
||||
name.web? || specializations["traefik"]
|
||||
end
|
||||
|
||||
private
|
||||
attr_accessor :config
|
||||
|
||||
@@ -61,10 +65,6 @@ class Mrsk::Configuration::Role
|
||||
end
|
||||
end
|
||||
|
||||
def running_traefik?
|
||||
name.web? || specializations["traefik"]
|
||||
end
|
||||
|
||||
def custom_labels
|
||||
Hash.new.tap do |labels|
|
||||
labels.merge!(config.labels) if config.labels.present?
|
||||
|
||||
@@ -70,6 +70,14 @@ class ConfigurationTest < ActiveSupport::TestCase
|
||||
assert_equal "1.1.1.1", @config_with_roles.primary_host
|
||||
end
|
||||
|
||||
test "traefik hosts" do
|
||||
assert_equal [ "1.1.1.1", "1.1.1.2" ], @config_with_roles.traefik_hosts
|
||||
|
||||
@deploy_with_roles[:servers]["workers"]["traefik"] = true
|
||||
config = Mrsk::Configuration.new(@deploy_with_roles)
|
||||
|
||||
assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" ], config.traefik_hosts
|
||||
end
|
||||
|
||||
test "version" do
|
||||
assert_equal "123", @config.version
|
||||
|
||||
Reference in New Issue
Block a user