skip to Main Content

I am trying to install ansible on CentOS 8 but no success, After searching google i did following steps

yum install python3-pip
pip3 install ansible

but it shows following output and no ansible avaiable

[root@okd1 ~]# pip3 install ansible
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Requirement already satisfied: ansible in ./.local/lib/python3.6/site-packages
Requirement already satisfied: jinja2 in ./.local/lib/python3.6/site-packages (from ansible)
Requirement already satisfied: PyYAML in /usr/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: cryptography in /usr/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: MarkupSafe>=0.23 in ./.local/lib/python3.6/site-packages (from jinja2->ansible)
Requirement already satisfied: idna>=2.1 in /usr/lib/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/lib/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: six>=1.4.1 in /usr/lib/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: cffi!=1.11.3,>=1.7 in /usr/lib64/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: pycparser in /usr/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography->ansible)

i tried to manually download and install but still no success

curl -o ansible.rpm https://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/ansible-2.8.5-1.el7.ans.noarch.rpm

[root@okd1 ~]# yum install ansible.rpm
Last metadata expiration check: 0:09:14 ago on Wed 25 Sep 2019 05:39:22 PM EDT.
Error: 
 Problem: conflicting requests
  - nothing provides python-setuptools needed by ansible-2.8.5-1.el7.ans.noarch
  - nothing provides python-six needed by ansible-2.8.5-1.el7.ans.noarch
  - nothing provides PyYAML needed by ansible-2.8.5-1.el7.ans.noarch
  - nothing provides python-jinja2 needed by ansible-2.8.5-1.el7.ans.noarch
  - nothing provides python-paramiko needed by ansible-2.8.5-1.el7.ans.noarch
  - nothing provides python2-cryptography needed by ansible-2.8.5-1.el7.ans.noarch
  - nothing provides sshpass needed by ansible-2.8.5-1.el7.ans.noarch
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

then tried to deploy these packages but no success

[root@okd1 ~]# pip3 install python-setuptools
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting python-setuptools
  Could not find a version that satisfies the requirement python-setuptools (from versions: )
No matching distribution found for python-setuptools
[root@okd1 ~]# 
[root@okd1 ~]# pip2 install python-setuptools
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip2 install --user` instead.
Collecting python-setuptools
  Could not find a version that satisfies the requirement python-setuptools (from versions: )
No matching distribution found for python-setuptools

2

Answers


  1. You see one warning, which you should take very seriously if you don’t want to destroy files, that were installed via yum packages. which is

    Running pip install with root privileges is generally not a good idea.
    Try pip3 install --user instead.

    I suggest to try using a virtualenv. Using a virtualenv reduces the probability to destroy an existing setup and allows you to have different package versions per virtualenv. Just do not forget to activate your virtualenv before pip installing into it.

    Unfortunately Ansible has (had at least when I used it last time) a small issue, that it will not be able to install packages if you use a virtualenv which does not include system site packages, so I’m not 100% sure, you will be successful.

    I try to walk you through following:
    1.) install virtualenv (either with yum or with pip install, but in order to not destroy anything in your existing setup you’d use pip install with the --user option)
    2.) create a virtualenv for python3 with system site packages enabled as you will have issues with ansible and package installation otherwise
    3.) enable your virtualenv (Do not forget this!)
    4.) Check that you really enabled your virtualenv
    5.) pip install ansible with the -U option

    Try out ansible and specify the path to the python executable of your virtualenv in with the ansible_python_interpreter setting of ansible ( https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html )
    Collecting python-setuptools
    You might try to use a virtualenv in order to avoid conflicts with existing packages.

    You might try something like:

    sudo pip install --user virtualenv # or install virtualenv with yum if you know the package name.

    then

    virtualenv -p $(which python3) /root/ansiblevenv --system-site-packages

    now activate the virutalenv

    . /root/ansiblevenv/bin/activate # do not forget the space between the . and the /

    Now check, that the active python is the one of the virtualenv

    type python

    you should see /root/ansiblevenv/bin/python instead if ‘usr/bin/python’ if not the virtualenv is not enabled properly

    Now update pip (just in case)

    pip install -U pip

    and now try to install ansible

    pip install -U ansible

    Login or Signup to reply.
  2. You can also use the below steps to install Ansible on CentOS 8.

    Step 1: Installation of EPEL repository

    Ansible is not available in the default repository. So, to install it, we have to enable the EPEL repository. Firstly, we are going to install epel-release. Use the below command to install it.

    sudo dnf -y install epel-release
    

    Note: you can also use yum command instead of dnf

    Step 2: Installing Ansible on CentOS 8

    let’s install Ansible. Use the below command for this installation.

    sudo dnf -y install ansible
    

    Once the installation is completed, then use the below command to verify the version.

    ansible --version
    

    That’s it. But you can read more about ansible installation on CentOS8 related commands for managed node and other details. You can visit my blog post for Ansible. You can use the URL below.

    How to install and configure Ansible on CentOS 8

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search