diff options
Diffstat (limited to 'nixpkgs/pkgs/tools/admin/ansible')
-rw-r--r-- | nixpkgs/pkgs/tools/admin/ansible/doctor.nix | 67 | ||||
-rw-r--r-- | nixpkgs/pkgs/tools/admin/ansible/later.nix | 87 | ||||
-rw-r--r-- | nixpkgs/pkgs/tools/admin/ansible/lint.nix | 91 |
3 files changed, 245 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/admin/ansible/doctor.nix b/nixpkgs/pkgs/tools/admin/ansible/doctor.nix new file mode 100644 index 000000000000..ef7ef6aabb85 --- /dev/null +++ b/nixpkgs/pkgs/tools/admin/ansible/doctor.nix @@ -0,0 +1,67 @@ +{ lib +, fetchFromGitHub +, fetchpatch +, python3 +}: + +python3.pkgs.buildPythonApplication rec { + pname = "ansible-doctor"; + version = "2.0.4"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "thegeeklab"; + repo = "ansible-doctor"; + rev = "refs/tags/v${version}"; + hash = "sha256-nZv1PdR0kGrke2AjcDWjDWBdsw64UpHYFNDFAe/UoJo="; + }; + + patches = [ + # https://github.com/thegeeklab/ansible-doctor/pull/541 + (fetchpatch { + name = "poetry-dynamic-versioning-pep517.patch"; + url = "https://github.com/thegeeklab/ansible-doctor/commit/b77ba9dccaef4b386bd54b128136c948665eb61a.patch"; + hash = "sha256-XfdTkRk9B857V5DQnxlbwxTb098YwHzKGzNQBTQzWCM="; + }) + ]; + + pythonRelaxDeps = true; + + nativeBuildInputs = with python3.pkgs; [ + poetry-core + poetry-dynamic-versioning + pythonRelaxDepsHook + ]; + + propagatedBuildInputs = with python3.pkgs; [ + anyconfig + appdirs + colorama + environs + jinja2 + jsonschema + nested-lookup + pathspec + python-json-logger + ruamel-yaml + ]; + + postInstall = '' + rm $out/lib/python*/site-packages/LICENSE + ''; + + # Module has no tests + doCheck = false; + + pythonImportsCheck = [ + "ansibledoctor" + ]; + + meta = with lib; { + description = "Annotation based documentation for your Ansible roles"; + homepage = "https://github.com/thegeeklab/ansible-doctor"; + changelog = "https://github.com/thegeeklab/ansible-doctor/releases/tag/v${version}"; + license = licenses.lgpl3Only; + maintainers = with maintainers; [ tboerger ]; + }; +} diff --git a/nixpkgs/pkgs/tools/admin/ansible/later.nix b/nixpkgs/pkgs/tools/admin/ansible/later.nix new file mode 100644 index 000000000000..733981ecd928 --- /dev/null +++ b/nixpkgs/pkgs/tools/admin/ansible/later.nix @@ -0,0 +1,87 @@ +{ lib +, fetchFromGitHub +, fetchpatch +, python3 +}: + +python3.pkgs.buildPythonApplication rec { + pname = "ansible-later"; + version = "3.3.1"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "thegeeklab"; + repo = pname; + rev = "refs/tags/v${version}"; + hash = "sha256-7k81eEcM+BXNrln6+Lu0+1LjsZdYkUidrRQCdlBbQB8="; + }; + + patches = [ + # https://github.com/thegeeklab/ansible-later/pull/658 + (fetchpatch { + name = "poetry-dynamic-versioning-pep517.patch"; + url = "https://github.com/thegeeklab/ansible-later/commit/a2c278fb45769648df1439df5bb25883dddfc58a.patch"; + hash = "sha256-++CiwwHZoaPC8XHaYbNQeU3zqEi2a4eIYbuSQkO0jTI="; + }) + ]; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace " --cov=ansiblelater --cov-report=xml:coverage.xml --cov-report=term --no-cov-on-fail" "" + ''; + + pythonRelaxDeps = [ + "flake8" + "jsonschema" + "pathspec" + "python-json-logger" + "PyYAML" + "toolz" + "unidiff" + "yamllint" + ]; + + nativeBuildInputs = with python3.pkgs; [ + poetry-core + poetry-dynamic-versioning + pythonRelaxDepsHook + ]; + + propagatedBuildInputs = with python3.pkgs; [ + ansible + ansible-core + anyconfig + appdirs + colorama + flake8 + jsonschema + nested-lookup + pathspec + python-json-logger + pyyaml + toolz + unidiff + yamllint + ]; + + nativeCheckInputs = with python3.pkgs; [ + pytest-mock + pytestCheckHook + ]; + + postInstall = '' + rm $out/lib/python*/site-packages/LICENSE + ''; + + pythonImportsCheck = [ + "ansiblelater" + ]; + + meta = with lib; { + description = "Best practice scanner for Ansible roles and playbooks"; + homepage = "https://github.com/thegeeklab/ansible-later"; + changelog = "https://github.com/thegeeklab/ansible-later/releases/tag/v${version}"; + license = licenses.mit; + maintainers = with maintainers; [ tboerger ]; + }; +} diff --git a/nixpkgs/pkgs/tools/admin/ansible/lint.nix b/nixpkgs/pkgs/tools/admin/ansible/lint.nix new file mode 100644 index 000000000000..fbac95d019ba --- /dev/null +++ b/nixpkgs/pkgs/tools/admin/ansible/lint.nix @@ -0,0 +1,91 @@ +{ lib +, python3 +, fetchPypi +, ansible +}: + +python3.pkgs.buildPythonApplication rec { + pname = "ansible-lint"; + version = "6.21.1"; + format = "pyproject"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-Bf/G38jzy79W9/l3CzQ2/HkJutXB11Rw76BkUx8C324="; + }; + + postPatch = '' + # it is fine if lint tools are missing + substituteInPlace conftest.py \ + --replace "sys.exit(1)" "" + ''; + + nativeBuildInputs = with python3.pkgs; [ + setuptools + setuptools-scm + ]; + + propagatedBuildInputs = with python3.pkgs; [ + # https://github.com/ansible/ansible-lint/blob/master/.config/requirements.in + ansible-core + ansible-compat + black + filelock + jsonschema + packaging + pyyaml + rich + ruamel-yaml + subprocess-tee + wcmatch + yamllint + ]; + + # tests can't be easily run without installing things from ansible-galaxy + doCheck = false; + + nativeCheckInputs = with python3.pkgs; [ + flaky + pytest-xdist + pytestCheckHook + ]; + + preCheck = '' + # ansible wants to write to $HOME and crashes if it can't + export HOME=$(mktemp -d) + export PATH=$PATH:${lib.makeBinPath [ ansible ]} + + # 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 + + # create symlink like in the git repo so test_included_tasks does not fail + ln -s ../roles examples/playbooks/roles + ''; + + disabledTests = [ + # requires network + "test_cli_auto_detect" + "test_install_collection" + "test_prerun_reqs_v1" + "test_prerun_reqs_v2" + "test_require_collection_wrong_version" + # re-execs ansible-lint which does not works correct + "test_custom_kinds" + "test_run_inside_role_dir" + "test_run_multiple_role_path_no_trailing_slash" + "test_runner_exclude_globs" + "test_discover_lintables_umlaut" + ]; + + makeWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ ansible ]}" ]; + + meta = with lib; { + description = "Best practices checker for Ansible"; + homepage = "https://github.com/ansible/ansible-lint"; + changelog = "https://github.com/ansible/ansible-lint/releases/tag/v${version}"; + license = licenses.mit; + maintainers = with maintainers; [ sengaya ]; + }; +} |