diff --git a/lib/kamal/cli/app.rb b/lib/kamal/cli/app.rb index 601d485e6..fae607fcf 100644 --- a/lib/kamal/cli/app.rb +++ b/lib/kamal/cli/app.rb @@ -147,8 +147,12 @@ def exec(cmd) using_version(version_or_latest) do |version| say "Launching command with version #{version} from new container...", :magenta on(KAMAL.hosts) do |host| - execute *KAMAL.auditor.record("Executed cmd '#{cmd}' on app version #{version}"), verbosity: :debug - puts_by_host host, capture_with_info(*KAMAL.app.execute_in_new_container(cmd)) + roles = KAMAL.roles_on(host) + + roles.each do |role| + execute *KAMAL.auditor.record("Executed cmd '#{cmd}' on app version #{version}"), verbosity: :debug + puts_by_host host, capture_with_info(*KAMAL.app(role: role).execute_in_new_container(cmd)) + end end end end diff --git a/test/cli/app_test.rb b/test/cli/app_test.rb index c70b8ed49..fd1064213 100644 --- a/test/cli/app_test.rb +++ b/test/cli/app_test.rb @@ -159,7 +159,7 @@ class CliAppTest < CliTestCase test "exec" do run_command("exec", "ruby -v").tap do |output| - assert_match "docker run --rm dhh/app:latest ruby -v", output + assert_match "docker run --rm --env-file .kamal/env/roles/app-web.env dhh/app:latest ruby -v", output end end