ansible案例

韵味老鸟 2024-06-22 13:57:20

ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能

ansible案例

Q2:执行命令

ansible all -i non-k8s-hostlists -m shell -a "cd /data/node-exporter;docker load < node-exporter.v1.5.0.tgz;"

ansible all -i non-k8s-hostlists -m shell -a "cd /data/node-exporter;docker-compose up -d"

Q1:复制文件指定用户属主和权限

ansible all -m copy -a "src=/root/install.log dest=/root/install.log.1 owner=<username> mode=<permission>" -u <remote_user> -k

ansible baidu-bj-bigdata-1 -i host.list -m copy -a "src=/data/tools/docker-compose-v1.29.2 dest=/usr/local/bin/docker-compose owner=root mode=755"

0 阅读:0