There is quite a few python per-requisites for ansible, for example, it isn’t enough to just install python3, usually I think ansible would install the other deps needed, but you cant exactly do that on nixos, anyone has a flake or list of packages or something, plus anything else I might need so ansible can run some tasks on my Nixos server? the reason I cant use nix completely is that some playbooks in ansible are more featureful or existent unlike some modules in nix. Or at the very least I am planning to site down one day and re-write eveything in Nix but I would also need to look into something like nix-ops for deployments and I need to get all my services and stuff running quickly on nix for a bit a reliably (I could run the commands manually but it would be alot of commands and I have to update the nix code often and it would just be a hassle). So until then, when i get it working on Nix, how can I make it so my Nix system supports ansible?
Depends on what you want to achieve, but you could make Ansible “happier” by adding a few lines to your NixOS configuration, like:
{
# Create a symlink from /usr/libexec/platform-python to the Python executable
systemd.tmpfiles.rules = [
"L+ /usr/libexec/platform-python - - - - ${pkgs.python3Minimal}/bin/python3"
];
}
(Stolen from NixOS Ansible JumpHost - Robert Sliwinski)
This way Ansible can at least call its needed Python executable and do things.
So gathering facts, getting other data and reading from the host is possible this way.
Besides the writing the file system you’re pretty limited as the most collections from Ansible Galaxy do not cover Nix/NixOS, be prepared to run in a lot of failures as things like ansible.builtin.package
simply do not understand the nature of Nix.
Hope this helps! And awaiting your implementation and experience in a heterogenous environment of declarative and imperative distros!
1 Like