ansible生产实践一 二进制安装ansible
原创
©著作权归作者所有:来自51CTO博客作者哭泣的馒头的原创作品,请联系作者获取转载授权,否则将追究法律责任
一、下载安装包
1、下载ansible安装包
https://releases.ansible.com/ansible/
下载:
ansible-2.9.5.tar.gz
ansible-2.9.9.tar.gz
2、下载python
https://www.python.org/downloads/
Python-3.8.12.tar.xz
二、安装编译
1、安装python,配置pip
1、gcc --version
2、安装python
tar -xvf Python-3.8.12.tar.xz
cd Python-3.8.12
./configure --prefix=/usr/local/python3.8
make && make install
linux默认自带的python是2.7.5
3、添加软连接
rm -f /usr/bin/python /usr/bin/pip
ln -s /usr/local/python3.8/bin/python3.8 /usr/bin/python
ln -s /usr/local/python3.8/bin/pip3.8 /usr/bin/pip
4、配置pip源
mkdir /root/.pip
[root@k8s01 bin]
[global]
index-url = https://mirrors.huaweicloud.com/repository/pypi/simple
trusted-host = mirrors.huaweicloud.com
timeout = 120
2、安装ansible
1、解压并安装
tar -xvf ansible-2.9.5.tar.gz
cd ansible-2.9.5
python setup.py install
报错:
Ansible now needs setuptools in order to build. Install it using your package manager
(usually python-setuptools) or via pip (pip install setuptools).
安装依赖:
更新pip
python -m pip install --upgrade pip
卸载并重装setuptools
pip uninstall setuptools
pip install setuptools
2、继续安装
python setup.py install
3、添加软连接
ansible安装完默认都安装到/usr/local/python3.8/bin下面
ln -s /usr/local/python3.8/bin/ansible* /usr/bin/
4、创建默认配置文件
二进制安装的,配置文件在解压包里面有个模板
mkdir /etc/ansible
cp /root/ansible-2.9.5/examples/ansible.cfg /etc/ansible
5、验证
ansible localhost -m ping