1.基础环境
先换源拷贝到/etc/yum.repos.d/下
http://mirrors.163.com/.help/CentOS7-Base-163.repo
2.编写脚本文件
#!/bin/bash
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel gcc wget gcc-c++ libffi-devel python3
mkdir -p /root/.pip
cat >>/root/.pip/pip.conf<<EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF
pip3 install --upgrade pip&&pip install --upgrade setuptools&&pip3 install ansible
3.最后结果