Repository: basecamp/kamal (Ruby)

Issue:
kamal app exec -r "job" leads to "No such container" 
Hey,
I discovered that the wrong container is executed when running `kamal app exec` on the container with the `job` role (as opposed to the `app` role) with or without the `--reuse` parameter. Specifically, the container with the `-web-` part in its name is run instead of the expected `-job-` container, leading to `No such container` error.

```
# deploy.yml
servers:
  web:
    hosts:
      - 192.168.0.1
  job:
    hosts:
      - 192.168.0.2
    cmd: bin/sidekiq

# command
kamal app exec -i -r job --reuse 'bin/rails console'

# command output
Get current version of running container...
  INFO [60450d97] Running docker ps --filter label=service=my-app --filter label=destination=production --filter label=role=job --filter status=running --filter status=restarting --latest --format "{{.Names}}" | while read line; do echo ${line#my-app-job-production-}; done on 49.12.205.26
  INFO [60450d97] Finished in 1.969 seconds with exit status 0 (successful).
Launching interactive command with version ae02a03a80b50d23044775849f206736b21f682a_uncommitted_0ec40738dc63d21e via SSH from existing container on 49.12.205.26...
Error response from daemon: No such container: my-app-web-production-ae02a03a80b50d23044775849f206736b21f682a_uncommitted_0ec40738dc63d21e
Connection to 49.12.205.26 closed.
```



Fix (patch):
diff --git a/lib/kamal/cli/app.rb b/lib/kamal/cli/app.rb
index 6ba8908ae..601d485e6 100644
--- a/lib/kamal/cli/app.rb
+++ b/lib/kamal/cli/app.rb
@@ -115,14 +115,16 @@ def exec(cmd)
       say "Get current version of running container...", :magenta unless options[:version]
       using_version(options[:version] || current_running_version) do |version|
         say "Launching interactive command with version #{version} via SSH from existing container on #{KAMAL.primary_host}...", :magenta
-        run_locally { exec KAMAL.app(role: "web").execute_in_existing_container_over_ssh(cmd, host: KAMAL.primary_host) }
+        run_locally { exec KAMAL.app(role: KAMAL.primary_role).execute_in_existing_container_over_ssh(cmd, host: KAMAL.primary_host) }
       end
 
     when options[:interactive]
       say "Get most recent version available as an image...", :magenta unless options[:version]
       using_version(version_or_latest) do |version|
         say "Launching interactive command with version #{version} via SSH from new container on #{KAMAL.primary_host}...", :magenta
-        run_locally { exec KAMAL.app(role: KAMAL.roles_on(KAMAL.primary_host).first).execute_in_new_container_over_ssh(cmd, host: KAMAL.primary_host) }
+        run_locally do
+          exec KAMAL.app(role: KAMAL.primary_role).execute_in_new_container_over_ssh(cmd, host: KAMAL.primary_host)
+        end
       end
 
     when options[:reuse]
diff --git a/lib/kamal/commander.rb b/lib/kamal/commander.rb
index 92717b103..9ba3be122 100644
--- a/lib/kamal/commander.rb
+++ b/lib/kamal/commander.rb
@@ -39,6 +39,10 @@ def primary_host
     specific_hosts&.first || specific_roles&.first&.primary_host || config.primary_web_host
   end
 
+  def primary_role
+    roles_on(primary_host).first
+  end
+
   def roles
     (specific_roles || config.roles).select do |role|
       ((specific_hosts || config.all_hosts) & role.hosts).any?