There are many ways to install Ansible inside virtualenv on CentOS7, I would like to show now a very simple variant. Important are actually the CentOS packages at the beginning.
Steps
# install needed packages $ yum install -y python-setuptools python-devel openssl-devel libffi-devel # install pip $ easy_install pip # install virtualenv $ pip install virtualenv # create and activate virtualenv $ virtualenv .env && . .env/bin/activate # install latest ansible (.env) [demo@centos7 ~]$ pip install ansible # show python packages (.env) [demo@centos7 ~]$ pip freeze ansible==2.3.1.0 asn1crypto==0.22.0 bcrypt==3.1.3 cffi==1.10.0 cryptography==1.9 enum34==1.1.6 idna==2.5 ipaddress==1.0.18 Jinja2==2.9.6 MarkupSafe==1.0 paramiko==2.2.1 pyasn1==0.2.3 pycparser==2.17 pycrypto==2.6.1 PyNaCl==1.1.2 PyYAML==3.12 six==1.10.0 # exit virtualenv (.env) [demo@centos7 ~]$ deactivate
it can be so easy 😉