diff --git a/0001-Handle-downstream-version-additions.patch b/0001-Handle-downstream-version-additions.patch new file mode 100644 index 0000000..54de411 --- /dev/null +++ b/0001-Handle-downstream-version-additions.patch @@ -0,0 +1,56 @@ +From 0bc2d1f25860956f713ef0bdc86e67141360090d Mon Sep 17 00:00:00 2001 +From: Toshio Kuratomi +Date: Wed, 8 Mar 2017 14:06:29 -0800 +Subject: [PATCH] Handle downstream version additions + +Some downstreams want to ship multiple versions of ansible (Either to +have multiple ansible versions or to have a version that uses python3.X +and a version that uses python2.x). When they do this, they append +a version number to the cli scripts in /usr/bin. This patch will remove +those version numbers before trying to find the ansible python module to +import for this commandline +--- + bin/ansible | 26 ++++++++++++++++---------- + 1 file changed, 16 insertions(+), 10 deletions(-) + +diff --git a/bin/ansible b/bin/ansible +index 22dd449..24550b9 100755 +--- a/bin/ansible ++++ b/bin/ansible +@@ -69,17 +69,23 @@ if __name__ == '__main__': + display.debug("starting run") + + sub = None ++ target = me.split('-') ++ if target[-1][0].isdigit(): ++ # Remove any version or pthon version info as downstreams ++ # sometimes add that ++ target = target[:-1] ++ ++ if len(target) > 1: ++ sub = target[1] ++ myclass = "%sCLI" % sub.capitalize() ++ elif target[0] == 'ansible': ++ sub = 'adhoc' ++ myclass = 'AdHocCLI' ++ else: ++ raise AnsibleError("Unknown Ansible alias: %s" % me) ++ + try: +- if me.find('-') != -1: +- target = me.split('-') +- if len(target) > 1: +- sub = target[1] +- myclass = "%sCLI" % sub.capitalize() +- mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass) +- elif me == 'ansible': +- from ansible.cli.adhoc import AdHocCLI as mycli +- else: +- raise AnsibleError("Unknown Ansible alias: %s" % me) ++ mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass) + except ImportError as e: + # ImportError members have changed in py3 + if 'msg' in dir(e): +-- +2.9.3 + diff --git a/0001-Make-openvswitch-pass-py3-sanity-check.patch b/0001-Make-openvswitch-pass-py3-sanity-check.patch new file mode 100644 index 0000000..7f5ebbe --- /dev/null +++ b/0001-Make-openvswitch-pass-py3-sanity-check.patch @@ -0,0 +1,70 @@ +From 18098ad055c3159adcbe1a151bbd1f3b71b653f5 Mon Sep 17 00:00:00 2001 +From: Toshio Kuratomi +Date: Wed, 8 Mar 2017 12:32:47 -0800 +Subject: [PATCH] Make openvswitch* pass py3 sanity check + +(cherry picked from 7f4fdba0c6ab1a00e8be2fc517173d898f305a23) + +diff --git a/network/openvswitch_bridge.py b/network/openvswitch_bridge.py +index 68528dd..abe89df 100644 +--- a/lib/ansible/modules/extras/network/openvswitch_bridge.py ++++ b/lib/ansible/modules/extras/network/openvswitch_bridge.py +@@ -143,7 +143,8 @@ class OVSBridge(object): + changed = True + elif self.state == 'present' and not self.exists(): + changed = True +- except Exception, earg: ++ except Exception: ++ earg = get_exception() + self.module.fail_json(msg=str(earg)) + + # pylint: enable=W0703 +@@ -189,7 +190,8 @@ class OVSBridge(object): + self.set_external_id(key, None)): + changed = True + +- except Exception, earg: ++ except Exception: ++ earg = get_exception() + self.module.fail_json(msg=str(earg)) + # pylint: enable=W0703 + self.module.exit_json(changed=changed) +@@ -267,4 +269,5 @@ def main(): + + # import module snippets + from ansible.module_utils.basic import * ++from ansible.module_utils.pycompat24 import get_exception + main() +diff --git a/network/openvswitch_port.py b/network/openvswitch_port.py +index c2224b5..d2bf31a 100644 +--- a/lib/ansible/modules/extras/network/openvswitch_port.py ++++ b/lib/ansible/modules/extras/network/openvswitch_port.py +@@ -204,7 +204,8 @@ class OVSPort(object): + changed = True + else: + changed = False +- except Exception, earg: ++ except Exception: ++ earg = get_exception() + self.module.fail_json(msg=str(earg)) + self.module.exit_json(changed=changed) + +@@ -235,7 +236,8 @@ class OVSPort(object): + external_id = fmt_opt % (self.port, key, value) + changed = self.set(external_id) or changed + ## +- except Exception, earg: ++ except Exception: ++ earg = get_exception() + self.module.fail_json(msg=str(earg)) + self.module.exit_json(changed=changed) + +@@ -269,4 +271,5 @@ def main(): + + # import module snippets + from ansible.module_utils.basic import * ++from ansible.module_utils.pycompat24 import get_exception + main() +-- +2.9.3 + diff --git a/ansible.spec b/ansible.spec index 2b52c9c..4fa73c9 100644 --- a/ansible.spec +++ b/ansible.spec @@ -9,12 +9,18 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot %endif +%if 0%{?fedora} +%global with_python3 1 +%else +%global with_python3 0 +%endif + %{!?python_sitelib: %global python_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} Name: ansible Summary: SSH-based configuration management, deployment, and task execution system Version: 2.2.2.0 -Release: 0.1.rc1%{?dist} +Release: 0.2.rc1%{?dist} Group: Development/Libraries License: GPLv3+ @@ -31,6 +37,12 @@ Source100: get-unittests.sh # Upstream issue: https://github.com/ansible/ansible/issues/11536 Patch0: ansible-2.1.0.0-control_path.patch +# Make the Ansible cli script work with our addition of python version (upstreamed in 2.3) +Patch1: 0001-Handle-downstream-version-additions.patch + +# Upstream change to fix python3 compilation for openvswitch modules +Patch2: 0001-Make-openvswitch-pass-py3-sanity-check.patch + # Patch to utilize a newer jinja2 package on epel6 # Non-upstreamable as it creates a dependency on a specific version of jinja. # This is desirable for us as we have packages for that version but not for @@ -47,7 +59,6 @@ Requires: python26-PyYAML Requires: python26-paramiko Requires: python26-jinja2 Requires: python26-keyczar -Requires: python26-httplib2 %else @@ -60,8 +71,6 @@ BuildRequires: python-setuptools BuildRequires: PyYAML BuildRequires: python-paramiko BuildRequires: python-keyczar -BuildRequires: python-httplib2 -BuildRequires: python-setuptools BuildRequires: python-six BuildRequires: python-nose BuildRequires: python-coverage @@ -126,6 +135,61 @@ over SSH and does not require any software or daemons to be installed on remote nodes. Extension modules can be written in any language and are transferred to managed machines automatically. + +%if 0%{?with_python3} +# Note, ansible is not intended to be used as a library so avoiding the +# python3-ansible and python2-ansible package names so we don't confuse users. + +# Also note, similarly to dnf in its transition period, the python2 and python3 +# versions of ansible should behave identically but python3-only bugs may be present. +# So upstream would like us to ship both py2 and py3 ansible (at least in +# rawhide) for people to beat on and find bugs. +%package -n ansible-python3 +Summary: SSH-based configuration management, deployment, and task execution system +BuildRequires: python3-devel +BuildRequires: python3-setuptools + +# For tests +BuildRequires: python3-PyYAML +BuildRequires: python3-paramiko +# accelerate is the only thing that makes keyczar mandatory. Since accelerate +# is deprecated, just ignore it +#BuildRequires: python-keyczar +BuildRequires: python3-six +BuildRequires: python3-nose +BuildRequires: python3-pytest +BuildRequires: python3-coverage +BuildRequires: python3-mock +BuildRequires: python3-boto3 +BuildRequires: python3-botocore +BuildRequires: python3-passlib +BuildRequires: python3-jinja2 + +Requires: python3-PyYAML +Requires: python3-paramiko +# accelerate is the only thing that makes keyczar mandatory. Since accelerate +# is deprecated, just ignore it +#Requires: python3-keyczar +Requires: python3-setuptools +Requires: python3-six +Requires: python3-jinja2 +Requires: sshpass +%endif + + +%if 0%{?with_python3} +%description -n ansible-python3 + +Ansible is a radically simple model-driven configuration management, +multi-node deployment, and remote task execution system. Ansible works +over SSH and does not require any software or daemons to be installed +on remote nodes. Extension modules can be written in any language and +are transferred to managed machines automatically. + +This package installs versions of ansible that execute on Python3. +%endif # with_python3 + + %prep %setup -q @@ -135,6 +199,9 @@ are transferred to managed machines automatically. %patch0 -p1 %endif +%patch1 -p1 +%patch2 -p1 + %if 0%{?rhel} == 6 %patch100 -p1 %endif @@ -142,25 +209,55 @@ are transferred to managed machines automatically. # Unittests tar -xJvf %{SOURCE1} +%if 0%{?with_python3} +rm -rf %{py3dir} +cp -a . %{py3dir} +%endif # with_python3 + %build %{__python2} setup.py build +%if 0%{?with_python3} +%py3_build +%endif # with_python3 + %install +%if 0%{?with_python3} +pushd %{py3dir} +%{__python3} setup.py install --root=$RPM_BUILD_ROOT +popd + +for i in $RPM_BUILD_ROOT/%{_bindir}/ansible* ; do + mv $i $i-%{python3_version} +done +%endif # with_python3 + %{__python2} setup.py install --root=$RPM_BUILD_ROOT +for i in $RPM_BUILD_ROOT/%{_bindir}/{ansible,ansible-console,ansible-doc,ansible-galaxy,ansible-playbook,ansible-pull,ansible-vault} ; do + mv $i $i-%{python2_version} + ln -s %{_bindir}/$(basename $i)-%{python2_version} $i +done + mkdir -p $RPM_BUILD_ROOT/etc/ansible/ mkdir -p $RPM_BUILD_ROOT/etc/ansible/roles/ cp examples/hosts $RPM_BUILD_ROOT/etc/ansible/ cp examples/ansible.cfg $RPM_BUILD_ROOT/etc/ansible/ mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1 cp -v docs/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1/ -mkdir -p $RPM_BUILD_ROOT/%{_datadir}/ansible -mkdir -p $RPM_BUILD_ROOT/%{_datadir}/ansible_plugins/{action,callback,connection,lookup,vars,filter}_plugins + %check # RHEL <= 6 doesn't have a new enough python-mock to run the tests %if 0%{?fedora} || 0%{?rhel} >= 7 make tests -%endif + +%if 0%{?with_python3} +pushd %{py3dir} +make tests +%endif # python3 + +%endif # New enough Fedora/RHEL + %clean rm -rf $RPM_BUILD_ROOT @@ -169,11 +266,29 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %{python_sitelib}/ansible* %{_bindir}/ansible* +%exclude %{_bindir}/ansible*%{python3_version} +%config(noreplace) %{_sysconfdir}/ansible/ +%doc README.md PKG-INFO COPYING CHANGELOG.md +%doc %{_mandir}/man1/ansible* + +%files -n ansible-python3 +%defattr(-,root,root,-) +%{python3_sitelib}/ansible* +%{_bindir}/ansible*%{python3_version} %config(noreplace) %{_sysconfdir}/ansible/ %doc README.md PKG-INFO COPYING CHANGELOG.md %doc %{_mandir}/man1/ansible* %changelog +* Wed Mar 8 2017 Toshio Kuratomi - - 2.2.2.0-0.2.rc1 +- Add a python3 ansible package. Note that upstream doesn't intend for the library + to be used by third parties so this is really just for the executables. It's not + strictly required that the executables be built for both python2 and python3 but + we do need to get testing of the python3 version to know if it's stable enough to + go into the next Fedora. We also want the python2 version available in case a user + has to get something done and the python3 version is too buggy. +- Fix Ansible cli scripts to handle appended python version + * Wed Feb 22 2017 Kevin Fenzi - 2.2.2.0-0.1.rc1 - Update to 2.2.2.0 rc1. Fixes bug #1421485