apt install ansible -y
# 1. 生成密钥(如果没有:检查.ssh目录下是否有id_rsa.pub)
ssh-keygen
# 2. 与被管理结点共享ssh密钥(ip根据实际情况填写)
ssh-copy-id 192.168.0.2
ssh-copy-id 192.168.0.3
ssh-copy-id 192.168.0.4
ssh-copy-id 192.168.0.5
# 1. 新建配置文件,/etc/ansible/hosts
mkdir /etc/ansible
vim /etc/ansible/hosts
# 2. 将被管理结点的信息填入,示例内容如下:
[group1]
192.168.0.2
192.168.0.3
[group2]
192.168.0.4
192.168.0.5
ansible all -m ping
# 1. 执行shell命令
ansible all -m shell -a "ls /root"
ansible group1 -m shell -a "ls /root"
# 2. 拷贝文件
ansible all -m copy -a "src=/root/test.txt dest=/home/ubuntu/test.txt"
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- yrrf.cn 版权所有 赣ICP备2024042794号-2
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务