Open nikita197 opened 5 months ago
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.
cc @evgkrsk click here for bot help
The module documents nowhere that you can specify versions, so this is not a bug, but a feature request.
The module documents nowhere that you can specify versions, so this is not a bug, but a feature request.
It seems like it is. Сan anyone add this functionality? I think I'm not the only one who has this need.
I'm confused your example used package
, from the package doc it supports specific versions. so it seems package
bug if it does not work.
The module documents nowhere that you can specify versions, so this is not a bug, but a feature request.
It seems like it is. Сan anyone add this functionality? I think I'm not the only one who has this need.
Yes, this is a community collection, so it's owned by the community :)
I'm confused your example used
package
, from the package doc it supports specific versions. so it seemspackage
bug if it does not work.
The package module isn't a module, but an action which passes its parameters through to the selected package manager module. Which features are actually supported depends on the specific module used. The important part in the documentation is Syntax varies with package manager. (It should better say "package manager module" though, since it in particular depends on that one. The module might support more or less things than the actual package manager.) The apt_rpm module doesn't support features that many other package manager modules support, like specifying versions.
I'm confused your example used
package
, from the package doc it supports specific versions. so it seemspackage
bug if it does not work.
I tried also apt_rpm module, but the same problem:
---
- hosts: all
become: true
tasks:
- name: Install my package
become: yes
apt_rpm:
name: bird=1.6.8
state: present
update_cache: yes
...
output:
docker-desktop:/ansible/host_group/postgres# ansible-playbook playbook.yml -i inventory.ini --vault-pass-file vault_pass
[DEPRECATION WARNING]: ansible.posix.skippy has been deprecated. See the plugin documentation for more details. This feature will be removed from ansible.posix in a release after 2022-06-01. Deprecation
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
PLAY [all] *****************************************************************************************************************************************************************************************************
TASK [Install squid packages] **********************************************************************************************************************************************************************************
fatal: [postgres-pro.lab.adc.spb]: FAILED! => {"changed": false, "msg": "'apt-get -y install bird=1.6.8' failed: "}
PLAY RECAP *****************************************************************************************************************************************************************************************************
postgres-pro.lab.adc.spb : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
docker-desktop:/ansible/host_group/postgres#
On official AltLinux FTP package server (http://ftp.altlinux.org/pub/distributions/ALTLinux/p10/branch/x86_64/RPMS.classic/) required package present:
The module documents nowhere that you can specify versions, so this is not a bug, but a feature request.
It seems like it is. Сan anyone add this functionality? I think I'm not the only one who has this need.
Yes, this is a community collection, so it's owned by the community :)
I'm confused your example used
package
, from the package doc it supports specific versions. so it seemspackage
bug if it does not work.The package module isn't a module, but an action which passes its parameters through to the selected package manager module. Which features are actually supported depends on the specific module used. The important part in the documentation is Syntax varies with package manager. (It should better say "package manager module" though, since it in particular depends on that one. The module might support more or less things than the actual package manager.) The apt_rpm module doesn't support features that many other package manager modules support, like specifying versions.
Yes, you are right. Also I noticed that "present" state for apt_rpm module will update package if a newer version exists, but this is very strange behavior. On the contrary, I want to fix the package version and always be sure that I know the final state of the operating system
I have the same problem
Previously, this could be fixed as follows
def fix_package_name(name):
package_name = name.replace('=', '-')
return package_name
def query_package(module, name):
# rpm -q returns 0 if the package is installed,
# 1 if it is not installed
rc, out, err = module.run_command("%s -q %s" % (RPM_PATH, name))
rc, out, err = module.run_command("%s -q %s" % (RPM_PATH, fix_package_name(name)))
if rc == 0:
return True
else:
def query_package_provides(module, name):
# rpm -q returns 0 if the package is installed,
# 1 if it is not installed
rc, out, err = module.run_command("%s -q --provides %s" % (RPM_PATH, name))
rc, out, err = module.run_command("%s -q --provides %s" % (RPM_PATH, fix_package_name(name)))
return rc == 0
now we have a rather strange default behavior that is not well suited for a production environment
https://github.com/ansible-collections/community.general/blob/main/plugins/modules/apt_rpm.py#L99 https://github.com/ansible-collections/community.general/blob/main/plugins/modules/apt_rpm.py#L170
when we specify "present" we get "latest"
I agree that this behavior is odd, but the module has been claiming this behavior from the beginning.
How about:
latest
and installed
, where the former upgrades and the latter does not.state=present
will change its meaning in the future (basically change from latest
to installed
).state=present
.Then users can soon start specifying the exact behavior they want, but they can also chose to stick to the old behavior. And they can get rid of the deprecation warning by adjusting state to one of the two new values.
And eventually installed
will be an alias of present
, as its already the case for multiple other package managing modules.
(This doesn't fix the problem that you might want to specify a package version, but at least it stops the strange behavior.)
I agree that this behavior is odd, but the module has been claiming this behavior from the beginning.
How about:
- Add two new states
latest
andinstalled
, where the former upgrades and the latter does not.- Add a deprecation warning that
state=present
will change its meaning in the future (basically change fromlatest
toinstalled
).- Then in a couple of versions, change the behavior for
state=present
.Then users can soon start specifying the exact behavior they want, but they can also chose to stick to the old behavior. And they can get rid of the deprecation warning by adjusting state to one of the two new values.
And eventually
installed
will be an alias ofpresent
, as its already the case for multiple other package managing modules.(This doesn't fix the problem that you might want to specify a package version, but at least it stops the strange behavior.)
The problem with automatically updating packages to the latest version when it is present
state is minor. Now it is extremely important for me to find a way to fix package versions
I created #8247 to add new states latest
and present_not_latest
(installed
was already there, and equivalent to present
).
@felixfontein thank you very much for your contribution! Also please create a new PR to add a package version fixation
@nikita197 I likely won't implement that, but that shouldn't stop anyone else from trying it.
(If someone wants to work on this, please note that #8264 does some general refactoring of the run_command
calls in this module.)
state=installed
and state=present
so it can change to what is less surprising in community.general 11.0.0.
Summary
When I try to install specific package version via Ansible, I got error:
my playbook example:
Target host is AltLinux server v10.2
As I know, in https://github.com/ansible-collections/community.general/issues/7414 in file apt_rpm.py added function that upgrade package if newer version exists. But it is not good for me, because I'm getting inconsistent state of packages (For example, I don't want to upgrade the k8s cluster if I just run playbook).
Issue Type
Feature idea
Component Name
apt_rpm
Ansible Version
Community.general Version
Configuration
OS / Environment
Alpine Linux v3.18
Steps to Reproduce
just run
Expected Results
Specific package version installed on target AltLinux host. Moreover, I can install a package of a specific version on the target host via apt-get:
Actual Results
Code of Conduct