%global dlrn_nvr ansible-2.8.0.dev0-0.1.20180913211731.5a3a865 %global dlrn 1 %define upstream_version 2.8.0.dev0 %if !0%{?dlrn} %global upstream_version %version %endif # RHEL 6 didn't have a __python2 macro. # Amazon Linux 2015.9 is based on RHEL6, with /usr/bin/python2 -> python2.6, while # /usr/bin/python -> python2.7. Explicitly use python2.6. %if 0%{?rhel} == 6 || 0%{?rhel} == 5 %global __python2 /usr/bin/python2.6 %endif # RHEL 6 and 7 do not have BuildRequires to build docs # Fedora 27 and older have too old a jinja2 to build docs %if (0%{?fedora} >= 27 || 0%{?rhel} >= 8) && !0%{?dlrn} %global with_docs 1 %else %global with_docs 0 %endif # Build Fedora and RHEL larger than 7 with python3 %if 0%{?fedora} || 0%{?rhel} >= 8 %global with_python3 1 %else %global with_python3 0 %endif # Fedora 29+ and RHEL larger than 7 no python2, python3 default %if 0%{?fedora} >= 29 || 0%{?rhel} >= 8 %global with_python2 0 %else %global with_python2 1 %endif Name: ansible Summary: SSH-based configuration management, deployment, and task execution system Version: 2.8.0 Release: 0.1.20180913211731.5a3a865%{?dist} Group: Development/Libraries License: GPLv3+ Source0: ansible-2.8.0.dev0-0.1.20180913211731.5a3a865.tar.gz # 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 # upstream as they don't know what their customers are running. Patch100: ansible-newer-jinja.patch # temprary patches for dlrn packaging (devel branch) #Patch1001: ansible-mock-ncclient-import.patch Url: http://ansible.com BuildArch: noarch # This is needed to update the old ansible-fireball package that is no # longer needed. Note that you should also remove ansible-node-fireball manually # Where you still have it installed. # Provides: ansible-fireball = %{version}-%{release} Obsoletes: ansible-fireball < 1.2.4 %if 0%{?with_python2} %if 0%{?rhel} && 0%{?rhel} <= 5 # On RHEL6 use the python26 stack BuildRequires: python26-devel Requires: python26-PyYAML Requires: python26-paramiko Requires: python26-jinja2 %endif # for the netconf module Requires: python-ncclient BuildRequires: python BuildRequires: python2-devel BuildRequires: python-setuptools # For building docs/tests BuildRequires: git-core %if %with_docs BuildRequires: python-sphinx BuildRequires: asciidoc %endif # For tests # We don't run tests on epel6, so don't bother pulling these in there. %if (0%{?fedora} || 0%{?rhel} > 6) BuildRequires: which BuildRequires: PyYAML BuildRequires: python-boto BuildRequires: python-netaddr BuildRequires: python-crypto BuildRequires: python-paramiko BuildRequires: python-keyczar BuildRequires: python-six BuildRequires: python-nose BuildRequires: python-coverage BuildRequires: python-requests BuildRequires: python-mock BuildRequires: python-boto3 BuildRequires: python-botocore BuildRequires: python-passlib # Fedora only docs building BuildRequires: python2-sphinx-theme-alabaster # rhel7 does not have python-pytest but has pytest %if 0%{?rhel} == 7 BuildRequires: pytest %else BuildRequires: python-pytest BuildRequires: python-attrs BuildRequires: python-pluggy BuildRequires: python-pytest-xdist BuildRequires: python-pytest-mock BuildRequires: python-packaging BuildRequires: python2-pexpect BuildRequires: python2-winrm %endif %endif %if (0%{?rhel} && 0%{?rhel} <= 6) # Ansible will work with the jinja2 shipped with RHEL6 but users can gain # additional jinja features by using the newer version Requires: python-jinja2-26 BuildRequires: python-jinja2-26 # Distros with python < 2.7.0 BuildRequires: python-unittest2 %else Requires: python-jinja2 BuildRequires: python-jinja2 %endif Requires: PyYAML Requires: python-crypto Requires: python-paramiko Requires: python-keyczar Requires: python-httplib2 Requires: python-setuptools Requires: python-six Requires: sshpass %if (0%{?fedora} || 0%{?rhel} > 6) # needed for json_query filter # but avoid on rhel6 due to amazon linux conflicts Requires: python2-jmespath %endif %if 0%{?rhel} == 6 # RHEL 6 needs a newer version of the pycrypto library for the ansible-vault # command. Note: If other pieces of ansible also grow to need pycrypto you may # need to add: Requires: python-crypto or patch the other pieces of ansible to # make use of this forward compat package (see the patch for ansible-vault # above to see what needs to be done.) Requires: python-crypto2.6 # The python-2.6 stdlib json module has a bug that affects the ansible # to_nice_json filter Requires: python-simplejson # For testing BuildRequires: python-crypto2.6 BuildRequires: python-simplejson %endif %description 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. %endif # python2 %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. # However, for future ELs and Fedora 29+, we want Python 3 only %if 0%{?with_python2} %package -n ansible-python3 Summary: SSH-based configuration management, deployment, and task execution system %else Provides: ansible-python3 = %{version}-%{release} Obsoletes: ansible-python3 < %{version}-%{release} %endif BuildRequires: python3-devel BuildRequires: python3-setuptools # For tests BuildRequires: python3-PyYAML BuildRequires: python3-paramiko BuildRequires: python3-crypto BuildRequires: python3-packaging BuildRequires: python3-pexpect BuildRequires: python3-winrm # For Docs/tests BuildRequires: git-core %if %with_docs BuildRequires: python3-sphinx BuildRequires: python3-sphinx-theme-alabaster BuildRequires: asciidoc %endif # 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-pluggy BuildRequires: python3-attrs BuildRequires: python3-pytest BuildRequires: python3-pytest-xdist BuildRequires: python3-pytest-mock BuildRequires: python3-requests BuildRequires: python3-coverage BuildRequires: python3-mock BuildRequires: python3-boto3 BuildRequires: python3-botocore BuildRequires: python3-passlib BuildRequires: python3-jinja2 BuildRequires: python3-requests Requires: python3-PyYAML Requires: python3-paramiko Requires: python3-crypto # 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 # needed for json_query filter Requires: python3-jmespath %if 0%{?with_python2} %description -n ansible-python3 %else %description %endif 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 # python3 %package -n ansible-doc Summary: Documentation for Ansible %description -n ansible-doc 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 extensive documentation for ansible %prep %setup -q -n %name-%upstream_version echo 0%{?fedora} 0%{?rhel} 0%{?with_python3} %if 0%{?rhel} == 6 %patch100 -p1 %endif # temporary patches for DLRN #%patch1001 -p1 %if 0%{?with_python3} rm -rf %{py3dir} cp -a . %{py3dir} %endif # with_python3 %build %if 0%{?with_python2} %{__python2} setup.py build %endif %if 0%{?with_python3} pushd %{py3dir} %py3_build %if %with_docs # Fedora 26 does not have pathfix, so build docs with python2 %if (0%{?fedora} == 26) make PYTHON=/usr/bin/python2 webdocs %else pathfix.py -i %{__python3} -p docs/bin test/runner make PYTHON=/usr/bin/python3 SPHINXBUILD=sphinx-build-3 webdocs %endif %endif popd %endif # with_python3 %if ! %with_docs && ( 0%{?fedora} || 0%{?rhel} >= 7) %if ! 0%{?with_python2} pathfix.py -i %{__python3} -p docs/bin %endif # Generate the rst docs from the source if they weren't generated earlier as # part of the html docs build make -Cdocs/docsite PYTHON=/usr/bin/python3 config cli keywords modules plugins testing %endif %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 if [ $(basename $i) = "ansible-connection" -o $(basename $i) = "ansible" ] ; then %if 0%{?with_python2} mv $i $i-%{python3_version} %else # for backwards compatibility ln -s $(basename $i) $i-%{python3_version} %endif ln -s %{_bindir}/$(basename $i)-%{python3_version} $i-3 %if 0%{?with_python2} else # The ansible commands are themselves symlinks to /usr/bin/ansible. # Need to change them to point to the python3 version ln -s %{_bindir}/ansible-3 $i-%{python3_version} ln -s %{_bindir}/$(basename $i)-%{python3_version} $i-3 %endif fi done %endif # with_python3 %if 0%{?with_python2} %{__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 ln -s %{_bindir}/$(basename $i)-%{python2_version} $i-2 done %endif 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/ cp -pr docs/docsite/rst . %if %with_docs mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1 cp -v docs/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1/ pushd %{py3dir} cp -pr docs/docsite/_build/html %{_builddir}/%{name}-%{version}/html popd %endif %check # RHEL <= 6 doesn't have a new enough python-mock to run the tests # Currently RHEL <= 7 doesn't have pytest-xdist or a new enough pytest # Fedora 25 doesn't have a new enough pytest %if 0%{?with_python2} && 0%{?fedora} >= 26 ln -s /usr/bin/pytest bin/pytest make PYTHON=/usr/bin/python2 tests %endif # New enough Fedora with python2 %if 0%{?with_python3} pushd %{py3dir} ln -s /usr/bin/pytest-3 bin/pytest # Fedora 26 does not have pathfix ¯\_(ツ)_/¯ %if (0%{?fedora} > 26) pathfix.py -i %{__python3} -p test/runner %endif make PYTHON=/usr/bin/python3 tests-py3 popd %endif # python3 %files %defattr(-,root,root) %if 0%{?with_python2} %{python_sitelib}/ansible* %endif %{_bindir}/ansible* %if 0%{?with_python3} && 0%{?with_python2} %exclude %{_bindir}/ansible*-3* %endif # python3 and 2 %config(noreplace) %{_sysconfdir}/ansible/ %doc README.rst PKG-INFO COPYING %if ! 0%{?dlrn} %doc changelogs/CHANGELOG-v2.7.rst %endif %if %with_docs %doc %{_mandir}/man1/ansible* %endif %if 0%{?with_python3} %if 0%{?with_python2} %files -n ansible-python3 %defattr(-,root,root,-) %config(noreplace) %{_sysconfdir}/ansible/ %doc README.rst PKG-INFO COPYING %if ! 0%{?dlrn} %doc changelogs/CHANGELOG-v2.7.rst %endif %if %with_docs %doc %{_mandir}/man1/ansible* %endif %{_bindir}/ansible*-3* %endif # python2 %{python3_sitelib}/ansible* %endif # python3 %files -n ansible-doc %doc rst %if %with_docs %doc html %endif %changelog