ITPub博客

首页 > IT基础架构 > > ansible安装及使用

ansible安装及使用

作者:deepocean601 时间:2019-09-09 16:08:01 0 删除 编辑

Director:

192.168.0.118 director.shamereedwine.com dr

webserver:

node1:node1.shamereedwine.com(192.168.0.119)

node2:node2.shamereedwine.com(192.168.0.120)

dbserver:

node2.shamereedwine.com(192.168.0.120)

node3.shamereedwine.com(192.168.0.122)

一、安装ansible

DR上

1、配置epel的yum源,使用yum安装ansible

yum install ansible

二、各节点配置互信

1、各节点上编辑/etc/hosts配置文件,以实现各主机的互相解析,配置如下:

192.168.0.118 director.shamereedwine.com dr

192.168.0.119 node1.shamereedwine.com node1

192.168.0.120 node2.shamereedwine.com node2

192.168.0.122 node3.shamereedwine.com node3

2、dr节点配置ssh互信

[root@localhost ~]# ssh-keygen -t rsa -P ''

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): 

Created directory '/root/.ssh'.

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

a5:ce:85:ba:74:67:51:3c:ae:4b:0d:7e:d6:4d:ef:e1 root@director.shamereedwine.com

The key's randomart image is:

+--[ RSA 2048]----+

|                 |

|           .     |

|          . +    |

|         + o .   |

|        S + .   .|

|       + o = . o.|

|      o + * + ..o|

|     . o + +  ...|

|      .   .    E.|

+-----------------+

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node1.shamereedwine.com

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node2.shamereedwine.com

The authenticity of host 'node2.shamereedwine.com (192.168.0.120)' can't be established.

RSA key fingerprint is cf:98:8a:b1:33:6d:1b:6c:85:34:54:0b:33:f5:27:99.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'node2.shamereedwine.com,192.168.0.120' (RSA) to the list of known hosts.

root@node2.shamereedwine.com's password: 

Now try logging into the machine, with "ssh 'root@node2.shamereedwine.com'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub root@node3.shamereedwine.com

The authenticity of host 'node3.shamereedwine.com (192.168.0.122)' can't be established.

RSA key fingerprint is cf:98:8a:b1:33:6d:1b:6c:85:34:54:0b:33:f5:27:99.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'node3.shamereedwine.com,192.168.0.122' (RSA) to the list of known hosts.

root@node3.shamereedwine.com's password: 

Now try logging into the machine, with "ssh 'root@node3.shamereedwine.com'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

三、使用ansible

1、探测各节点是否在线

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2557/viewspace-3164363/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: python整数和变量
请登录后发表评论 登录
全部评论

注册时间:2019-08-16

  • 博文量
    102
  • 访问量
    475