ansible使用ansible安装nginx
Posted foreverfriends
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ansible使用ansible安装nginx相关的知识,希望对你有一定的参考价值。
一、主机准备
ServerIP:10.10.10.102
ClientIP: 10.10.10.103,10.10.10.104
二、安装ansible
yum -y install ansible
三、配置免密登录
1.在Server上制作公钥和私钥
[[email protected] 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 [email protected] The key‘s randomart image is: +---[RSA 2048]----+ | . | | . o + | | + B o | | o =.X. | | . oSO*o . | | . . ..+*E.o . | | o . .=.+o.o | | . o + +.* + | | o .+.++=.o. . | +----[SHA256]-----+ [[email protected] roles]#
2.将Server上的公钥复制到Client上
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 22 [email protected]
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 22 [email protected]
#写入成功后会在10.10.10.103目录~/.ssh/下生成authorized_keys #验证免密登录是否成功,回车后能登录成功,说明设置成功 ssh [email protected]10.10.10.103
四、编写ansible相关配置文件
1.ansible的目录结构如下
以上是关于ansible使用ansible安装nginx的主要内容,如果未能解决你的问题,请参考以下文章