如何在Ubuntu 18.04上完全删除Ansible 2.8.3

如何在Ubuntu 18.04上完全删除Ansible 2.8.3,ansible,Ansible,在我的Ubuntu 18.04上安装了Ansible 2.8.3 [root:~] # ansible --version ansible 2.8.3 config file = None configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/loca

在我的Ubuntu 18.04上安装了Ansible 2.8.3

[root:~] # ansible --version
ansible 2.8.3
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15+ (default, Oct  7 2019, 17:39:04) [GCC 7.4.0]
当然,我可以使用apt删除此包

[root:~] # apt remove ansible
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python-httplib2 python-jinja2 python-markupsafe python-paramiko python-pyasn1 python-yaml sshpass
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  ansible
0 upgraded, 0 newly installed, 1 to remove and 343 not upgraded.
After this operation, 58.0 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 317908 files and directories currently installed.)
Removing ansible (2.9.6-1ppa~bionic) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
[root:~] # 
我可以安装不同的版本,例如2.9.6

[root:~] # apt install ansible=2.9.6-1ppa~bionic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  ansible
0 upgraded, 1 newly installed, 0 to remove and 343 not upgraded.
Need to get 0 B/5,786 kB of archives.
After this operation, 58.0 MB of additional disk space will be used.
Selecting previously unselected package ansible.
(Reading database ... 311783 files and directories currently installed.)
Preparing to unpack .../ansible_2.9.6-1ppa~bionic_all.deb ...
Unpacking ansible (2.9.6-1ppa~bionic) ...
Setting up ansible (2.9.6-1ppa~bionic) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
[root:~] # 
问题是,安装2.9.6-1ppa~bionic只会使2.8.3版本恢复

[root:~] # ansible --version
ansible 2.8.3
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15+ (default, Oct  7 2019, 17:39:04) [GCC 7.4.0]
[root:~] #
因此,结论必须是apt remove ansible不会完全删除2.8.3。如果执行另一个apt install ansible,则此版本仍已安装,可以激活

是否有办法完全删除Ansible 2.8.3?没有完全重新安装Ubuntu 18.04

顺便说一句,我使用官方Ansible存储库安装了2.8.3

[root:~] # cat /etc/apt/sources.list.d/ansible.list 
deb      "http://ppa.launchpad.net/ansible/ansible/ubuntu" bionic main
[root:~] #  

顺便说一句,我使用Chef管理我的所有系统。因此,Ansible是使用apt和官方Ansible存储库安装的

apt_repository 'ansible' do
  uri          'ppa:ansible/ansible'
  distribution node['lsb']['codename']
end
package ['ansible','python-pip']

我通过卸载Ansible、Python,然后从根目录中搜索任何名为“Ansible”的文件系统,解决了这个问题。包括存储库

我通过卸载Ansible、Python,然后从根目录搜索文件系统中任何名为“Ansible”的内容,解决了这个问题。包括存储库

在我的例子中,事实证明我的ansible是由pip安装的:

$ sudo apt remove ansible
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'ansible' is not installed, so not removed

$ ansible --version
ansible 2.3.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]

$ sudo pip uninstall --yes ansible
Uninstalling ansible-2.3.2.0:
  Successfully uninstalled ansible-2.3.2.0

$ ansible --version
-bash: /usr/local/bin/ansible: No such file or directory
因此,请尝试通过pip卸载ansible:

$ sudo pip uninstall --yes ansible

在我的例子中,事实证明我已经由pip安装了ansible:

$ sudo apt remove ansible
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'ansible' is not installed, so not removed

$ ansible --version
ansible 2.3.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]

$ sudo pip uninstall --yes ansible
Uninstalling ansible-2.3.2.0:
  Successfully uninstalled ansible-2.3.2.0

$ ansible --version
-bash: /usr/local/bin/ansible: No such file or directory
因此,请尝试通过pip卸载ansible:

$ sudo pip uninstall --yes ansible

您可能安装了不同版本Python的ansible和/或来自不同的包管理器。我使用Chef管理所有系统。所以我知道我是如何安装Ansible的。使用apt和官方Ansible存储库。我把这些信息添加到我的问题中,我认为2.8.3从官方存储库中删除是有原因的。软件包维护人员跳过了一些质量检查,使2.8.3的行为类似于恶意软件。您可能安装了不同版本的Python ansible和/或来自不同的软件包管理器。我使用Chef管理所有系统。所以我知道我是如何安装Ansible的。使用apt和官方Ansible存储库。我把这些信息添加到我的问题中,我认为2.8.3从官方存储库中删除是有原因的。软件包维护人员跳过了一些质量检查,使2.8.3表现得像恶意软件。