ansible-基於python3的環境搭建
阿新 • • 發佈:2020-12-11
python3 原始碼編譯
# 編譯環境準備 yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel \ ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel -y # 下載python3原始碼 curl https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tgz -o Python-3.8.6.tgz # 解壓 tar xvf Python-3.8.6.tgz # 編譯配置 cd Python-3.8.6 ./configure --prefix=/usr/local/python38 # 開始編譯 make -j4 # 安裝編譯檔案 make install
安裝ansible
/usr/local/python38/bin/pip3 install ansible -i https://mirrors.aliyun.com/pypi/simple
本機使用
# 新增軟鏈
ln -s /usr/local/python38/bin/python3 /usr/bin/python3
ln -s /usr/local/python38/bin/ansible /usr/bin/ansible
ln -s /usr/local/python38/bin/ansible-playbook /usr/bin/ansible-playbook
打包離線使用
# 打包為壓縮包 tar zcvf python38.tgz /usr/local/python38/ # 直接將壓縮包在目標機解壓,新增軟鏈即可使用 tar xvf python38.tgz -C / ln -s /usr/local/python38/bin/python3 /usr/bin/python3 ln -s /usr/local/python38/bin/ansible /usr/bin/ansible ln -s /usr/local/python38/bin/ansible-playbook /usr/bin/ansible-playbook