Ansible安装方式
yum方式安装
适用于CentOS7安装ansible, 需要先安装配置epel源
yum -y install epel-release
yum -y install ansible sshpass
dnf方式安装
适用于CentOS Linux 8
dnf config-manager --set-enabled powertools
dnf -y install epel-release
dnf -y install ansible
适用于CentOS Stream 8
dnf config-manager --set-enabled powertools
dnf install epel-release epel-next-release
dnf -y install ansible
apt方式安装
适用于Ubuntu系列Linux版本,配置PPA源及安装ansible
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible sshpass
pip方式安装
使用Centos7 自带python安装
yum -y install python-pip
pip install ansible
安装Python3,使用pip3安装
anaconda3官网的miniconda3下载地址
清华minconda3下载地址
国内推荐在清华镜像站进行下载,网速会快一些。
wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh
bash Miniconda3-py39_4.9.2-Linux-x86_64.sh
conda3使用
查看虚拟环境
conda env list
创建虚拟环境
conda create -n abe_env python=3.7
激活虚拟环境
conda activate abe_env
安装ansible
pip3 install ansible
退出虚拟环境
conda deactivate abe_env
注意: 退出abe_env虚拟环境,则ansible相关命令无法使用,只有激活此虚拟环境或者配置环境变量才可以使用ansible相关命令。
关于如何使用minconda3和配置conda源请参考我的另一篇博客: 配置minconda3环境和conda源