Open yajo opened 1 year ago
ansible/core.nix has this:
propagatedBuildInputs = [
# depend on ansible instead of the other way around
ansible
which I'm guessing makes the full ansible
available when running ansible-galaxy, bringing in all the collections as well. Getting rid of that dependency causes ansible-galaxy to output this:
$ ansible-galaxy collection list
usage: ansible-galaxy [-h] [--version] [-v] TYPE ...
Perform various Role and Collection related operations.
positional arguments:
TYPE
collection Manage an Ansible Galaxy collection.
role Manage an Ansible Galaxy role.
options:
--version show program's version number, config file location, configured module
search path, module location, executable location and exit
-h, --help show this help message and exit
-v, --verbose Causes Ansible to print more debug messages. Adding multiple -v will
increase the verbosity, the builtin plugins currently evaluate up to
-vvvvvv. A reasonable level to start is -vvv, connection debugging might
require -vvvv.
ERROR! - None of the provided paths were usable. Please specify a valid path with --collections-path
Though, from a shell with ansible
, ansible-core's ansible-galaxy doesn't find any collections.
PR https://github.com/NixOS/nixpkgs/pull/166447 seems relevant -- it got rid of the ansible-collections
package, I'm not really sure why it did that, but ansible-core
depended on ansible-collections
before that as well.
Hi, I did those changes back when I maintained ansible in nixpkgs. I can quickly summarize the issues I've seen and why they exist that way.
In 2.9 ansible
contained the core and collections in one. In 2.10 that was separated into ansible-base
for the core, and ansible
for the collections. In 2.11 the core was renamed into ansible-core
.
We still supported both 2.9, 2.10 and 2.11 at the same time, but we cannot have multiple versions of the ansible
package, especially with the change of the package contents from core+collections to just collections.
The naming of the legacy packages has been dropped in #166447.
What this issue actually complains about is that I changed how ansible and ansible-core depend on each other. Because in general you should be able to just install ansible-core
and have a lean installation.
Upstream by default creates a dependency from ansible
, the collections package, to ansible-core
, the runtime package. The problem with that kind of dependency is, that when you install python3Packages.ansible
you will not see the executables of its transitive dependencies in your PATH. That means you will not have any ansible executables. This is what you noticed here:
Though, from a shell with ansible, ansible-core's ansible-galaxy doesn't find any collections.
The only way to install ansible executables from nixpkgs is to directly install the ansible_2_15
, ansible_2_14
etc. packages, all of which are an override of python3Packages.ansible-core
for the relevant version. But that would leave you without collections.
Now how would you install collections? By overriding the ansible-core
package to propagate the relevant collection packages. And that is ultimately what I decided to do, by reversing that dependency.
The thing about collections is, that they're huge (~350M). And nobody ever needs all collections. Instead, everyone usually manages them in a requirements.yml
, which allows installing just selected parts of the collections package through ansible-collection collection install -r requirements.yml
.
---
collections:
- name: ansible.netcommon
- name: ansible.posix
- name: ansible.utils # ipaddr filter
- name: community.crypto # openssh_keypair
- name: community.docker
- name: community.general
- name: community.grafana
- name: community.sops
- name: netbox.netbox # inventory and lookups
We currently lack a selection mechanism for these individual collection packages.
Also note, that if you separate those two packages again, the collections would need to made available be in the same python environment, that ansible-core
already uses.
I've dropped maintenainership for the ansible packages over a year ago in 2d0f97be21750797ff946c644202b12cd317397d, and it would be good if one or multiple people could step up to fill that role. I would be available to recommend solutions or do reviews, to get this started.
One thing that needs to be done is move ansible out of python3Packages
and fully into the top-level. There were always bits of ansible in pkgs/tools/admin/ansible
and that's where all of this should live.
A module for ansible doesn't make much sense, given that the required collections are mostly project-specific. So it would most likely be function arguments, or a wrapper.
Describe the bug
When installing both
ansible
andansible-core
packages from nixpkgs, both get access to standard collections.Only
ansible
should have that.Steps To Reproduce
Current behaviour
Expected behavior
The list should be empty because I'm using the
ansible-core
package.Additional context
According to the docs:
Thus,
ansible-core
is not expected to provide any collections besidesansible.builtin
.Notify maintainers
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.@moduon MT-1075