3
0
Fork 0
forked from mirrors/nixpkgs

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
commit ee2d7e432f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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; {

View file

@ -1,36 +0,0 @@
{ stdenv, fetchFromGitHub, pythonPackages, ansible }:
pythonPackages.buildPythonPackage rec {
pname = "ansible-lint";
version = "3.5.1";
src = fetchFromGitHub {
owner = "willthames";
repo = "ansible-lint";
rev = "v${version}";
sha256 = "09qixiaqhm6dbl74s1rwxbsg31nr6jjsvr4fxfnxl9ccbxcrpzn2";
};
propagatedBuildInputs = with pythonPackages; [ pyyaml six ] ++ [ ansible ];
checkInputs = [ pythonPackages.nose ];
postPatch = ''
patchShebangs bin/ansible-lint
'';
preBuild = ''
export HOME="$TMP"
'';
checkPhase = ''
nosetests test
'';
meta = {
homepage = "https://github.com/willthames/ansible-lint";
description = "Best practices checker for Ansible";
license = stdenv.lib.licenses.mit;
maintainers = [ stdenv.lib.maintainers.sengaya ];
};
}

View file

@ -1,72 +1,27 @@
{ stdenv, fetchurl, python2
, windowsSupport ? false
}:
{ python3Packages, fetchurl }:
let
generic = { version, sha256, py ? python2 }: py.pkgs.buildPythonPackage rec {
{
ansible = with python3Packages; toPythonApplication ansible;
ansible_2_7 = with python3Packages; toPythonApplication ansible;
ansible_2_6 = with python3Packages; toPythonApplication (ansible.overridePythonAttrs(old: rec {
pname = "ansible";
inherit version;
outputs = [ "out" "man" ];
version = "2.6.9";
src = fetchurl {
url = "https://releases.ansible.com/ansible/${pname}-${version}.tar.gz";
inherit sha256;
sha256 = "12mysvdavkypgmyms1wjq2974lk97w893k23i6khigxrjj6r85z1";
};
}));
prePatch = ''
sed -i "s,/usr/,$out," lib/ansible/constants.py
'';
ansible_2_5 = with python3Packages; toPythonApplication (ansible.overridePythonAttrs(old: rec {
pname = "ansible";
version = "2.5.14";
postInstall = ''
wrapPythonProgramsIn "$out/bin" "$out $PYTHONPATH"
for m in docs/man/man1/*; do
install -vD $m -t $man/share/man/man1
done
'';
doCheck = false;
dontStrip = true;
dontPatchELF = true;
dontPatchShebangs = false;
propagatedBuildInputs = with py.pkgs; [
pycrypto paramiko jinja2 pyyaml httplib2 boto six netaddr dnspython jmespath dopy
] ++ stdenv.lib.optional windowsSupport pywinrm;
meta = with stdenv.lib; {
homepage = http://www.ansible.com;
description = "A simple automation tool";
license = with licenses; [ gpl3 ] ;
maintainers = with maintainers; [ jgeerds joamaki ];
platforms = with platforms; linux ++ darwin;
src = fetchurl {
url = "https://releases.ansible.com/ansible/${pname}-${version}.tar.gz";
sha256 = "0sd04h2k5qv4m48dn76jkjlwlqfdk15hzyagj9i71r8brvmwhnk9";
};
};
in rec {
# We will carry all the supported versions
ansible_2_4 = generic {
version = "2.4.4.0";
sha256 = "0n1k6h0h6av74nw8vq98fmh6q4pq6brpwmx45282vh3bkdmpa0ib";
};
ansible_2_5 = generic {
version = "2.5.11";
sha256 = "07rhgkl3a2ba59rqh9pyz1p661gc389shlwa2sw1m6wwifg4lm24";
};
ansible_2_6 = generic {
version = "2.6.7";
sha256 = "10pakw9k9wd3cy1qk3ah2253ph7c7h3qzpal4k0s5lschzgy2fh0";
};
ansible_2_7 = generic {
version = "2.7.6";
sha256 = "0f7b2ghm34ql8yv90wr0ngd6w7wyvnlcxpc3snkj86kcjsnmx1bd";
};
ansible2 = ansible_2_7;
ansible = ansible2;
}));
}

View file

@ -1,4 +1,4 @@
{ stdenv, fetchurl, python2Packages, ansible2 }:
{ stdenv, fetchurl, python2Packages }:
python2Packages.buildPythonApplication rec {
version = "0.4.6";
@ -12,7 +12,7 @@ python2Packages.buildPythonApplication rec {
doCheck = false;
propagatedBuildInputs = with python2Packages; [
ansible2
ansible
boto
cffi
cryptography

View file

@ -8308,15 +8308,13 @@ in
augeas = callPackage ../tools/system/augeas { };
inherit (callPackages ../tools/admin/ansible {})
ansible_2_4
inherit (callPackage ../tools/admin/ansible { })
ansible
ansible_2_5
ansible_2_6
ansible_2_7
ansible2
ansible;
ansible_2_7;
ansible-lint = callPackage ../development/tools/ansible-lint {};
ansible-lint = with python3.pkgs; toPythonApplication ansible-lint;
antlr = callPackage ../development/tools/parsing/antlr/2.7.7.nix { };

View file

@ -922,6 +922,14 @@ in {
allpairspy = callPackage ../development/python-modules/allpairspy { };
ansible = callPackage ../development/python-modules/ansible { };
ansible-kernel = callPackage ../development/python-modules/ansible-kernel { };
ansible-lint = callPackage ../development/python-modules/ansible-lint { };
ansible-runner = callPackage ../development/python-modules/ansible-runner { };
ansicolors = callPackage ../development/python-modules/ansicolors {};
aniso8601 = callPackage ../development/python-modules/aniso8601 {};