ansible
准备两台虚拟机192.168.1.100 192.168.1.101
在192.168.1.100进行操作
1.安装epel
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
2.安装python-jinja2-2.7.2-4.el7
网址https://centos.pkgs.org/7/centos-x86_64/python-jinja2-2.7.2-4.el7.noarch.rpm.html
上传并安装
3 rz
4 ls
5 yum -y install epel-release-latest-7.noarch.rpm
6 echo $?
7 yum -y install python-jinja2-2.7.2-4.el7.noarch.rpm
8 echo $?
安装ansible
9 yum -y install ansible
10 echo $?
.
编辑配置文件
11 cd /etc/ansible/
12 ls
13 vim hosts
在末尾加入
192.168.1.101 ansible_ssh_user=root
ansible_ssh_pass=111
14 vim ansible.cfg
将#去掉,并将fales改为in
将#去掉
验证
15 ansible test -a ‘uptime’
ansible -m ping “test”
在192.168.1.101上创建文档1和2
17 ansible test -m command -a “touch /1” 18 ansible test -m command -a “touch /2”
在192.168.1.101上查看