【linux系统下载_学习_教程_编程_软件】提供全系列Linux发行版下载学习-Linux部落
当前位置: 主页 > Linux系统教程 > 自动化 >

centos系统Ansible安装部署

时间:2017-10-18 10:25来源:网络整理 作者:admin 点击:
------分隔线----------------------------
Ansible安装环境
服务端 172.16.1.106    
客户端 172.16.1.111

修改hosts设置主机名
172.16.1.106 host1.linuxzone.net
172.16.1.111 host2.linuxzone.net

在服务端安装ansible
[root@linuzone ~]# yum install -y epel-release
[root@linuzone ~]# yum install -y ansible

生成秘钥
[root@linuzone ~]# ssh-keygen -t rsa 
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):     #输入密码
Enter passphrase (empty for no passphrase):

将公钥上传到客户端
[root@linuzone ~]# scp .ssh/id_rsa.pub 172.16.1.111:/root/ssh/authorized_keys
[root@linuzone ~]# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized.keys
[root@linuzone ~]# chmod 600 /root/.ssh/authorized.keys
[root@linuzone ~]# setenforce 0
[root@linuzone ~]# iptables -F
[root@linuzone ~]# ssh host2.linuxzone.net
The authenticity of host 'host2.linuxzone.net(172.16.1.111)' can't be established.
RSA key fingerprint is .....
Are you sure you want to continue connecting (yes/no)? yes

安装完成

测试Ansible
修改服务端hosts文件
[root@linuzone ~]# vim /etc/ansible/hosts
[test]
127.0.0.1
172.16.1.111

[root@linuzone ~]# ansible test -m command -a 'hostname'
127.0.0.1 | success | rc=0 >>
host1.linuxzone.net

host2.linuxzone.net | success | rc=0 >>
host2.linuxzone.net

安装成功!

 

 


本文地址:http://www.linuxzone.net/auto/348.html
------分隔线----------------------------
栏目列表