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

DNF module upgrades modules with state: present or state: installed #76384

Open
1 task done
1kaw opened this issue Nov 29, 2021 · 9 comments
Open
1 task done

DNF module upgrades modules with state: present or state: installed #76384

1kaw opened this issue Nov 29, 2021 · 9 comments
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@1kaw
Copy link
Contributor

1kaw commented Nov 29, 2021

Summary

When running the DNF module with state: present or state: installed, certain packages will be upgraded even though they should be skipped with that parameter.

Issue Type

Bug Report

Component Name

dnf

Ansible Version

$ ansible --version
ansible 2.10.15
  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, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

Configuration

$ ansible-config dump --only-changed

OS / Environment

CentOS 8

Steps to Reproduce

redis package is already installed.

[root@c8 ~]# rpm -qa | grep redis
redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64

Next, run the following playbook.

- hosts: localhost
  tasks:
    - dnf:
        name: '@redis:5'
        state: present

Expected Results

With state: present or installed, it is expected that packages with available updates do not get updated.

Actual Results

TASK [dnf] *************************************************************************************************************************************************
task path: /root/playbook.yml:3
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1638195909.4688942-5425-281163792679993 `" && echo ansible-tmp-1638195909.4688942-5425-281163792679993="` echo /root/.ansible/tmp/ansible-tmp-1638195909.4688942-5425-281163792679993 `" ) && sleep 0'
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/dnf.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-53303e4t90od/tmpmpdxsfb2 TO /root/.ansible/tmp/ansible-tmp-1638195909.4688942-5425-281163792679993/AnsiballZ_dnf.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1638195909.4688942-5425-281163792679993/ /root/.ansible/tmp/ansible-tmp-1638195909.4688942-5425-281163792679993/AnsiballZ_dnf.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3.6 /root/.ansible/tmp/ansible-tmp-1638195909.4688942-5425-281163792679993/AnsiballZ_dnf.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1638195909.4688942-5425-281163792679993/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true,
    "invocation": {
        "module_args": {
            "allow_downgrade": false,
            "allowerasing": false,
            "autoremove": false,
            "bugfix": false,
            "conf_file": null,
            "disable_excludes": null,
            "disable_gpg_check": false,
            "disable_plugin": [],
            "disablerepo": [],
            "download_dir": null,
            "download_only": false,
            "enable_plugin": [],
            "enablerepo": [],
            "exclude": [],
            "install_repoquery": true,
            "install_weak_deps": true,
            "installroot": "/",
            "list": null,
            "lock_timeout": 30,
            "name": [
                "@redis:5"
            ],
            "releasever": null,
            "security": false,
            "skip_broken": false,
            "state": "present",
            "update_cache": false,
            "update_only": false,
            "validate_certs": true
        }
    },
    "msg": "Check mode: No changes made, but would have if not in check mode",
    "rc": 0,
    "results": [
        "Installed: redis-5.0.3-5.module_el8.4.0+955+7126e393.x86_64",
        "Removed: redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64"
    ]
}
META: ran handlers
META: ran handlers

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot
Copy link
Contributor

ansibot commented Nov 29, 2021

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. 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 Nov 29, 2021
@1kaw
Copy link
Contributor Author

1kaw commented Nov 29, 2021

related #75311

@sivel
Copy link
Member

sivel commented Nov 29, 2021

I guess maybe the 2 lines to install and enable the module are not indented far enough?

if not self._is_module_installed(module):
response['results'].append("Module {0} installed.".format(module))
self.module_base.install([module])
self.module_base.enable([module])

@1kaw 1kaw changed the title DNF module upgrades packages with state: present or state: installed DNF module upgrades packages with state: present or state: installed Dec 1, 2021
@1kaw
Copy link
Contributor Author

1kaw commented Dec 2, 2021

AppStream does not retain old versions.

So, I think we need to prepare a repository (including modules) for testing to prevent degressive behavior in the future.

@nitzmahone nitzmahone removed the needs_triage Needs a first human triage before being processed. label Dec 2, 2021
@mkrizek mkrizek changed the title DNF module upgrades packages with state: present or state: installed DNF module upgrades modules with state: present or state: installed Dec 7, 2021
@1kaw
Copy link
Contributor Author

1kaw commented Dec 7, 2021

It also occurs when not in check mode

@jameslivulpi
Copy link
Contributor

See 76467 for some details particularly my last comment which is related.

The issue here with installing module seems to be that dnf doesn't honor the best option in dnf.conf when using dnf module install .. or dnf install @<package> From dnf docs I can't see anything mentioning its not supported for these 2 cases.

e.g.,:

This looks good:

[root@centos-s-1vcpu-1gb-nyc1-01 ~]# dnf install redis --nobest
Last metadata expiration check: 0:04:07 ago on Wed 08 Dec 2021 01:17:21 PM UTC.
Package redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

This doesn't look correct, I would expect it to show like the above " is already installed."

[root@centos-s-1vcpu-1gb-nyc1-01 ~]# dnf install @redis  --nobest
Last metadata expiration check: 0:00:06 ago on Wed 08 Dec 2021 01:22:26 PM UTC.
Dependencies resolved.
==========================================================================================================================================================================
 Package                         Architecture                     Version                                                       Repository                           Size
==========================================================================================================================================================================
Upgrading:
 redis                           x86_64                           5.0.3-5.module_el8.4.0+955+7126e393                           appstream                           927 k

Transaction Summary
==========================================================================================================================================================================
Upgrade  1 Package

Total size: 927 k
Is this ok [y/N]: 

@maxamillion
Copy link
Contributor

See 76467 for some details particularly my last comment which is related.

The issue here with installing module seems to be that dnf doesn't honor the best option in dnf.conf when using dnf module install .. or dnf install @<package> From dnf docs I can't see anything mentioning its not supported for these 2 cases.

e.g.,:

This looks good:

[root@centos-s-1vcpu-1gb-nyc1-01 ~]# dnf install redis --nobest
Last metadata expiration check: 0:04:07 ago on Wed 08 Dec 2021 01:17:21 PM UTC.
Package redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

This doesn't look correct, I would expect it to show like the above " is already installed."

[root@centos-s-1vcpu-1gb-nyc1-01 ~]# dnf install @redis  --nobest
Last metadata expiration check: 0:00:06 ago on Wed 08 Dec 2021 01:22:26 PM UTC.
Dependencies resolved.
==========================================================================================================================================================================
 Package                         Architecture                     Version                                                       Repository                           Size
==========================================================================================================================================================================
Upgrading:
 redis                           x86_64                           5.0.3-5.module_el8.4.0+955+7126e393                           appstream                           927 k

Transaction Summary
==========================================================================================================================================================================
Upgrade  1 Package

Total size: 927 k
Is this ok [y/N]: 

this gets even more fun because the Ansible dnf module doesn't call the cli, but uses the python library which appears to mimic the behavior which leads me to think this is an upstream DNF bug

@s-hertel s-hertel added the P3 Priority 3 - Approved, No Time Limitation label Aug 3, 2022
@Alex-ala
Copy link

Alex-ala commented Dec 1, 2022

This issue still persists with Ansible 2.14.0 and dnf 4.7.0* or 4.4.2* on CentOS 8 Stream.
I could not find a dnf version, where this is properly working.

Are there any updates on this topic or the PR provided in above comments? (#76467)

@dlakatos847
Copy link

Still an issue with Ansible 2.16.2 running on RHEL 8.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

9 participants