Enforce Ansible availability via Nix and validate requirements.yml

- Add ansiblePkg as propagated dependency in flake.nix so ansible-galaxy is available on host
- Introduce strict requirements.yml validator for AnsibleRequirementsInstaller
- Accept roles entries with either 'name' or 'src'
- Ensure run() always validates requirements before installing dependencies
- Extend unit tests to cover valid, invalid and warning-only requirements.yml cases

See: https://chatgpt.com/share/69332bc4-a128-800f-a69c-fdc24c4cc7fe
This commit is contained in:
Kevin Veen-Birkenbach
2025-12-05 20:00:47 +01:00
parent f5475d86e2
commit a435745c02
3 changed files with 191 additions and 21 deletions

View File

@@ -43,27 +43,33 @@
);
# Packages: nix build .#pkgmgr / .#default
packages = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python311;
pypkgs = pkgs.python311Packages;
packages = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python311;
pypkgs = pkgs.python311Packages;
pkgmgrPkg = pypkgs.buildPythonApplication {
pname = "package-manager";
version = "0.1.0";
src = ./.;
# Be robust: ansible-core if available, otherwise ansible.
ansiblePkg =
if pkgs ? ansible-core then pkgs.ansible-core
else pkgs.ansible;
in
rec {
pkgmgr = pypkgs.buildPythonApplication {
pname = "package-manager";
version = "0.1.0";
src = ./.;
propagatedBuildInputs = [
pypkgs.pyyaml
# add further dependencies here
];
};
in {
pkgmgr = pkgmgrPkg;
default = pkgmgrPkg;
}
);
propagatedBuildInputs = [
pypkgs.pyyaml
ansiblePkg
];
};
# default package just points to pkgmgr
default = pkgmgr;
}
);
# Apps: nix run .#pkgmgr / .#default
apps = forAllSystems (system: