1{
2 lib,
3 pythonOlder,
4 buildPythonPackage,
5 fetchPypi,
6 jsonschema,
7 jxmlease,
8 ncclient,
9 netaddr,
10 paramiko,
11 ansible-pylibssh,
12 pynetbox,
13 scp,
14 textfsm,
15 ttp,
16 xmltodict,
17
18 # optionals
19 withJunos ? false,
20 withNetbox ? false,
21}:
22
23let
24 pname = "ansible";
25 version = "9.5.1";
26in
27buildPythonPackage {
28 inherit pname version;
29 format = "setuptools";
30
31 disabled = pythonOlder "3.9";
32
33 src = fetchPypi {
34 inherit pname version;
35 hash = "sha256-PCeLyWQrl/yVOyugW5nNgIAedb81Z9+qHLUTH+DsHs0=";
36 };
37
38 postPatch = ''
39 # we make ansible-core depend on ansible, not the other way around
40 sed -Ei '/ansible-core/d' setup.py
41 '';
42
43 propagatedBuildInputs = lib.unique (
44 [
45 # Support ansible collections by default, make all others optional
46 # ansible.netcommon
47 jxmlease
48 ncclient
49 netaddr
50 paramiko
51 ansible-pylibssh
52 xmltodict
53 # ansible.posix
54 # ansible.utils
55 jsonschema
56 textfsm
57 ttp
58 xmltodict
59 # ansible.windows
60
61 # lots of collections with dedicated requirements.txt and pyproject.toml files,
62 # add the dependencies for the collections you need conditionally and install
63 # ansible using overrides to enable the collections you need.
64 ]
65 ++ lib.optionals (withJunos) [
66 # ansible_collections/junipernetworks/junos/requirements.txt
67 jxmlease
68 ncclient
69 paramiko
70 ansible-pylibssh
71 scp
72 xmltodict
73 ]
74 ++ lib.optionals (withNetbox) [
75 # ansible_collections/netbox/netbox/pyproject.toml
76 pynetbox
77 ]
78 );
79
80 # don't try and fail to strip 48000+ non strippable files, it takes >5 minutes!
81 dontStrip = true;
82
83 # difficult to test
84 doCheck = false;
85
86 meta = with lib; {
87 description = "Radically simple IT automation";
88 mainProgram = "ansible-community";
89 homepage = "https://www.ansible.com";
90 changelog = "https://github.com/ansible-community/ansible-build-data/blob/${version}/${lib.versions.major version}/CHANGELOG-v${lib.versions.major version}.rst";
91 license = licenses.gpl3Plus;
92 maintainers = with maintainers; [ ];
93 };
94}