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