Ansible 安装测试

sudo apt update
sudo apt install ansible
sudo vim /etc/ansible/hosts

[ceshi3]
192.168.1.181 ansible_ssh_user='cla' ansible_ssh_pass='cla' ansible_ssh_port=22
192.168.1.182 ansible_ssh_user='cla' ansible_ssh_pass='cla' ansible_ssh_port=22
192.168.1.183 ansible_ssh_user='cla' ansible_ssh_pass='cla' ansible_ssh_port=22

测试:

cla@cla:~$ ansible ceshi3 -a 'date'
192.168.1.183 | SUCCESS | rc=0 >>
Wed Sep 25 18:19:45 CST 2019

192.168.1.182 | SUCCESS | rc=0 >>
Wed Sep 25 18:19:45 CST 2019

192.168.1.181 | SUCCESS | rc=0 >>
Wed Sep 25 18:19:45 CST 2019
可能会出现一下错误
192.168.1.181 | FAILED | rc=0 >>
ERROR! Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host.


# 如果出现以上错误,要先用ssh登录一下
cla@cla:~$ ssh cla@192.168.1.181
The authenticity of host '192.168.1.181 (192.168.1.181)' can't be established.
ECDSA key fingerprint is SHA256:XP/3w0dm+2cg0qxSCDjQtjJo5Zg/020+s5H45yo7IDo.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.181' (ECDSA) to the list of known hosts.
cla@192.168.1.181's password:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值