Gentoo Archives: gentoo-commits

From: Denis Dupeyron <calchan@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-admin/ansible/, app-admin/ansible/files/, profiles/
Date: Wed, 09 Aug 2017 17:25:53
Message-Id: 1502299363.450cb03a2d599c16754bb36da218f39a4556b245.calchan@gentoo
1 commit: 450cb03a2d599c16754bb36da218f39a4556b245
2 Author: Denis Dupeyron <calchan <AT> gentoo <DOT> org>
3 AuthorDate: Wed Aug 9 17:22:43 2017 +0000
4 Commit: Denis Dupeyron <calchan <AT> gentoo <DOT> org>
5 CommitDate: Wed Aug 9 17:22:43 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=450cb03a
7
8 app-admin/ansible: add masked 2.3.2.0-r1
9
10 Fix a long standing incompatibility between recent versions of ansible
11 and jinja.
12 https://github.com/ansible/ansible/issues/20494
13
14 Based on a patch by Zac Medico at:
15 https://github.com/zmedico/ansible/pull/1/commits/32e5613a95e525c3a25b8cd5aa1beaa75a4b0d5c
16
17 Masked for testing.
18
19 app-admin/ansible/ansible-2.3.2.0-r1.ebuild | 64 +++++++++++++++++++
20 .../files/ansible-2.3.2.0-fix_key_error.patch | 74 ++++++++++++++++++++++
21 profiles/package.mask | 5 ++
22 3 files changed, 143 insertions(+)
23
24 diff --git a/app-admin/ansible/ansible-2.3.2.0-r1.ebuild b/app-admin/ansible/ansible-2.3.2.0-r1.ebuild
25 new file mode 100644
26 index 00000000000..17a663cf185
27 --- /dev/null
28 +++ b/app-admin/ansible/ansible-2.3.2.0-r1.ebuild
29 @@ -0,0 +1,64 @@
30 +# Copyright 1999-2017 Gentoo Foundation
31 +# Distributed under the terms of the GNU General Public License v2
32 +
33 +EAPI=6
34 +
35 +PYTHON_COMPAT=( python2_7 )
36 +
37 +inherit distutils-r1 eutils versionator
38 +
39 +DESCRIPTION="Model-driven deployment, config management, and command execution framework"
40 +HOMEPAGE="http://ansible.com/"
41 +SRC_URI="http://releases.ansible.com/${PN}/${P}.tar.gz
42 + https://dev.gentoo.org/~prometheanfire/dist/ansible/ansible-2.3.2.0-pycryptodome.patch"
43 +
44 +LICENSE="GPL-3"
45 +SLOT="0"
46 +KEYWORDS="~amd64 ~x86 ~x64-macos"
47 +IUSE="test"
48 +
49 +RDEPEND="
50 + dev-python/paramiko[${PYTHON_USEDEP}]
51 + dev-python/jinja[${PYTHON_USEDEP}]
52 + dev-python/pyyaml[${PYTHON_USEDEP}]
53 + dev-python/setuptools[${PYTHON_USEDEP}]
54 + || (
55 + dev-python/pycryptodome[${PYTHON_USEDEP}]
56 + >=dev-python/pycrypto-2.6[${PYTHON_USEDEP}]
57 + )
58 + dev-python/httplib2[${PYTHON_USEDEP}]
59 + dev-python/six[${PYTHON_USEDEP}]
60 + net-misc/sshpass
61 + virtual/ssh
62 +"
63 +DEPEND="
64 + dev-python/setuptools[${PYTHON_USEDEP}]
65 + >=dev-python/packaging-16.6[${PYTHON_USEDEP}]
66 + test? (
67 + ${RDEPEND}
68 + dev-python/nose[${PYTHON_USEDEP}]
69 + >=dev-python/mock-1.0.1[${PYTHON_USEDEP}]
70 + <dev-python/mock-1.1[${PYTHON_USEDEP}]
71 + dev-python/passlib[${PYTHON_USEDEP}]
72 + dev-python/coverage[${PYTHON_USEDEP}]
73 + dev-python/unittest2[${PYTHON_USEDEP}]
74 + dev-vcs/git
75 + )"
76 +
77 +# not included in release tarball
78 +RESTRICT="test"
79 +
80 +PATCHES=(
81 + "${DISTDIR}/${PN}-2.3.2.0-pycryptodome.patch"
82 + "${FILESDIR/${PN}-2.3.2.0-fix_key_error.patch}"
83 + )
84 +
85 +python_test() {
86 + nosetests -d -w test/units -v --with-coverage --cover-package=ansible --cover-branches || die
87 +}
88 +
89 +python_install_all() {
90 + distutils-r1_python_install_all
91 +
92 + doman docs/man/man1/*.1
93 +}
94
95 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
96 new file mode 100644
97 index 00000000000..80b9350d3e3
98 --- /dev/null
99 +++ b/app-admin/ansible/files/ansible-2.3.2.0-fix_key_error.patch
100 @@ -0,0 +1,74 @@
101 +From fbe9ec58c7f48d2cef4a49ba96e84bce5933d654 Mon Sep 17 00:00:00 2001
102 +From: Denis Dupeyron <calchan@g.o>
103 +Date: Wed, 9 Aug 2017 12:01:31 -0500
104 +Subject: [PATCH] template: fix KeyError: 'undefined variable: 0
105 +
106 +Fixes: https://github.com/ansible/ansible/issues/20494
107 +
108 +Based on a patch by Zac Medico at:
109 +https://github.com/zmedico/ansible/pull/1/commits/32e5613a95e525c3a25b8cd5aa1beaa75a4b0d5c
110 +---
111 + lib/ansible/template/template.py | 10 ++++++++--
112 + lib/ansible/template/vars.py | 14 +++++++++++++-
113 + 2 files changed, 21 insertions(+), 3 deletions(-)
114 +
115 +diff --git a/lib/ansible/template/template.py b/lib/ansible/template/template.py
116 +index 55936f4..fe11471 100644
117 +--- a/lib/ansible/template/template.py
118 ++++ b/lib/ansible/template/template.py
119 +@@ -33,5 +33,11 @@ class AnsibleJ2Template(jinja2.environment.Template):
120 + '''
121 +
122 + def new_context(self, vars=None, shared=False, locals=None):
123 +- return self.environment.context_class(self.environment, vars.add_locals(locals), self.name, self.blocks)
124 +-
125 ++ if vars is not None:
126 ++ if isinstance(vars, dict):
127 ++ vars = vars.copy()
128 ++ if locals is not None:
129 ++ vars.update(locals)
130 ++ else:
131 ++ vars = vars.add_locals(locals)
132 ++ return self.environment.context_class(self.environment, vars, self.name, self.blocks)
133 +diff --git a/lib/ansible/template/vars.py b/lib/ansible/template/vars.py
134 +index fc6140c..2bf95ac 100644
135 +--- a/lib/ansible/template/vars.py
136 ++++ b/lib/ansible/template/vars.py
137 +@@ -19,6 +19,8 @@
138 + from __future__ import (absolute_import, division, print_function)
139 + __metaclass__ = type
140 +
141 ++from collections import Mapping
142 ++
143 + from ansible.compat.six import iteritems
144 + from jinja2.utils import missing
145 + from ansible.module_utils._text import to_native
146 +@@ -27,7 +29,7 @@ from ansible.module_utils._text import to_native
147 + __all__ = ['AnsibleJ2Vars']
148 +
149 +
150 +-class AnsibleJ2Vars:
151 ++class AnsibleJ2Vars(Mapping):
152 + '''
153 + Helper class to template all variable content before jinja2 sees it. This is
154 + done by hijacking the variable storage that jinja2 uses, and overriding __contains__
155 +@@ -68,6 +70,16 @@ class AnsibleJ2Vars:
156 + return True
157 + return False
158 +
159 ++ def __iter__(self):
160 ++ keys = set()
161 ++ keys.update(self._templar._available_variables, self._locals, self._globals, *self._extras)
162 ++ return iter(keys)
163 ++
164 ++ def __len__(self):
165 ++ keys = set()
166 ++ keys.update(self._templar._available_variables, self._locals, self._globals, *self._extras)
167 ++ return len(keys)
168 ++
169 + def __getitem__(self, varname):
170 + if varname not in self._templar._available_variables:
171 + if varname in self._locals:
172 +--
173 +2.13.3
174 +
175
176 diff --git a/profiles/package.mask b/profiles/package.mask
177 index c11dde36d83..7682d12d05a 100644
178 --- a/profiles/package.mask
179 +++ b/profiles/package.mask
180 @@ -29,6 +29,11 @@
181
182 #--- END OF EXAMPLES ---
183
184 +# Denis Dupeyron <calchan@g.o> (09 AUg 2017)
185 +# Masked for testing of fix for long standing incompatibility between recent versions of ansible and jinja
186 +# https://github.com/ansible/ansible/issues/20494
187 +=app-admin/ansible-2.3.2.0-r1
188 +
189 # Pawel Hajdan, Jr. <phajdan.jr@g.o> (09 Aug 2017)
190 # Dev channel releases are only for people who are developers or want more
191 # experimental features and accept a more unstable release.