CentOS7 python3.6 ansible2.5 原始碼安裝
阿新 • • 發佈:2018-11-19
安裝步驟:
1° 依據《CentOS7實驗機模板搭建部署》克隆實驗機
2° 主機名和hosts配置
HOSTNAME=ansible
hostnamectl set-hostname "$HOSTNAME"
echo "$HOSTNAME">/etc/hostname
echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts
echo "$(ip a|grep "inet "|grep -v 127|awk -F'[ /]' '{print $6}') $HOSTNAME">>/etc/hosts
3° 編譯安裝Python3.6
cd /tmp
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
tar -xf Python-3.6.6.tgz
cd Python-3.6.6
yum -y install openssl-devel zlib-devel
./configure --with-ssl --enable-shared \
LDFLAGS="-Wl,-rpath /usr/local/lib"
# 使用--with-ssl引數,很多網路安裝源是https協議的
# 提前預裝openssl-devel包,否則--with-ssl引數無法生效
make && make altinstall
ln -s /usr/local/bin/pip3.6 /usr/local/bin/pip
pip install --upgrade pip
# 使用pip安裝virtualenv
pip install virtualenv
4° 配置系統使用者,原始碼安裝ansible
yum -y install git
useradd deploy
echo deploy|passwd --stdin deploy
su - deploy
# 使用 virtualenv 命令建立一個專用的python3.6環境來配置安裝使用ansible2.5
virtualenv -p /usr/local/bin/python3.6 .py3.6.env
cd .py3.6.env
source ~/.py3.6.env/bin/activate
pip install paramiko PyYAML jinja2
git clone https://github.com/ansible/ansible.git
cd ansible/
git checkout stable-2.5
source ~/.py3.6.env/ansible/hacking/env-setup -q
ansible --version
# 配置環境變數
su - deploy
echo 'source ~/.py3.6.env/bin/activate'>>~/.bash_profile
echo 'source ~/.py3.6.env/ansible/hacking/env-setup -q'>>~/.bash_profile
[TOC]