Class: Mrsk::Commander
- Inherits:
-
Object
- Object
- Mrsk::Commander
- Defined in:
- lib/mrsk/commander.rb
Instance Attribute Summary collapse
-
#lock_count ⇒ Object
Returns the value of attribute lock_count.
-
#specific_hosts ⇒ Object
Returns the value of attribute specific_hosts.
-
#specific_roles ⇒ Object
Returns the value of attribute specific_roles.
-
#verbosity ⇒ Object
Returns the value of attribute verbosity.
Instance Method Summary collapse
- #accessory(name) ⇒ Object
- #accessory_hosts ⇒ Object
- #accessory_names ⇒ Object
- #app(role: nil) ⇒ Object
- #auditor(role: nil) ⇒ Object
- #builder ⇒ Object
- #config ⇒ Object
- #configure(**kwargs) ⇒ Object
- #healthcheck ⇒ Object
- #hosts ⇒ Object
-
#initialize ⇒ Commander
constructor
A new instance of Commander.
- #lock ⇒ Object
- #primary_host ⇒ Object
- #prune ⇒ Object
- #registry ⇒ Object
- #roles ⇒ Object
- #roles_on(host) ⇒ Object
- #specific_primary! ⇒ Object
- #traefik ⇒ Object
- #traefik_hosts ⇒ Object
- #with_verbosity(level) ⇒ Object
Constructor Details
#initialize ⇒ Commander
Returns a new instance of Commander.
7 8 9 10 |
# File 'lib/mrsk/commander.rb', line 7 def initialize self.verbosity = :info self.lock_count = 0 end |
Instance Attribute Details
#lock_count ⇒ Object
Returns the value of attribute lock_count.
5 6 7 |
# File 'lib/mrsk/commander.rb', line 5 def lock_count @lock_count end |
#specific_hosts ⇒ Object
Returns the value of attribute specific_hosts.
23 24 25 |
# File 'lib/mrsk/commander.rb', line 23 def specific_hosts @specific_hosts end |
#specific_roles ⇒ Object
Returns the value of attribute specific_roles.
23 24 25 |
# File 'lib/mrsk/commander.rb', line 23 def specific_roles @specific_roles end |
#verbosity ⇒ Object
Returns the value of attribute verbosity.
5 6 7 |
# File 'lib/mrsk/commander.rb', line 5 def verbosity @verbosity end |
Instance Method Details
#accessory(name) ⇒ Object
74 75 76 |
# File 'lib/mrsk/commander.rb', line 74 def accessory(name) Mrsk::Commands::Accessory.new(config, name: name) end |
#accessory_hosts ⇒ Object
61 62 63 |
# File 'lib/mrsk/commander.rb', line 61 def accessory_hosts specific_hosts || config.accessories.flat_map(&:hosts) end |
#accessory_names ⇒ Object
65 66 67 |
# File 'lib/mrsk/commander.rb', line 65 def accessory_names config.accessories&.collect(&:name) || [] end |
#app(role: nil) ⇒ Object
70 71 72 |
# File 'lib/mrsk/commander.rb', line 70 def app(role: nil) Mrsk::Commands::App.new(config, role: role) end |
#auditor(role: nil) ⇒ Object
78 79 80 |
# File 'lib/mrsk/commander.rb', line 78 def auditor(role: nil) Mrsk::Commands::Auditor.new(config, role: role) end |
#builder ⇒ Object
82 83 84 |
# File 'lib/mrsk/commander.rb', line 82 def builder @builder ||= Mrsk::Commands::Builder.new(config) end |
#config ⇒ Object
12 13 14 15 16 17 |
# File 'lib/mrsk/commander.rb', line 12 def config @config ||= Mrsk::Configuration.create_from(**@config_kwargs).tap do |config| @config_kwargs = nil configure_sshkit_with(config) end end |
#configure(**kwargs) ⇒ Object
19 20 21 |
# File 'lib/mrsk/commander.rb', line 19 def configure(**kwargs) @config, @config_kwargs = nil, kwargs end |
#healthcheck ⇒ Object
86 87 88 |
# File 'lib/mrsk/commander.rb', line 86 def healthcheck @healthcheck ||= Mrsk::Commands::Healthcheck.new(config) end |
#hosts ⇒ Object
47 48 49 50 51 |
# File 'lib/mrsk/commander.rb', line 47 def hosts (specific_hosts || config.all_hosts).select do |host| (specific_roles || config.roles).flat_map(&:hosts).include?(host) end end |
#lock ⇒ Object
102 103 104 |
# File 'lib/mrsk/commander.rb', line 102 def lock @lock ||= Mrsk::Commands::Lock.new(config) end |
#primary_host ⇒ Object
37 38 39 |
# File 'lib/mrsk/commander.rb', line 37 def primary_host specific_hosts&.first || config.primary_web_host end |
#prune ⇒ Object
90 91 92 |
# File 'lib/mrsk/commander.rb', line 90 def prune @prune ||= Mrsk::Commands::Prune.new(config) end |
#registry ⇒ Object
94 95 96 |
# File 'lib/mrsk/commander.rb', line 94 def registry @registry ||= Mrsk::Commands::Registry.new(config) end |
#roles ⇒ Object
41 42 43 44 45 |
# File 'lib/mrsk/commander.rb', line 41 def roles (specific_roles || config.roles).select do |role| ((specific_hosts || config.all_hosts) & role.hosts).any? end end |
#roles_on(host) ⇒ Object
53 54 55 |
# File 'lib/mrsk/commander.rb', line 53 def roles_on(host) roles.select { |role| role.hosts.include?(host.to_s) }.map(&:name) end |
#specific_primary! ⇒ Object
25 26 27 |
# File 'lib/mrsk/commander.rb', line 25 def specific_primary! self.specific_hosts = [ config.primary_web_host ] end |
#traefik ⇒ Object
98 99 100 |
# File 'lib/mrsk/commander.rb', line 98 def traefik @traefik ||= Mrsk::Commands::Traefik.new(config) end |
#traefik_hosts ⇒ Object
57 58 59 |
# File 'lib/mrsk/commander.rb', line 57 def traefik_hosts specific_hosts || config.traefik_hosts end |
#with_verbosity(level) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/mrsk/commander.rb', line 106 def with_verbosity(level) old_level = self.verbosity self.verbosity = level SSHKit.config.output_verbosity = level yield ensure self.verbosity = old_level SSHKit.config.output_verbosity = old_level end |