New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do switch to apt if aptitude is not installed #30738

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
4 participants
@mscherer
Contributor

mscherer commented Sep 22, 2017

Trying to use the apt module on a freshly install 16.04 Ubuntu VM with
"ansible -m apt -a 'name=* state=latest' all" fail with this backtrace:

    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 1055, in <module>
      main()
    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 998, in main
      upgrade(module, 'yes', force_yes, p['default_release'], use_apt_get, dpkg_options)
    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 759, in upgrade
      apt_cmd_path = m.get_bin_path(apt_cmd, required=True)
    File \"/tmp/ansible_2inxygge/ansible_modlib.zip/ansible/module_utils/basic.py\", line 2182, in get_bin_path
    File \"/usr/lib/python3.5/posixpath.py\", line 89, in join
      genericpath._check_arg_types('join', a, *p)
    File \"/usr/lib/python3.5/genericpath.py\", line 143, in _check_arg_types
      (funcname, s.__class__.__name__)) from None
    TypeError: join() argument must be str or bytes, not 'NoneType'

It seems that since aptitude is not installed on Xenial, so APTITUDE_CMD is None
and we later hit the bug in the upgrade function since it assume APTITUDE_CMD
is set.

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

apt

@ansibot

This comment has been minimized.

Contributor

ansibot commented Sep 22, 2017

Do switch to apt if aptitude is not installed
Trying to use the apt module on a freshly install 16.04 Ubuntu VM with
"ansible -m apt -a 'name=* state=latest' all" fail with this backtrace:

  Traceback (most recent call last):
    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 1055, in <module>
      main()
    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 998, in main
      upgrade(module, 'yes', force_yes, p['default_release'], use_apt_get, dpkg_options)
    File \"/tmp/ansible_2inxygge/ansible_module_apt.py\", line 759, in upgrade
      apt_cmd_path = m.get_bin_path(apt_cmd, required=True)
    File \"/tmp/ansible_2inxygge/ansible_modlib.zip/ansible/module_utils/basic.py\", line 2182, in get_bin_path
    File \"/usr/lib/python3.5/posixpath.py\", line 89, in join
      genericpath._check_arg_types('join', a, *p)
    File \"/usr/lib/python3.5/genericpath.py\", line 143, in _check_arg_types
      (funcname, s.__class__.__name__)) from None
    TypeError: join() argument must be str or bytes, not 'NoneType'

It seems that since aptitude is not installed on Xenial, so APTITUDE_CMD is None
and we later hit the bug in the upgrade function since it assume APTITUDE_CMD
is set.
@mkrizek

This comment has been minimized.

Contributor

mkrizek commented Apr 4, 2018

@mscherer I can't reproduce the issue to test the patch. Running the following on newly installed Ubuntu 16.04:

ansible -b -K -m apt -a 'name=* state=latest' ubuntu

I get:

Unable to find APTITUDE in path. Please make sure to have APTITUDE in path or use 'force_apt_get=True'

Anything I am doing wrong?

@ansibot ansibot removed the stale_ci label Apr 4, 2018

@ansibot ansibot added the stale_ci label Apr 12, 2018

@ansibot ansibot added the traceback label May 30, 2018

@ansibot ansibot added the small_patch label Jun 23, 2018

@maxamillion

This comment has been minimized.

Contributor

maxamillion commented Sep 19, 2018

waiting_on_contributor
needs_revision

@ansibot ansibot added needs_revision and removed core_review labels Sep 19, 2018

if not use_apt_get and not APTITUDE_CMD and p.get('upgrade', None) in ['full', 'safe', 'yes']:
module.warn("Could not find aptitude. Using apt-get instead.")
if not use_apt_get and not APTITUDE_CMD:
module.warn("Could not find aptitude. Using apt-get instead")

This comment has been minimized.

@maxamillion

maxamillion Dec 7, 2018

Contributor

This is a tiny nit pick, but can you replace the period at the end of the warning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment