Make an effort to match the primary_role from a list of specific roles.

This is less surprising than picking the first role and first host.
This commit is contained in:
Matthew Kent
2023-11-24 15:35:36 -08:00
parent b1dc188841
commit 79baa598fa
2 changed files with 11 additions and 1 deletions

View File

@@ -36,7 +36,8 @@ class Kamal::Commander
end
def primary_host
specific_hosts&.first || specific_roles&.first&.primary_host || config.primary_host
# Given a list of specific roles, make an effort to match up with the primary_role
specific_hosts&.first || specific_roles&.detect { |role| role.name == config.primary_role }&.primary_host || specific_roles&.first&.primary_host || config.primary_host
end
def primary_role