3个版本
0.1.2 | 2022年12月31日 |
---|---|
0.1.1 | 2022年12月31日 |
0.1.0 | 2022年12月31日 |
#56 in #execute-command
47KB
941 行
那里
那里 (以下简称 "那里" 或 there
) 是
- 一个用于在本地和远程主机上通用计划和管理任务的库。
- crates.io
- 任务被编译成可执行的
sh(1)
命令。 - 非原始命令任务在执行前会尝试验证先决条件。
- 一个用于通过以下方式应用计划的命令行界面
- 本地执行
- 远程SSH
- 代理控制器SSH
- 远程SSH执行的代理控制器对。
最低支持的Rust版本:1.66
功能
库
- 基于Tokio,完全异步
- 可插拔执行后端
- 本地
- SSH
- 自己实现
Executor
!
- 异步日志流
- 可插拔日志流后端
- 内存
- 自己实现
LogSource
/LogSink
!
- 代理控制器共享IPC结构
- 计划验证
- 将任务编译成
sh(1)
兼容的命令
- 将任务编译成
- 主机文件 + 主机组
- 完全使用
tracing::instrument
仪器化- 基于
tracing
的日志,可以使用tracing-subscriber
消费 - 基于
color_eyre
的错误报告- 用于在CLI/代理/控制器之间共享错误实现
- 基于
CLI
- 默认日志流
- 本地执行
- SSH执行
- 代理控制器执行
- 计划验证
设置
安装 pre-commit。
pre-commit install
pre-commit autoupdate
cargo install cargo-audit
用法
目前尚无文档。有关计划/主机文件示例,请参考 test/*.yaml
。
待办事项
- 带有 makeup 的日志流的美观tui
展示一些漂亮的东东
git:(mistress) | ▶ cargo run -p there-cli -- plan apply --dry -f ./test/ssh-plan.yaml --hosts ./test/ssh-hosts.yaml # ...
*** plan: test plan ***
* metadata
** hosts:
*** group: ssh-group
**** broken-ssh: localhost:2222 (ssh)
**** ssh-localhost: localhost:22 (ssh)
** test command: echo hello world!
*** ExeExists { exe: "echo" }
** test command 2: echo hello world!! :D
*** ExeExists { exe: "echo" }
** test command 2: echo wow!!!!!
*** ExeExists { exe: "echo" }
** create some file: touch /tmp/some-file
*** ExeExists { exe: "touch" }
*** DirectoryExists { path: "/tmp" }
git:(mistress) 1 | ▶ cargo run -p there-cli -- plan apply -f ./test/ssh-plan.yaml --hosts ./test/ssh-hosts.yaml # ...
*** applying plan to group: ssh-group ***
*** prepared plan for host: broken-ssh
*** prepared plan for host: ssh-localhost
broken-ssh: * steps: 4
ssh-localhost: * steps: 4
broken-ssh: ssh authentication failed!
*** failed plan: test plan for host: broken-ssh: 0/4 ***
*** error: ssh executor failed to apply plan test plan to host broken-ssh: 0/4 tasks finished: ssh authentication failed!
ssh-localhost: ** executing task: test command
ssh-localhost: ensuring ExeExists { exe: "echo" }
ssh-localhost: /bin/echo
ssh-localhost:
ssh-localhost: hello world!
ssh-localhost:
ssh-localhost:
ssh-localhost: ** executing task: test command 2
ssh-localhost: ensuring ExeExists { exe: "echo" }
ssh-localhost: /bin/echo
ssh-localhost:
ssh-localhost: hello world!! :D
ssh-localhost:
ssh-localhost:
ssh-localhost: ** executing task: test command 2
ssh-localhost: ensuring ExeExists { exe: "echo" }
ssh-localhost: /bin/echo
ssh-localhost:
ssh-localhost: wow!!!!!
ssh-localhost:
ssh-localhost:
ssh-localhost: ** executing task: create some file
ssh-localhost: ensuring ExeExists { exe: "touch" }
ssh-localhost: /bin/touch
ssh-localhost:
ssh-localhost: ensuring DirectoryExists { path: "/tmp" }
ssh-localhost:
ssh-localhost: *** finished applying plan: test plan -> ssh-localhost (4/4)
*** completed plan: test plan for host: ssh-localhost: 4/4 ***
git:(mistress) 1 | ▶
依赖项
~31–46MB
~528K SLoC