ansible部署httpd
1. 准备工作
先在ansible主机上创建一个名为file的目录用来存放软件包
[root@node1 apache]# mkdir file/
[root@node1 apache]# ls
file inventory playbook
[root@node1 apache]#
进入file目录,用wget命令在ansible主机中下载所需要的软件包
[root@node1 apache]# cd file/
[root@node1 file]# wget https://downloads.apache.org//apr/apr-1.7.0.tar.gz
[root@node1 file]# https://downloads.apache.org//apr/apr-util-1.6.1.tar.gz
[root@node1 file]# wget https://downloads.apache.org//httpd/httpd-2.4.48.tar.gz
[root@node1 file]# ls
apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz httpd-2.4.48.tar.gz
配置免密登录
[root@node1 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
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:0hlA47rthbuBHTE73hXCeZD0fcprOEj9+oiXKZGVBZI root@node1
The key's randomart image is:
+---[RSA 3072]----+
| .+.+o.. |
| . +E= .. |
| + = +o. . |
| . = *oo o |
| . = Soo o |
| * Boo o . |
| o * +.oo+ |
| . +..+= |
| +..oo.. |
+----[SHA256]-----+
//将密钥传输到远程主机
[root@node1 ~]# ssh-copy-id root@node2
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa