SSH executor
Similar to issue https://github.com/yohamta/dagu/issues/298 for creating a container executor, I propose the creation of a SSH executor to run tasks on remote servers
Current workaround is to execute ssh command
Thanks for the suggestion! That sounds like a really useful idea. I'm just trying to figure out how to make it a generic feature that would work for a variety of Executors, including SSH, Docker, and HTTP hooks. A naive way might be something like this. However, this approach might seem a bit complicated with more fields required for various Executors. Any ideas?
steps:
- name: step1
executor: ssh
host: xxx
port: 22
key: /home/dagu/.ssh/xxx
command: java /home/app/app.jar
- name: step2
executor: docker
context: /home/app/Dockerfile
command: node app.js
depends:
- step1
I think one way might be to extend the Executor interface.
package dag
type DAG struct {
// ...
Executor: string
ExecutorConfig: map[string]interface{}
}
package executor
type Executor interface {
SetStdout(out io.Writer)
SetStderr(out io.Writer)
Kill(sig os.Signal) error
Run() error
// For loading Executor specific config
LoadConfig(dag *dag.DAG, execConfig map[string]interface{}) error
}
In this case, the DAG is defined as follows.
steps:
- name: step1
executor: ssh
executorConfig:
host: xxx
port: 22
key: /home/dagu/.ssh/xxx
command: java /home/app/app.jar
- name: step2
executor: docker
executorConfig:
context: /home/app/Dockerfile
command: node app.js
depends:
- step1
This will work for a variety of Executors.
Your proposed solution sounds nice! 👍
On a side-note, food for thought: what if I want to run a Docker container (executor) through SSH? 😮
Thanks!
In that case, I thought we could set DOCKER_HOST environ variable to run containers on a remote server via ssh :)
steps:
- name: step1
executor: docker
env:
- DOCKER_HOST: ssh://[email protected]
executorConfig:
context: /home/app/Dockerfile
command: node app.js
Let's see if it would work.
Also, let's add the host field in the executor config.
steps:
- name: step1
executor: docker
executorConfig:
context: /home/app/Dockerfile
host: ssh://[email protected]
command: node app.js
Now I think we can implement SSH executor. Here's a gist that might be useful. https://gist.github.com/josephspurrier/e83bcdbf9e6865500004
It is now implemented in v1.9.0 but I think it will need further improvements. readme: https://github.com/yohamta/dagu#ssh-executor