Pull the primary host from the role

So commands like this run on a host with the specified role:
```
mrsk app exec -r=console -i "/bin/bash`
mrsk app logs -f -r=workers
```
This commit is contained in:
Donal McBreen
2023-04-12 13:03:02 +01:00
parent 60a19f0b30
commit fb62f2e6e1
2 changed files with 3 additions and 3 deletions

View File

@@ -35,7 +35,7 @@ class Mrsk::Commander
end
def primary_host
specific_hosts&.first || config.primary_web_host
specific_hosts&.first || specific_roles&.first&.primary_host || config.primary_web_host
end
def roles

View File

@@ -47,8 +47,8 @@ class CommanderTest < ActiveSupport::TestCase
end
test "primary_host with specific hosts via role" do
@mrsk.specific_roles = "web"
assert_equal "1.1.1.1", @mrsk.primary_host
@mrsk.specific_roles = "workers"
assert_equal "1.1.1.3", @mrsk.primary_host
end
test "roles_on" do