CentOS8 安装ansible

CentOS8 无法使用yum进行ansible安装,此次使用pip install ansible来安装ansible
大概步骤
1,编译安装升级python,centos8系统自动安装的python3.6版本过低,安装ansible时会有警告
2,安装pip
3,pip install ansible

python编译安装

1,安装epel源

yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
wget https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-8.noarch.rpm
rpm -ivh epel-next-release-latest-8.noarch.rpm

2,下载python

wget https://www.python.org/ftp/python/3.12.3/Python-3.12.3.tgz

3,解压python安装包

tar -zxvf Python-3.12.3.tgz

4,编译安装python
安装系统需要的一些包

dnf -y install gcc zlib* libffi-devel openssl-devel make 

删除系统自带的python3

rm -rf /usr/local/python3

编译安装python3

cd Python-3.12.3/
./configure --prefix=/usr/local/python3 --enable-optimizations
make
make instal

切换到普通用户

su - qxh4819
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
chmod +x get-pip.py
python3 get-pip.py --user
echo 'export PATH=/usr/local/python3/bin:$PATH' >>~/.bashrc
source ~/.bashrc

pip install ansible

python3 -m pip install --user ansible
python3 -m pip install --user ansible-core
ansible --version
ansible [core 2.16.6]
  config file = None
  configured module search path = ['/home/qxh4819/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/qxh4819/.local/lib/python3.12/site-packages/ansible
  ansible collection location = /home/qxh4819/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/qxh4819/.local/bin/ansible
  python version = 3.12.3 (main, Apr 16 2024, 16:59:46) [GCC 8.5.0 20210514 (Red Hat 8.5.0-4)] (/usr/local/python3/bin/python3)
  jinja version = 3.1.3
  libyaml = True
python3 --version
Python 3.12.3

5, 可用的一些网页
https://www.python.org/ftp/python/3.12.3/Python-3.12.3.tgz
https://pypi.org/simple/pip/
https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html
https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/p/
https://docs.w3cub.com/ansible~2.11/installation_guide/intro_installation.html#installing-ansible-on-rhel-centos-or-fedora
https://blog.****.net/m0_73823239/article/details/134990021?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0-134990021-blog-103934722.235v43pc_blog_bottom_relevance_base8&spm=1001.2101.3001.4242.1&utm_relevant_index=1
https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#locating-python

上一篇:Django-admin组件


下一篇:2024年华为OD机试真题-智能驾驶-Python-OD统一考试(C卷D卷)