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