summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/ansible-runner/default.nix
blob: 346907d999b6b24ee643d4ac26e66b888f51bc3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,

  # build-system
  setuptools,
  setuptools-scm,

  # dependencies
  packaging,
  pexpect,
  python-daemon,
  pyyaml,

  # tests
  addBinToPathHook,
  ansible-core,
  glibcLocales,
  mock,
  openssh,
  pytest-mock,
  pytest-timeout,
  pytest-xdist,
  pytestCheckHook,
  versionCheckHook,
  writableTmpDirAsHomeHook,
}:

buildPythonPackage rec {
  pname = "ansible-runner";
  version = "2.4.2";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "ansible";
    repo = "ansible-runner";
    tag = version;
    hash = "sha256-aO7AcDtPbbmTsY+39oZYdPABYFy6bK3ZR1jatLTb7O4=";
  };

  postPatch = ''
    substituteInPlace pyproject.toml \
      --replace-fail "setuptools>=45, <=70.0.0" setuptools \
      --replace-fail "setuptools-scm[toml]>=6.2, <=8.1.0" setuptools-scm
  '';

  build-system = [
    setuptools
    setuptools-scm
  ];

  dependencies = [
    packaging
    pexpect
    python-daemon
    pyyaml
  ];

  nativeCheckInputs = [
    addBinToPathHook
    ansible-core # required to place ansible CLI onto the PATH in tests
    glibcLocales
    mock
    openssh
    pytest-mock
    pytest-timeout
    pytest-xdist
    pytestCheckHook
    versionCheckHook
    writableTmpDirAsHomeHook
  ];

  preCheck = ''
    # avoid coverage flags
    rm pytest.ini
  '';

  disabledTests = [
    # Tests require network access
    "test_callback_plugin_task_args_leak"
    "test_env_accuracy"
    # Times out on slower hardware
    "test_large_stdout_blob"
    # Failed: DID NOT RAISE <class 'RuntimeError'>
    "test_validate_pattern"
    # Assertion error
    "test_callback_plugin_censoring_does_not_overwrite"
    "test_get_role_list"
    "test_include_role_events"
    "test_include_role_from_collection_events"
    "test_module_level_no_log"
    "test_output_when_given_invalid_playbook"
    "test_resolved_actions"
  ];

  disabledTestPaths = [
    # These tests unset PATH and then run executables like `bash` (see https://github.com/ansible/ansible-runner/pull/918)
    "test/integration/test_runner.py"
    "test/unit/test_runner.py"
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # Integration tests on Darwin are not regularly passing in ansible-runner's own CI
    "test/integration"
    # These tests write to `/tmp` which is not writable on Darwin
    "test/unit/config/test__base.py"
  ];

  pythonImportsCheck = [ "ansible_runner" ];

  meta = {
    description = "Helps when interfacing with Ansible";
    homepage = "https://github.com/ansible/ansible-runner";
    changelog = "https://github.com/ansible/ansible-runner/releases/tag/${version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ GaetanLepage ];
    mainProgram = "ansible-runner";
  };
}