[BUG] `pkg.installed` state with `dnf` should mark the package as installed
Description A clear and concise description of what the bug is.
On RHEL-8-based OS, using pkg.installed should mark the package as "installed by user" so that it do not get removed by dependencies.
Setup (Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)
Just a simple RockyLinux 8.6 OpenStack VM.
$ cat /etc/centos-release
Rocky Linux release 8.6 (Green Obsidian)
$ uname -a
Linux test-salt-dnf-dependency.novalocal 4.18.0-372.19.1.el8_6.x86_64 #1 SMP Tue Aug 2 16:19:42 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Steps to Reproduce the behavior (Include debug logs if possible and relevant)
# cat /srv/salt/test.sls
Install lvm2:
pkg.installed:
- name: lvm2
# This package is already installed as an "lvm2" dependencies
Install lvm2-libs:
pkg.installed:
- name: lvm2-libs
- require:
- pkg: Install lvm2
# I would expect this to not remove "lvm2-libs"
Remove lvm2:
pkg.removed:
- name: lvm2
- require:
- pkg: Install lvm2
$ salt-call --local state.sls test
local:
----------
ID: Install lvm2
Function: pkg.installed
Name: lvm2
Result: True
Comment: The following packages were installed/updated: lvm2
Started: 16:46:56.278371
Duration: 9790.847 ms
Changes:
----------
lvm2:
----------
new:
8:2.03.14-3.el8_6.2
old:
lvm2-libs:
----------
new:
8:2.03.14-3.el8_6.2
old:
----------
ID: Install lvm2-libs
Function: pkg.installed
Name: lvm2-libs
Result: True
Comment: All specified packages are already installed
Started: 16:47:06.100743
Duration: 868.546 ms
Changes:
----------
ID: Remove lvm2
Function: pkg.removed
Name: lvm2
Result: True
Comment: All targeted packages were removed.
Started: 16:47:06.969568
Duration: 2747.068 ms
Changes:
----------
lvm2:
----------
new:
old:
8:2.03.14-3.el8_6.2
lvm2-libs:
----------
new:
old:
8:2.03.14-3.el8_6.2
Summary for local
------------
Succeeded: 3 (changed=2)
Failed: 0
------------
Total states run: 3
Total run time: 13.406 s
Expected behavior A clear and concise description of what you expected to happen.
From previous example, I would expect the lvm2-libs to not be removed by the pkg.removed, because the pkg.installed would have run a dnf mark install <pkg_name>.
Could be the default behavior of pkg.installed or at least have a boolean to "enforce package mark".
Screenshots If applicable, add screenshots to help explain your problem.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)Salt Version:
Salt: 3004.2
Dependency Versions:
cffi: 1.11.5
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10.1
libgit2: Not Installed
M2Crypto: 0.35.2
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.14
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Apr 12 2022, 06:55:39)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 19.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: rocky 8.6 Green Obsidian
locale: UTF-8
machine: x86_64
release: 4.18.0-372.19.1.el8_6.x86_64
system: Linux
version: Rocky Linux 8.6 Green Obsidian
Additional context
Maybe, it's a feature but to me, it's kind of a bug according to the example I described
This would be applicable to apt systems too.
This would be applicable to
aptsystems too.
apt-mark manual <package>
but anything installed with apt-get/aptitude/apt should automatically have these packages marked as manually installed. Have you observed the same behavior in apt based systems? ref: https://github.com/saltstack/salt/blob/master/salt/modules/aptpkg.py#L821-L853
If a package is already auto installed, and you add an installed state for it, then it will do nothing and not mark it as manual, right?
On 15 Aug 2022, at 21:11, Kevin Landreth @.***> wrote:
This would be applicable to apt systems too.
apt-mark manual
but anything installed with apt-get/aptitude/apt should automatically have these packages marked as manually installed. Have you observed the same behavior in apt based systems? ref: https://github.com/saltstack/salt/blob/master/salt/modules/aptpkg.py#L821-L853
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
@OrangeDog thanks for that clarification, makes a ton of sense now. edit: also I am dumb