From fb62f2e6e1746ef1b3a1e013ca1c7064f9a67f04 Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Wed, 12 Apr 2023 13:03:02 +0100 Subject: [PATCH] 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 ``` --- lib/mrsk/commander.rb | 2 +- test/commander_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mrsk/commander.rb b/lib/mrsk/commander.rb index 9dc557af..0ab0588d 100644 --- a/lib/mrsk/commander.rb +++ b/lib/mrsk/commander.rb @@ -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 diff --git a/test/commander_test.rb b/test/commander_test.rb index 245350c2..163feaf7 100644 --- a/test/commander_test.rb +++ b/test/commander_test.rb @@ -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