Search K
Appearance
Appearance
别问,问就是无脑
apt install -y ansible sshpass如果是其他系统请自行更改管理器
命令如下:
sed -i 's/^#host_key_checking.*/host_key_checking = False/g' /etc/ansible/ansible.cfg
grep checking /etc/ansible/ansible.cfg执行效果:
root@debian:~# sed -i 's/^#host_key_checking.*/host_key_checking = False/g' /etc/ansible/ansible.cfg
root@debian:~# grep checking /etc/ansible/ansible.cfg
# uncomment this to disable SSH key host checking
host_key_checking = False
# host key checking setting above.也就是把
host_key_checking设置为False
在/etc/ansible/hosts文件添加下面的内容(覆盖)
server1 ansible_ssh_host=10.1.0.3 ansible_ssh_port=22 ansible_ssh_pass=1
[hello]
server1其中:
server1 服务器名称ansible_ssh_host 服务器IP地址ansible_ssh_port 端口ansible_ssh_pass 密码ansible hello -m command -a 'echo hello world'执行效果 
ansible hello -m ping实现效果 
命令如下:
ansible hello -m command -a 'systemctl start httpd'实现效果: 

你学废了吗?
ansible从入门到入土:教你如何编写ansible剧本实现yum安装软件