From 236ac64bdf23c67655d4e4fc7b4da3afbe50a106 Mon Sep 17 00:00:00 2001 From: weiliang <1067599390@qq.com> Date: Wed, 6 Sep 2023 14:35:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\241\214\346\211\247\350\241\214shell.md" | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git "a/book/\346\211\247\350\241\214\346\214\207\344\273\244\351\233\206/01\350\267\250\344\270\273\346\234\272\345\271\266\350\241\214\346\211\247\350\241\214shell.md" "b/book/\346\211\247\350\241\214\346\214\207\344\273\244\351\233\206/01\350\267\250\344\270\273\346\234\272\345\271\266\350\241\214\346\211\247\350\241\214shell.md" index caae229f..da026786 100644 --- "a/book/\346\211\247\350\241\214\346\214\207\344\273\244\351\233\206/01\350\267\250\344\270\273\346\234\272\345\271\266\350\241\214\346\211\247\350\241\214shell.md" +++ "b/book/\346\211\247\350\241\214\346\214\207\344\273\244\351\233\206/01\350\267\250\344\270\273\346\234\272\345\271\266\350\241\214\346\211\247\350\241\214shell.md" @@ -4,14 +4,14 @@ > 版本支持 -- [v0.7.16-alpha以上](https://github.com/weiliang-ms/easyctl/releases/) +- [v0.8.3以上](https://github.com/weiliang-ms/easyctl/releases/) > 兼容性 - [x] `CentOS6` - [x] `CentOS7` -### 使用方式 +### 使用方式1 > 参考以下链接进行安装 @@ -44,15 +44,45 @@ script: "1.sh" 添加`--debug`可以输出详细内容。 +### 使用方式2 + +> 生成默认配置文件 + +exec 后执行的 shell 指令需用双引号引用 + +```shell +$ easyctl exec "date" +INFO[0000] 未找到配置文件,为您生成配置文件样例, 请修改文件内容后携带 -c 参数重新执行 -> config.yaml +``` + +> 修改配置文件 + +`config.yaml`, 修改主机列表。`easyctl`根据主机列表`ssh`远程至目标主机执行`shell` + +```yaml +server: + - host: 10.10.10.[1:3] + username: root + privateKeyPath: ~/.ssh/id_rsa + password: "" + port: 22 +excludes: + - 192.168.235.132 +``` + +> 执行 + +添加`--debug`可以输出详细内容。 + ```shell -$ easyctl exec shell -c config.yaml --debug +$ easyctl exec "date" -c config.yaml --debug ``` ### 配置项说明 - 主机配置段:该段配置远程执行`shell`的主机信息,字段说明如下 - - `host: 10.10.10.[1:3]` 主机地址段,适用于`ip`连续场景。分隔符可以为`[1:3]`、`1-2`、`[1-2]`、`1:2` - - `username`: 远程主机`ssh`用户名称,缺省值为`root` + - `host: 10.10.10.[1:3]` 主机地址段,适用于`ip`连续场景。分隔符可以为`[1:3]`、`1-2`、`[1-2]`、`1:2` + - `username`: 远程主机`ssh`用户名称,缺省值为`root` - `password`: 对应`username`的密码 - `privateKeyPath`: `ssh`私钥路径 - `port`: `ssh`端口,默认`22`