标签:inux 测试 生成 http ext for install 管理机 自己
配置环境:下载ansible
yum install ansible -y
生成公钥私钥:
ssh-keygen
一路回车
进到.ssh下
cd .ssh
将公钥上传到被管理机
ssh-copy-id -i root@192.168.43.213(被管理机ip)
```![](https://s1.51cto.com/images/blog/201908/09/6bb30d231e20827a06a624c3b0ebb87a.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
此时 被管理机的.ssh目录下会自动生成一个 ** authorized_keys**
![](https://s1.51cto.com/images/blog/201908/09/de2c57bf2ebf8f9af34f5bae246be591.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
编辑配置文件
vim /etc/ansible/hosts
在末端添加一个模块
![](https://s1.51cto.com/images/blog/201908/09/7053afce19005fe916e090c32cb53486.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
测试连接
ansible -m ping ‘test-servers‘
![](https://s1.51cto.com/images/blog/201908/09/2c421c49529431bb659548ab95681021.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
自己在家目录下创建一个文件传到被管理机的/tmp下(we.txt是我创建的)创建成功后会出现如下所示:
ansible test-servers -m copy -a "src=/root/we.txt dest=/tmp/ owner=root group=root mode=0755 force=yes"
![](https://s1.51cto.com/images/blog/201908/09/c73f3ecde1eb6c83957996fb63ba5e70.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
此时在被管理机的/tmp目录下会接收到管理机传输的文件
![](https://s1.51cto.com/images/blog/201908/09/8e9a19411f5b1f1dab4fc99da887c747.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
标签:inux 测试 生成 http ext for install 管理机 自己
原文地址:https://blog.51cto.com/14375810/2428082