Skip to content
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

apt module uses apt-get --autoremove even if autoremove=no #30516

Closed
ashikv opened this issue Sep 18, 2017 · 2 comments · Fixed by #30747
Closed

apt module uses apt-get --autoremove even if autoremove=no #30516

ashikv opened this issue Sep 18, 2017 · 2 comments · Fixed by #30747
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@ashikv
Copy link

ashikv commented Sep 18, 2017

ISSUE TYPE
  • Bug Report
COMPONENT NAME

apt

ANSIBLE VERSION
ansible 2.4.0.0 (detached HEAD 3c805f85bc) last updated 2017/09/18 18:23:57 (GMT +300)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/vashik/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vashik/opt/ansible/lib/ansible
  executable location = /home/vashik/opt/ansible/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
CONFIGURATION
OS / ENVIRONMENT

Debian Jessie

SUMMARY

If aptitude is missing apt module falls back to using apt-get but uses an option --autoremove that some versions of apt-get do not understood

STEPS TO REPRODUCE

Set up a minimal Debian Jessie system, it won't have aptitude installed.
Try to apply updates using apt module on it.

ansible -i target-host-name, target-host-name -m apt -sa 'upgrade=yes update_cache=yes autoclean=no autoremove=no' -vv
EXPECTED RESULTS

Apt module does not use --autoremove when autoremove=no
Apt module has default value no for autoremove
Apt module does not try to use --autoremove when apt-get does not support it

ACTUAL RESULTS
target-host-name | FAILED! => {
    "changed": false,
    "failed": true,
    "msg": "'/usr/bin/apt-get upgrade --with-new-pkgs --autoremove' failed: E: Command line option --autoremove is not understood\n",
    "rc": 100,
    "stdout": "",
    "stdout_lines": []
}
@ashikv ashikv changed the title apt module uses apt-get --autoremove even if autoremove=no apt module uses apt-get --autoremove even if autoremove=no #affects_2.4 Sep 18, 2017
@ansibot
Copy link
Contributor

ansibot commented Sep 18, 2017

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 18, 2017
@ashikv ashikv changed the title apt module uses apt-get --autoremove even if autoremove=no #affects_2.4 apt module uses apt-get --autoremove even if autoremove=no Sep 18, 2017
@nrwahl2
Copy link
Contributor

nrwahl2 commented Sep 19, 2017

Yeah this looks problematic.

def upgrade(m, mode="yes", force=False, default_release=None,
            use_apt_get=False,
            dpkg_options=expand_dpkg_options(DPKG_OPTIONS)):
    if m.check_mode:
        check_arg = '--simulate'
    else:
        check_arg = ''

    apt_cmd = None
    prompt_regex = None
    if mode == "dist" or (mode == "full" and use_apt_get):
        # apt-get dist-upgrade
        apt_cmd = APT_GET_CMD
        upgrade_command = "dist-upgrade"
    elif mode == "full" and not use_apt_get:
        # aptitude full-upgrade
        apt_cmd = APTITUDE_CMD
        upgrade_command = "full-upgrade"
    else:
        if use_apt_get:
            apt_cmd = APT_GET_CMD
            upgrade_command = "upgrade --with-new-pkgs --autoremove"
        else:
            # aptitude safe-upgrade # mode=yes # default
            apt_cmd = APTITUDE_CMD
            upgrade_command = "safe-upgrade"
            prompt_regex = r"(^Do you want to ignore this warning and proceed anyway\?|^\*\*\*.*\[default=.*\])"

@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Sep 21, 2017
dj4ngo added a commit to dj4ngo/ansible that referenced this issue Sep 26, 2017
BondAnthony pushed a commit to BondAnthony/ansible that referenced this issue Oct 5, 2017
abadger pushed a commit that referenced this issue Oct 26, 2017
abadger pushed a commit that referenced this issue Oct 26, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants