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