Centos7安装Ansible

准备环境

1、关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

2、selinux关闭

vi /etc/sysconfig/selinux
reboot

将SELINUX设置为disabled

安装

1、安装python

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
tar xf Python-3.6.5.tar.xz
cd Python-3.6.5
./configure --prefix=/usr/local --with-ensurepip=install --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall

2、查看安装是否完成

which pip3.6

3、创建软链接

ln -s /usr/local/bin/pip3.6  /usr/local/bin/pip

4、安装virtualenv

pip install virtualenv
上面的可能会安装失败,使用下面的
pip install virtualenv -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

5、添加用户

useradd deploy
su - deploy

6、创建实例

virtualenv -p /usr/local/bin/python3.6 .py3-a2.5-env
cd /home/deploy/.py3-a2.5-env
which git
如果没有安装git ,则切换到root用户
su - root
yum -y install git nss curl

su - deploy
git clone https://github.com/ansible/ansible.git
source /home/deploy/.py3-a2.5-env/bin/activate
pip install paramiko PyYAML jinja2  -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
mv ansible .py3-a2.5-env
cd  .py3-a2.5-env/ansible
git checkout stable-2.5
source /home/deploy/.py3-a2.5-env/ansible/hacking/env-setup -q   #用来在我们虚拟环境下在加载ansible2.5版本

SSH免密码密钥认证

ssh-keygen -t rsa
ssh-copy-id -i /home/deploy/.ssh/id_rsa.pub [email protected]
有可能会报错,安装
yum install openssl-devel -y
make&&make install

你可能感兴趣的:(Centos7安装Ansible)