1{
2 lib,
3 stdenv,
4 ansible-core,
5 buildPythonPackage,
6 fetchPypi,
7 glibcLocales,
8 importlib-metadata,
9 mock,
10 openssh,
11 packaging,
12 pexpect,
13 pytest-mock,
14 pytest-timeout,
15 pytest-xdist,
16 pytestCheckHook,
17 pythonOlder,
18 python-daemon,
19 pyyaml,
20 setuptools,
21 setuptools-scm,
22}:
23
24buildPythonPackage rec {
25 pname = "ansible-runner";
26 version = "2.4.0";
27 pyproject = true;
28
29 disabled = pythonOlder "3.9";
30
31 src = fetchPypi {
32 inherit pname version;
33 hash = "sha256-gtArJUiDDzelNRe2XII8SvNxBpQGx9ITtckEHUXgxbY=";
34 };
35
36 postPatch = ''
37 substituteInPlace pyproject.toml \
38 --replace-fail '"setuptools>=45, <=69.0.2", "setuptools-scm[toml]>=6.2, <=8.0.4"' '"setuptools", "setuptools-scm"'
39 '';
40
41 build-system = [
42 setuptools
43 setuptools-scm
44 ];
45
46 dependencies = [
47 packaging
48 pexpect
49 python-daemon
50 pyyaml
51 ] ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ];
52
53 nativeCheckInputs = [
54 ansible-core # required to place ansible CLI onto the PATH in tests
55 glibcLocales
56 pytestCheckHook
57 pytest-mock
58 pytest-timeout
59 pytest-xdist
60 mock
61 openssh
62 ];
63
64 preCheck = ''
65 export HOME=$(mktemp -d)
66 export PATH="$PATH:$out/bin";
67 # avoid coverage flags
68 rm pytest.ini
69 '';
70
71 disabledTests = [
72 # Tests require network access
73 "test_callback_plugin_task_args_leak"
74 "test_env_accuracy"
75 # Times out on slower hardware
76 "test_large_stdout_blob"
77 # Failed: DID NOT RAISE <class 'RuntimeError'>
78 "test_validate_pattern"
79 # Assertion error
80 "test_get_role_list"
81 "test_include_role_from_collection_events"
82 "test_resolved_actions"
83 "test_callback_plugin_censoring_does_not_overwrite"
84 ];
85
86 disabledTestPaths =
87 [
88 # These tests unset PATH and then run executables like `bash` (see https://github.com/ansible/ansible-runner/pull/918)
89 "test/integration/test_runner.py"
90 "test/unit/test_runner.py"
91 ]
92 ++ lib.optionals stdenv.hostPlatform.isDarwin [
93 # Integration tests on Darwin are not regularly passing in ansible-runner's own CI
94 "test/integration"
95 # These tests write to `/tmp` which is not writable on Darwin
96 "test/unit/config/test__base.py"
97 ];
98
99 pythonImportsCheck = [ "ansible_runner" ];
100
101 meta = with lib; {
102 description = "Helps when interfacing with Ansible";
103 homepage = "https://github.com/ansible/ansible-runner";
104 changelog = "https://github.com/ansible/ansible-runner/releases/tag/${version}";
105 license = licenses.asl20;
106 maintainers = [ ];
107 mainProgram = "ansible-runner";
108 };
109}