Ubuntu下Ansible安装和使用

Ansible是一个批量部署的工具

参考:Ansible中文权威指南

1.安装

sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible

2.在/etc/ansible/hosts文件中添加服务器的ip

vim /etc/ansible/hosts

3.需要将自己机器的~/.ssh/目录下公钥,即pub文件,添加到服务器的~/.ssh/authorized_keys文件中

vim ~/.ssh/authorized_keys

测试ssh是否可以免密登录

4.测试能否ping通,以root用户登录

ansible all -m ping -u root

5.测试建立一个test文件夹

ansible all -u root -a "/bin/mkdir test"

猜你喜欢

转载自www.cnblogs.com/tonglin0325/p/9074958.html