码迷,mamicode.com
首页 > 其他好文 > 详细

【ansible】使用ansible安装nginx

时间:2018-07-06 21:31:11      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:tip   creat   span   免密登录   cat   key   root   rip   私钥   

一、主机准备

ServerIP:10.10.10.102

ClientIP:  10.10.10.103,10.10.10.104

 

二、安装ansible

yum -y install ansible

 

三、配置免密登录

1.在Server上制作公钥和私钥

[root@localhost roles]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory /root/.ssh.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
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:
SHA256:fsarmF7FOVq6/s2ka/VjhEIjbnEcPoQvobEqL1dV63g root@localhost.localdomain
The keys randomart image is:
+---[RSA 2048]----+
|         .       |
|      . o +      |
|       + B o     |
|      o =.X.     |
|     . oSO*o .   |
|  . . ..+*E.o .  |
|   o . .=.+o.o   |
|  . o  + +.*  +  |
|   o .+.++=.o. . |
+----[SHA256]-----+
[root@localhost roles]# 

 

2.将Server上的公钥复制到Client上

ssh-copy-id -i ~/.ssh/id_rsa.pub -p 22 root@10.10.10.103
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 22 root@10.10.10.104
#写入成功后会在10.10.10.103目录~/.ssh/下生成authorized_keys

#验证免密登录是否成功,回车后能登录成功,说明设置成功
ssh root@10.10.10.103

 

四、编写ansible相关配置文件

1.ansible的目录结构如下

 

 

【ansible】使用ansible安装nginx

标签:tip   creat   span   免密登录   cat   key   root   rip   私钥   

原文地址:https://www.cnblogs.com/xialiaoliao0911/p/9275470.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!