Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pythonPackages.ansible: add support for hcloud #71112

Closed
wants to merge 1 commit into from

Conversation

liff
Copy link
Contributor

@liff liff commented Oct 14, 2019

Motivation for this change

Using Hetzner Cloud inventory plugin and cloud modules requires the availability of hcloud-python (also: #69151).

A slight caveat is that due to the way Ansible works, using the cloud module on localhost may need something like this to work:

ansible_python_interpreter=`which python`
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @joamaki @costrouc

@jonringer
Copy link
Contributor

the commit message sounds confusing, thought you were adding a dependency to the hcloud package

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about including all the plugins to the default installation... seems like it will eventually make the ansible closure huge. Might be worthwhile to just list the other needed packages alongside the ansible package when you're specifying the environment you want to use the packages in.

@FRidh thoughts?

pkgs/development/python-modules/ansible/default.nix Outdated Show resolved Hide resolved
@liff liff force-pushed the pythonPackages.ansible/add-hcloud branch from 4838d35 to f48693e Compare October 15, 2019 17:50
@liff liff changed the title pythonPackages.ansible: add dependency to hcloud pythonPackages.ansible: add support for hcloud Oct 15, 2019
@liff
Copy link
Contributor Author

liff commented Oct 15, 2019

Sorry for being a noob but I don’t quite understand what you mean by listing the needed packages in the environment?

Do you mean something like this?

nix run nixpkgs.ansible nixpkgs.python3Packages.hcloud \
    -c ansible-inventory -i hcloud.yml --graph

If so, then it doesn’t seem to work, i.e. Ansible cannot find the hcloud package in its python path.

@FRidh
Copy link
Member

FRidh commented Oct 15, 2019

The general approach with Python packages is to use composition using python3.withPackages. Please have a look in the Nixpkgs manual for examples.

@liff
Copy link
Contributor Author

liff commented Oct 15, 2019

So rather than installing Ansible with

{ environment.systemPackages = [ ansible ]; }

add it to Python environment:

{ environment.systemPackages = [ (python3.withPackages (ps: with ps; [ ansible ])) ]; }

along with whatever you need to depend on.

If so, works for me, thanks!

@liff liff closed this Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants