# wrench **Repository Path**: markguo123/wrench ## Basic Information - **Project Name**: wrench - **Description**: 使用 golang 实现模拟 ansible 的工具,基于ssh并发执行命令、脚本、文件文件传输,支持外部插件,支持j2格式渲染 - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: develop - **Homepage**: https://gitee.com/sikaodiwei/wrench - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2024-09-11 - **Last Updated**: 2024-09-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 编译: go mod tidy go build -o wrench wrench.go 选项: [root@k8s-m1 wrench]# ./wrench --help Usage of ./wrench: -C 清除此次执行缓存 -c string 指定命令,以分号做分隔符,覆盖配置文件中的task模块 -console 控制台模式 -cpuprofile string 记录CPU使用情况到文件 -f string 指定配置文件 (default "conf/wrench.yml") -g string 指定主机组,以逗号分隔 -i string 指定主机列表文件 (default "conf/hosts") -l string 指定日志级别,< error warn info debug trace > (default "info") -ping 只判断主机是否可达 -r string 按主机名做正则过滤,以逗号分隔 -t string 指定模板文件 (default "renderfile") [root@k8s-m1 wrench]# --- 功能说明: 1.远程并行执行命令; 2.远程并行同步文件,并保留权限; 3.以主机为基本单位并发,每模块的命令按顺序执行,最多10倍CPU线程数并发; 各别主机执行失败不影响其它机器上的执行 wrench [-f configfile] 4.console模式: wrench -console [-f configfile] 5.支持jinjia2格式渲染文件; 6.支持指定组名,指定组名时支持正则; 7.支持自定义插件,对应变量在目标机器声明为环境变量; 8.自远程拉取文件,并保留权限; 9.支持按主机名过滤; 10.做为中转从其中一台主机向其它主机同步文件; 11.使用script模块时,对应变量在目标机器声明为环境变量; 12.同步文件时支持排除列表; --- 配置文件格式: group: - m filter: # - golang # - m task: - plugin: - name: date env: /usr/bin/sh var: - a=1 - b=2 - shell: - name: shell1 sudo: false env: /usr/bin/sh cmd: - cat /tmp/date.txt --- 参数文件: 支持toml格式文件解析 --- 主机列表文件: [[group]] host_ip="10.1.8.155" host_name="k8s-m2" host_user="root" host_pass="redaht" host_ssh_type="password" host_key_path="/root/.ssh/id_rsa" host_port="22" k1="v1" k2="v2" clusterName="etcd-02" host_ip="10.1.8.151" host_name="k8s-m3" host_user="root" host_pass="redaht" host_ssh_type="password" host_key_path="/root/.ssh/id_rsa" host_port="22" k1="v1" k2="v2" clusterName="etcd-03" host_ip="10.1.8.150" host_name="k8s-n1" host_user="root" host_pass="redaht" host_ssh_type="password" host_key_path="/root/.ssh/id_rsa" host_port="22" k1="v1" k2="v2" clusterName="etcd-01" host_ip="10.1.8.[156:180]" host_name="k8s-n1" host_user="root" host_pass="redaht" host_ssh_type="password" host_key_path="/root/.ssh/id_rsa" host_port="22" k1="v1" k2="v2" clusterName="etcd-01" [[m]] host_ip="10.1.8.171" host_name="k8s-m1" host_user="root" host_pass="redaht" host_ssh_type="password" host_key_path="/root/.ssh/id_rsa" host_port="22" k1="v1" k2="v2"