0

I cannot suceed to install ansible, I know the basic command is:

yum install ansible

but the output is:

[root@localhost ~]# yum install ansible Last metadata expiration check: 0:36:48 ago on Sun 13 Oct 2019 13:27:03 CEST. Error:   Problem: conflicting requests
  - nothing provides PyYAML needed by ansible-2.8.5-1.el7.noarch
  - nothing provides python-setuptools needed by ansible-2.8.5-1.el7.noarch
  - nothing provides python-six needed by ansible-2.8.5-1.el7.noarch
  - nothing provides python-jinja2 needed by ansible-2.8.5-1.el7.noarch
  - nothing provides python2-cryptography needed by ansible-2.8.5-1.el7.noarch 
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

I already tryed the following commands:

yum install -y epel-release yum install -y

https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum -y install python2

yum install python3-pip

pip3 install ansible

The output of ansible --version is:

[root@localhost ~]# ansible --version ansible 2.8.5
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.8 (default, Oct 7 2019, 17:58:22) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]

Any help are greatly appreciated.

  • 1
    While the wrong one probably works (due to yum variables) you really ought to install the epel-release package intended for CentOS 8 instead of 7. dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm – jsbillings Oct 15 at 1:00
  • Like @jsbillings says, you need to use the right tool for the right job. Enabling epel-el7 wont deliver any packages to an el8 distribution. Also, like some answers say, you can easily install ansible via python3 and pip. – 0xSheepdog Oct 29 at 20:13
0

You should install python and pip:

sudo yum install python3 python3-pip

After this you'll are able to run:

sudo pip3 install ansible

Ansible successfully installed on CentOS 8

  • Thank you, the output is WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user` instead.` Do you have a command to check is ansible was successfully installed ? – Ced Oct 13 at 12:52
  • because ansible --version show config file = None – Ced Oct 13 at 12:58
  • I would say: Don't install ansible at all. Use container wrapped ansible. hub.docker.com/search?q=ansible&type=image – ozlev Oct 13 at 13:36
  • might be preferable to install it with "--user" depending on usecase. Also, 'sudo pip install blah' is really, really, really unsafe. Really. – 0xSheepdog Oct 29 at 20:14
0

It's well noted in one comment that pip should never bee run as sudo / under root user. Why is because it will very easily going to mess up RPM packaged Python packages with the ones installed by pip. Sooner or later something will stop working on this mess.

From how to install Ansible in CentOS/RHEL 8, for CentOS 8 (in lack of subscription-based repository that RHEL 8 has), you can use virtualenv for a safe install:

sudo yum install python3 python3-virtualenv python3-pip

cd ~
mkdir ansible
virtualenv-3 ansible
. ansible/bin/activate
pip3 install ansible

Then you can directly invoke ~/ansible/bin/ansible-playbook or add ~/ansible/bin to your PATH environment variable to just run it with ansible.

0

How To Install Latest Ansible on EL8 distributions without EPEL, RPM/YUM/DNF, etc.

First, ensure python3 and python-installer are installed (using a root shell)...
(ok we ARE using Yum here, but only to make sure python3 and pip are installed.)

# yum install -y python3 python3-pip

and configured as the correct alternative for 'python'.

# alternatives --set python /usr/bin/python3

Now test that it is working. Do not use a root shell.

$ python --version
Python 3.6.8

Now install ansible with python3-pip...

$ pip3 install ansible --user

Now test that ansible is also working.

$ ansible --version
ansible 2.8.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/sheepdog/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Jun 12 2019, 01:12:31) [GCC 8.2.1 20180905 (Red Hat 8.2.1-3)]

Now, wasn't that easy?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.