在本教程中,我们将向您展示怎样安装 Ansible Fedora 35. 对于那些不知道的人,Ansible 是一个开源软件供应、配置管理和应用程序部署工具,支持基础设施即代码。 Ansible 自动化并简化了重复、复杂和乏味的操作。 这是一个用 Python 编写的免费工具。
本文假设您至少具备 Linux 的基本知识,知道怎样使用 shell,最重要的是,您将网站托管在自己的 VPS 上。 安装非常简单,假设您在 root 帐户下运行,如果不是,您可能需要添加 ‘sudo
‘ 到命令以获取 root 权限。 我将向您展示 Ansible 自动化工具的逐步安装 Fedora 35.
安装 Ansible Fedora 35
步骤 1. 在继续之前,请更新您的 Fedora 操作系统以确保所有现有软件包都是最新的。 使用此命令更新服务器包:
sudo dnf upgrade sudo dnf update
步骤 2. 安装 Python。
Ansible 是用 Python 编写的,现在我们将 Python 安装在 Fedora 系统使用以下命令:
sudo dnf install python3 sudo dnf install python3-pip
步骤 3. 安装 Ansible Fedora 35.
默认情况下,Ansible 在 Fedora 35 个基础存储库。 现在运行以下命令来安装它:
sudo dnf install ansible
我们可以通过运行以下命令来验证 Ansible 版本:
ansible --version
输出:
ansible 2.9.30 config file =/etc/ansible/ansible.cfg configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location =/usr/lib/python3.8/site-packages/ansible executable location =/usr/bin/ansible python version =3.9.8 (default, Dec 10 2021, 00:11:01) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]
第 4 步:测试 Ansible。
现在我们使用 ssh-keygen
你的命令 Fedora:
ssh-keygen
输出:
Generating public/private rsa key pair. Enter file in which to save the key (/home/idroot/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/idroot/.ssh/id_rsa. Your public key has been saved in /home/idroot/.ssh/id_rsa.pub. The key fingerprint is: SHA256:vRdPlegZg1meilana0jQsiTYmariaSnuUQj3g [email protected] The key's randomart image is: +---[RSA 3072]----+ | oo . | | o.ooo+ o| | .o+*O=o*.| | ooE**=B..| | S++X+=o. | | =+.=o..| | . . o..| | . | | | +----[SHA256]-----+
接下来,将 id 复制到远程服务器:
ssh-copy-id [email protected]
之后,在控制机器上创建如下清单文件:
nano hosts
添加以下文件:
192.168.77.21 ansible_ssh_user=fedora
最后,使用 ping 模块测试 ansible:
ansible -i hosts 192.168.77.21 -m ping
输出:
192.168.77.21 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong" }
恭喜! 您已成功安装 Ansible。 感谢您使用本教程在您的计算机上安装 Ansible 自动化工具 Fedora 35系统。 如需更多帮助或有用信息,我们建议您查看 Ansible 官方网站.