Merge pull request #56323 from costrouc/python-ansible-refactor

Move ansible to python-modules and use toPythonApplication + ansible related packages
This commit is contained in:
Robert Schütz
2019-03-01 21:08:54 +01:00
committed by GitHub
10 changed files with 235 additions and 109 deletions

View File

@@ -0,0 +1,60 @@
{ lib
, buildPythonPackage
, fetchPypi
, writeText
, ipywidgets
, six
, docopt
, tqdm
, jupyter
, psutil
, pyyaml
, ansible-runner
, ansible
, python
}:
let
kernelSpecFile = writeText "kernel.json" (builtins.toJSON {
argv = [ "${python.interpreter}" "-m" "ansible_kernel" "-f" "{connection_file}" ];
codemirror_mode = "yaml";
display_name = "Ansible";
language = "ansible";
});
in
buildPythonPackage rec {
pname = "ansible-kernel";
version = "0.9.0";
src = fetchPypi {
inherit pname version;
sha256 = "a59039a1724c0f4f4435316e2ad3383f2328ae61f190e74414a66cc8c4637636";
};
propagatedBuildInputs = [ ipywidgets six docopt tqdm jupyter psutil pyyaml ansible-runner ansible ];
postPatch = ''
# remove when merged
# https://github.com/ansible/ansible-jupyter-kernel/pull/82
touch LICENSE.md
# remove custom install
sed -i "s/cmdclass={'install': Installer},//" setup.py
'';
# tests hang with launched kernel
doCheck = false;
# install kernel manually
postInstall = ''
mkdir -p $out/share/jupyter/kernels/ansible/
ln -s ${kernelSpecFile} $out/share/jupyter/kernels/ansible/kernel.json
'';
meta = with lib; {
description = "An Ansible kernel for Jupyter";
homepage = https://github.com/ansible/ansible-jupyter-kernel;
license = licenses.asl20;
maintainers = [ maintainers.costrouc ];
};
}

View File

@@ -0,0 +1,46 @@
{ lib
, fetchPypi
, buildPythonPackage
, ansible
, pyyaml
, six
, nose
, setuptools_scm
, ruamel_yaml
}:
buildPythonPackage rec {
pname = "ansible-lint";
version = "4.1.0";
src = fetchPypi {
inherit pname version;
sha256 = "9430ea6e654ba4bf5b9c6921efc040f46cda9c4fd2896a99ff71d21037bcb123";
};
nativeBuildInputs = [ setuptools_scm ];
propagatedBuildInputs = [ pyyaml six ansible ruamel_yaml ];
checkInputs = [ nose ];
postPatch = ''
patchShebangs bin/ansible-lint
substituteInPlace setup.cfg \
--replace "setuptools_scm_git_archive>=1.0" ""
'';
# give a hint to setuptools_scm on package version
preBuild = ''
export SETUPTOOLS_SCM_PRETEND_VERSION="v${version}"
'';
checkPhase = ''
PATH=$out/bin:$PATH HOME=$(mktemp -d) nosetests test
'';
meta = with lib; {
homepage = "https://github.com/willthames/ansible-lint";
description = "Best practices checker for Ansible";
license = licenses.mit;
maintainers = [ maintainers.sengaya ];
};
}

View File

@@ -0,0 +1,43 @@
{ lib
, buildPythonPackage
, fetchPypi
, psutil
, pexpect
, python-daemon
, pyyaml
, six
, ansible
, pytest
, mock
}:
buildPythonPackage rec {
pname = "ansible-runner";
version = "1.2.0";
src = fetchPypi {
inherit pname version;
sha256 = "9c2fc02bd22ac831138bfd2241e1664d7700bbb2c61f96b8b1f2d83ab4ea59a7";
};
checkInputs = [ pytest mock ];
propagatedBuildInputs = [
ansible
psutil
pexpect
python-daemon
pyyaml
six
];
checkPhase = ''
HOME=$(mktemp -d) pytest --ignore test/unit/test_runner.py -k "not test_prepare"
'';
meta = with lib; {
description = "Helps when interfacing with Ansible";
homepage = https://github.com/ansible/ansible-runner;
license = licenses.asl20;
maintainers = [ maintainers.costrouc ];
};
}

View File

@@ -0,0 +1,53 @@
{ lib
, fetchurl
, buildPythonPackage
, pycrypto
, paramiko
, jinja2
, pyyaml
, httplib2
, boto
, six
, netaddr
, dnspython
, jmespath
, dopy
, windowsSupport ? false
, pywinrm
}:
buildPythonPackage rec {
pname = "ansible";
version = "2.7.8";
src = fetchurl {
url = "https://releases.ansible.com/ansible/${pname}-${version}.tar.gz";
sha256 = "11yx7vd0mp5gkq428af141dwnrwf8f9cp3f65243qbs9icjxnrrx";
};
prePatch = ''
sed -i "s,/usr/,$out," lib/ansible/constants.py
'';
postInstall = ''
for m in docs/man/man1/*; do
install -vD $m -t $out/share/man/man1
done
'';
propagatedBuildInputs = [
pycrypto paramiko jinja2 pyyaml httplib2 boto
six netaddr dnspython jmespath dopy
] ++ lib.optional windowsSupport pywinrm;
# dificult to test
doCheck = false;
meta = with lib; {
homepage = http://www.ansible.com;
description = "Radically simple IT automation";
license = [ licenses.gpl3 ] ;
maintainers = with maintainers; [ jgeerds joamaki costrouc ];
platforms = platforms.linux ++ platforms.darwin;
};
}

View File

@@ -8,9 +8,8 @@
}:
buildPythonPackage rec {
version = "2.0.2";
pname = "pytest-ansible";
disabled = isPy3k;
version = "2.0.2";
src = fetchPypi {
inherit pname version;
@@ -30,7 +29,7 @@ buildPythonPackage rec {
doCheck = false;
checkPhase = ''
pytest tests
pytest
'';
meta = with stdenv.lib; {