Ansible - Pip3-Installation schlägt fehl

Ansible - Pip3-Installation schlägt fehl

Ich versuche, Ansible auf CentOS 7 zu installieren und habe Ansible für die Verwendung von Python 3 konfiguriert. Ich habe sowohl Python2 als auch Python3 installiert.

[root@ansible1 ~]# python --version
Python 2.7.5
[root@ansible1 ~]# python3 --version
Python 3.6.8

Wenn ich Ansible mit installiere yum install ansible, zeigt der ansible --versionBefehl, dass Ansible für die Verwendung von Python 2.7.5 konfiguriert ist. Ich deinstalliere ansible ( yum remove ansible);

[root@ansible1 ~]# ansible --version
ansible 2.9.10
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

Entsprechendhttps://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html:

Der einfachste Weg, /usr/bin/ansible unter Python 3 auszuführen, besteht darin, es mit der Python3-Version von pip zu installieren. Dadurch wird das Standardverzeichnis /usr/bin/ansible mit Python3 ausgeführt.

Ich habe Version 9.0.3 von Pip installiert.

[root@ansible1 ~]# pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

Gemäß der Ansible-Dokumentation pip3 install ansibleinstalliere ich Ansible mit pip3.

[root@ansible1 ~]# pip3 install ansible
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting ansible
  Using cached https://files.pythonhosted.org/packages/4b/69/c8aef60ce070fe6872e27db65f588bd0ffe8892a980cd3f4d844d8b72152/ansible-2.9.12.tar.gz
Requirement already satisfied: jinja2 in /usr/local/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: PyYAML in /usr/local/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: cryptography in /usr/local/lib64/python3.6/site-packages (from ansible)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib64/python3.6/site-packages (from jinja2->ansible)
Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in /usr/local/lib64/python3.6/site-packages (from cryptography->ansible)
Requirement already satisfied: pycparser in /usr/local/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.8->cryptography->ansible)
Installing collected packages: ansible
  Running setup.py install for ansible ... done
Successfully installed ansible-2.9.12

Hier ist die Ausgabe des pip3 show ansibleBefehls.

[root@ansible1 ~]# pip3 show ansible
Name: ansible
Version: 2.9.12
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /usr/local/lib/python3.6/site-packages
Requires: jinja2, PyYAML, cryptography

Der Befehl gibt jedoch ansible --versionFolgendes zurück.

-bash: /bin/ansible: No such file or directory

Ebenfalls, /usr/bin/ansible --version:

-bash: /usr/bin/ansible: No such file or directory

Der pip show ansibleBefehl zeigt, dass der Speicherort ist /usr/local/lib/python3.6/site-packages/ansible. Dieses Verzeichnis existiert und enthält viele Dateien und Ordner, aber keine Ansible-spezifischen Konfigurationsdateien (z. B. ansible.cfg) oder Binärdateien (z. B. ansible), die verwendet werden können (soweit ich weiß).

Antwort1

Schlagspeichert die Pfade zu Befehlen, und wenn ein Befehl verschoben wird (wie es in Ihrem Fall der Fall zu sein scheint), wird Bash ihn nicht abrufen, es sei denn, der Cache wird geleert.

Sie können ansibleden Cache wie folgt löschen:

hash -d ansible

Oder leeren Sie den gesamten Cache mit:

hash -r

verwandte Informationen