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
|
class Mrsk::Cli::Traefik < Mrsk::Cli::Base
|
||||||
desc "boot", "Boot Traefik on servers"
|
desc "boot", "Boot Traefik on servers"
|
||||||
def boot
|
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
|
end
|
||||||
|
|
||||||
desc "start", "Start existing Traefik on servers"
|
desc "start", "Start existing Traefik on servers"
|
||||||
def start
|
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
|
end
|
||||||
|
|
||||||
desc "stop", "Stop Traefik on servers"
|
desc "stop", "Stop Traefik on servers"
|
||||||
def stop
|
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
|
end
|
||||||
|
|
||||||
desc "restart", "Restart Traefik on servers"
|
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"
|
desc "details", "Display details about Traefik containers from servers"
|
||||||
def details
|
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
|
end
|
||||||
|
|
||||||
desc "logs", "Show last 100 log lines from Traefik on servers"
|
desc "logs", "Show last 100 log lines from Traefik on servers"
|
||||||
@@ -36,7 +36,7 @@ class Mrsk::Cli::Traefik < Mrsk::Cli::Base
|
|||||||
def remove
|
def remove
|
||||||
invoke :stop
|
invoke :stop
|
||||||
|
|
||||||
on(MRSK.config.role(:web).hosts) do
|
on(MRSK.config.traefik_hosts) do
|
||||||
execute *MRSK.traefik.remove_container
|
execute *MRSK.traefik.remove_container
|
||||||
execute *MRSK.traefik.remove_image
|
execute *MRSK.traefik.remove_image
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ class Mrsk::Configuration
|
|||||||
role(:web).hosts.first
|
role(:web).hosts.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def traefik_hosts
|
||||||
|
roles.select(&:running_traefik?).flat_map(&:hosts)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def version
|
def version
|
||||||
@version ||= ENV["VERSION"] || `git rev-parse HEAD`.strip
|
@version ||= ENV["VERSION"] || `git rev-parse HEAD`.strip
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ class Mrsk::Configuration::Role
|
|||||||
specializations["cmd"]
|
specializations["cmd"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def running_traefik?
|
||||||
|
name.web? || specializations["traefik"]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
attr_accessor :config
|
attr_accessor :config
|
||||||
|
|
||||||
@@ -61,10 +65,6 @@ class Mrsk::Configuration::Role
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def running_traefik?
|
|
||||||
name.web? || specializations["traefik"]
|
|
||||||
end
|
|
||||||
|
|
||||||
def custom_labels
|
def custom_labels
|
||||||
Hash.new.tap do |labels|
|
Hash.new.tap do |labels|
|
||||||
labels.merge!(config.labels) if config.labels.present?
|
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
|
assert_equal "1.1.1.1", @config_with_roles.primary_host
|
||||||
end
|
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
|
test "version" do
|
||||||
assert_equal "123", @config.version
|
assert_equal "123", @config.version
|
||||||
|
|||||||
Reference in New Issue
Block a user