2019-02-24 21:53:30 +00:00
|
|
|
{ lib
|
|
|
|
, fetchPypi
|
|
|
|
, buildPythonPackage
|
2020-02-23 20:38:55 +00:00
|
|
|
, isPy27
|
2019-02-24 21:53:30 +00:00
|
|
|
, ansible
|
|
|
|
, pyyaml
|
2021-03-07 18:18:07 +00:00
|
|
|
, ruamel-yaml
|
2020-10-18 18:04:41 +01:00
|
|
|
, rich
|
|
|
|
, pytestCheckHook
|
2021-03-07 18:18:07 +00:00
|
|
|
, pytest-xdist
|
2020-10-18 18:04:41 +01:00
|
|
|
, git
|
2021-03-07 18:18:07 +00:00
|
|
|
, wcmatch
|
|
|
|
, enrich
|
|
|
|
, python
|
2019-02-24 21:53:30 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "ansible-lint";
|
2021-03-07 18:18:07 +00:00
|
|
|
version = "5.0.2";
|
2020-02-23 20:38:55 +00:00
|
|
|
disabled = isPy27;
|
2021-03-07 18:18:07 +00:00
|
|
|
format = "pyproject";
|
2019-02-24 21:53:30 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2021-03-07 18:18:07 +00:00
|
|
|
sha256 = "sha256-vgt/KqNozTPaON/I19SybBZuo7bbl3Duq5dTBTMlj44=";
|
2019-02-24 21:53:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
2021-03-07 18:18:07 +00:00
|
|
|
substituteInPlace src/ansiblelint/file_utils.py \
|
|
|
|
--replace 'raise RuntimeError("Unable to determine file type for %s" % pathex)' 'return "playbook"'
|
2019-02-24 21:53:30 +00:00
|
|
|
'';
|
|
|
|
|
2021-03-07 18:18:07 +00:00
|
|
|
buildInputs = [ python ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ ansible enrich pyyaml rich ruamel-yaml wcmatch ];
|
|
|
|
|
|
|
|
checkInputs = [ pytestCheckHook pytest-xdist git ];
|
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
# ansible wants to write to $HOME and crashes if it can't
|
2020-01-02 21:59:09 +00:00
|
|
|
export HOME=$(mktemp -d)
|
2021-03-07 18:18:07 +00:00
|
|
|
export PATH=$PATH:${lib.makeBinPath [ ansible ]}
|
2019-02-24 21:53:30 +00:00
|
|
|
|
2021-03-07 18:18:07 +00:00
|
|
|
# create a working ansible-lint executable
|
|
|
|
export PATH=$PATH:$PWD/src/ansiblelint
|
|
|
|
ln -rs src/ansiblelint/__main__.py src/ansiblelint/ansible-lint
|
|
|
|
patchShebangs src/ansiblelint/__main__.py
|
2019-02-24 21:53:30 +00:00
|
|
|
'';
|
|
|
|
|
2021-03-07 18:18:07 +00:00
|
|
|
disabledTests = [
|
|
|
|
# requires network
|
|
|
|
"test_prerun_reqs_v1"
|
|
|
|
"test_prerun_reqs_v2"
|
|
|
|
# Assertion error with negative numbers; maybe requieres an ansible update?
|
|
|
|
"test_negative"
|
|
|
|
"test_example"
|
|
|
|
"test_playbook"
|
|
|
|
"test_included_tasks"
|
|
|
|
"test_long_line"
|
|
|
|
|
|
|
|
"test_get_yaml_files_umlaut"
|
|
|
|
"test_run_inside_role_dir"
|
|
|
|
"test_role_handler_positive"
|
|
|
|
];
|
|
|
|
|
|
|
|
makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ ansible ]}" ];
|
|
|
|
|
2019-02-24 21:53:30 +00:00
|
|
|
meta = with lib; {
|
2021-03-07 18:18:07 +00:00
|
|
|
homepage = "https://github.com/ansible-community/ansible-lint";
|
2019-02-24 21:53:30 +00:00
|
|
|
description = "Best practices checker for Ansible";
|
|
|
|
license = licenses.mit;
|
2021-03-07 18:18:07 +00:00
|
|
|
maintainers = with maintainers; [ sengaya SuperSandro2000 ];
|
2019-02-24 21:53:30 +00:00
|
|
|
};
|
|
|
|
}
|