diff options
author | Denis Dupeyron <calchan@gentoo.org> | 2017-08-09 12:22:43 -0500 |
---|---|---|
committer | Denis Dupeyron <calchan@gentoo.org> | 2017-08-09 12:22:43 -0500 |
commit | 450cb03a2d599c16754bb36da218f39a4556b245 (patch) | |
tree | 53ca64733bda42cfa0acafe0fa81b363d7e642a9 /app-admin | |
parent | dev-python/pyavm: version bump (diff) | |
download | gentoo-450cb03a2d599c16754bb36da218f39a4556b245.tar.gz gentoo-450cb03a2d599c16754bb36da218f39a4556b245.tar.bz2 gentoo-450cb03a2d599c16754bb36da218f39a4556b245.zip |
app-admin/ansible: add masked 2.3.2.0-r1
Fix a long standing incompatibility between recent versions of ansible
and jinja.
https://github.com/ansible/ansible/issues/20494
Based on a patch by Zac Medico at:
https://github.com/zmedico/ansible/pull/1/commits/32e5613a95e525c3a25b8cd5aa1beaa75a4b0d5c
Masked for testing.
Diffstat (limited to 'app-admin')
-rw-r--r-- | app-admin/ansible/ansible-2.3.2.0-r1.ebuild | 64 | ||||
-rw-r--r-- | app-admin/ansible/files/ansible-2.3.2.0-fix_key_error.patch | 74 |
2 files changed, 138 insertions, 0 deletions
diff --git a/app-admin/ansible/ansible-2.3.2.0-r1.ebuild b/app-admin/ansible/ansible-2.3.2.0-r1.ebuild new file mode 100644 index 000000000000..17a663cf1850 --- /dev/null +++ b/app-admin/ansible/ansible-2.3.2.0-r1.ebuild @@ -0,0 +1,64 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +PYTHON_COMPAT=( python2_7 ) + +inherit distutils-r1 eutils versionator + +DESCRIPTION="Model-driven deployment, config management, and command execution framework" +HOMEPAGE="http://ansible.com/" +SRC_URI="http://releases.ansible.com/${PN}/${P}.tar.gz + https://dev.gentoo.org/~prometheanfire/dist/ansible/ansible-2.3.2.0-pycryptodome.patch" + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86 ~x64-macos" +IUSE="test" + +RDEPEND=" + dev-python/paramiko[${PYTHON_USEDEP}] + dev-python/jinja[${PYTHON_USEDEP}] + dev-python/pyyaml[${PYTHON_USEDEP}] + dev-python/setuptools[${PYTHON_USEDEP}] + || ( + dev-python/pycryptodome[${PYTHON_USEDEP}] + >=dev-python/pycrypto-2.6[${PYTHON_USEDEP}] + ) + dev-python/httplib2[${PYTHON_USEDEP}] + dev-python/six[${PYTHON_USEDEP}] + net-misc/sshpass + virtual/ssh +" +DEPEND=" + dev-python/setuptools[${PYTHON_USEDEP}] + >=dev-python/packaging-16.6[${PYTHON_USEDEP}] + test? ( + ${RDEPEND} + dev-python/nose[${PYTHON_USEDEP}] + >=dev-python/mock-1.0.1[${PYTHON_USEDEP}] + <dev-python/mock-1.1[${PYTHON_USEDEP}] + dev-python/passlib[${PYTHON_USEDEP}] + dev-python/coverage[${PYTHON_USEDEP}] + dev-python/unittest2[${PYTHON_USEDEP}] + dev-vcs/git + )" + +# not included in release tarball +RESTRICT="test" + +PATCHES=( + "${DISTDIR}/${PN}-2.3.2.0-pycryptodome.patch" + "${FILESDIR/${PN}-2.3.2.0-fix_key_error.patch}" + ) + +python_test() { + nosetests -d -w test/units -v --with-coverage --cover-package=ansible --cover-branches || die +} + +python_install_all() { + distutils-r1_python_install_all + + doman docs/man/man1/*.1 +} diff --git a/app-admin/ansible/files/ansible-2.3.2.0-fix_key_error.patch b/app-admin/ansible/files/ansible-2.3.2.0-fix_key_error.patch new file mode 100644 index 000000000000..80b9350d3e37 --- /dev/null +++ b/app-admin/ansible/files/ansible-2.3.2.0-fix_key_error.patch @@ -0,0 +1,74 @@ +From fbe9ec58c7f48d2cef4a49ba96e84bce5933d654 Mon Sep 17 00:00:00 2001 +From: Denis Dupeyron <calchan@gentoo.org> +Date: Wed, 9 Aug 2017 12:01:31 -0500 +Subject: [PATCH] template: fix KeyError: 'undefined variable: 0 + +Fixes: https://github.com/ansible/ansible/issues/20494 + +Based on a patch by Zac Medico at: +https://github.com/zmedico/ansible/pull/1/commits/32e5613a95e525c3a25b8cd5aa1beaa75a4b0d5c +--- + lib/ansible/template/template.py | 10 ++++++++-- + lib/ansible/template/vars.py | 14 +++++++++++++- + 2 files changed, 21 insertions(+), 3 deletions(-) + +diff --git a/lib/ansible/template/template.py b/lib/ansible/template/template.py +index 55936f4..fe11471 100644 +--- a/lib/ansible/template/template.py ++++ b/lib/ansible/template/template.py +@@ -33,5 +33,11 @@ class AnsibleJ2Template(jinja2.environment.Template): + ''' + + def new_context(self, vars=None, shared=False, locals=None): +- return self.environment.context_class(self.environment, vars.add_locals(locals), self.name, self.blocks) +- ++ if vars is not None: ++ if isinstance(vars, dict): ++ vars = vars.copy() ++ if locals is not None: ++ vars.update(locals) ++ else: ++ vars = vars.add_locals(locals) ++ return self.environment.context_class(self.environment, vars, self.name, self.blocks) +diff --git a/lib/ansible/template/vars.py b/lib/ansible/template/vars.py +index fc6140c..2bf95ac 100644 +--- a/lib/ansible/template/vars.py ++++ b/lib/ansible/template/vars.py +@@ -19,6 +19,8 @@ + from __future__ import (absolute_import, division, print_function) + __metaclass__ = type + ++from collections import Mapping ++ + from ansible.compat.six import iteritems + from jinja2.utils import missing + from ansible.module_utils._text import to_native +@@ -27,7 +29,7 @@ from ansible.module_utils._text import to_native + __all__ = ['AnsibleJ2Vars'] + + +-class AnsibleJ2Vars: ++class AnsibleJ2Vars(Mapping): + ''' + Helper class to template all variable content before jinja2 sees it. This is + done by hijacking the variable storage that jinja2 uses, and overriding __contains__ +@@ -68,6 +70,16 @@ class AnsibleJ2Vars: + return True + return False + ++ def __iter__(self): ++ keys = set() ++ keys.update(self._templar._available_variables, self._locals, self._globals, *self._extras) ++ return iter(keys) ++ ++ def __len__(self): ++ keys = set() ++ keys.update(self._templar._available_variables, self._locals, self._globals, *self._extras) ++ return len(keys) ++ + def __getitem__(self, varname): + if varname not in self._templar._available_variables: + if varname in self._locals: +-- +2.13.3 + |