在Ubuntu/RHEL/CentOS/Rocky/macOS上安装Ansible
本文介绍在Ubuntu/RHEL 8/CentOS 8/Rocky Linux 8/macOS系统上安装Ansible的方法,全部都是采用命令来安装的。其中,在macOS系统上,只需要执行brew install ansible命令即可安装好Ansible。
在Ubuntu系统上安装Ansible的命令
sudo apt update
sudo apt install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
注:如果使用的是Debian系统,请看在Debian 11 Linux系统上安装和使用Ansible的方法,阅读地址在https://www.hmxthome.com/linux/5145.html
在RHEL 8/CentOS 8/Rocky Linux 8系统上安装Ansible的命令
sudo dnf install python3 python3-pip -y
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install --enablerepo epel-playground ansible
sudo yum install ansible
在macOS系统上安装Ansible的命令
brew install ansible
验证是否成功安装了Ansible
采用以下命令验证是否成功安装了Ansible,会返回Ansible版本的相关信息:
$ which ansible
/usr/bin/ansible
$ ansible --version
ansible [core 2.14.5]
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/dist-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
注:以上信息表明,所安装的版本是ansible [core 2.14.5]。