apt module has poor support for local packages
Summary
I am trying to deploy package files over a heterogeneous environment and trying to avoid having to duplicate things for each different distro. As such I want to use the package module, which in turn uses the apt module, but I'm seeing limitations. Basically I want the apt module to support file paths in the name argument.
Issue Type
Feature Idea
Component Name
apt
Additional Information
Ideally I want to do this:
- name: Install packages
package:
name:
- /path/package_a.deb
- /path/package_b.deb
But the apt module doesn't support giving files to the name argument, unlike the command apt. (missing feature 1)
I then change things to:
- name: Install packages
package:
deb:
- /path/package_a.deb
- /path/package_b.deb
Which doesn't work either since the apt module doesn't support specifying multiple files for the deb argument. (missing feature 2).
(I can't do this in a loop as the packages have a dependency loop)
So now I have to resort to using the command module, which is a lot less flexible.
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
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.
Technically deb can take multiple packages, by separating the paths with a comma. But there is certainly room for improvement.
- package:
name: '{{ package_files if ansible_facts.pkg_mgr != "apt" else omit }}'
deb: '{{ package_files|join(",") if ansible_facts.pkg_mgr == "apt" else omit }}'
Nice, thanks! That workaround got us a bit further.
Unfortunately we then hit #77150. :/
@sivel Thanks for the trick. Any workaround with apt module if packages depend on each other?
With plain dpkg wrapped in command/shell module this works, but ain't pretty and idempotent:
- command: "dpkg {{ package_files|join(' ') if ansible_facts.pkg_mgr == "apt" else omit }}"