ansible/ansible.spec

289 lines
8.6 KiB
RPMSpec

#
# spec file for package ansible
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright 2013 by Lars Vogdt
# Copyright 2014 by Boris Manojlovic
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%if 0%{?suse_version} && 0%{?suse_version} >= 1500
%bcond_without python3
%else
%bcond_with python3
%endif
%if %{with python3}
%define __python %{__python3}
%define python python3
%else
%define python python
%endif
# Disable shebang munging for specific paths. These files are data files.
# ansible-test munges the shebangs itself.
%global __brp_mangle_shebangs_exclude_from /usr/lib/python[0-9]+\.[0-9]+/site-packages/ansible_test/_data/.*
%if 0%{?suse_version} && 0%{?suse_version} <= 1110 || 0%{?rhel} == 5
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch: noarch
%endif
Name: ansible
Version: 2.9.2
Release: 0
Summary: SSH-based configuration management, deployment, and task execution system
License: GPL-3.0-or-later
Group: Development/Languages/Python
Url: https://ansible.com/
Source: https://releases.ansible.com/ansible/ansible-%{version}.tar.gz
Source1: https://releases.ansible.com/ansible/ansible-%{version}.tar.gz.sha
Source99: ansible-rpmlintrc
# SuSE/openSuSE
%if 0%{?suse_version}
%if %{with python3}
BuildRequires: python3-devel >= 3.5
%else
BuildRequires: python-devel
%endif
BuildRequires: %{python}-setuptools
Recommends: %{python}-dnspython
Recommends: %{python}-dopy
Recommends: %{python}-pywinrm
Recommends: sshpass
Recommends: %{python}-httplib2
Recommends: %{python}-keyczar
Recommends: %{python}-six
Requires: %{python}-setuptools
%if 0%{?suse_version} >= 01130
BuildRequires: %{python}-Jinja2
BuildRequires: %{python}-PyYAML
BuildRequires: %{python}-paramiko
BuildRequires: %{python}-pycrypto >= 2.6
BuildRequires: fdupes
Requires: %{python}-Jinja2
Requires: %{python}-PyYAML
Requires: %{python}-paramiko
Requires: %{python}-passlib
Requires: %{python}-pycrypto >= 2.6
%else
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
%endif
# RHEL <=5
%if 0%{?rhel} && 0%{?rhel} <= 5
BuildRequires: python26-devel
BuildRequires: python26-setuptools
Requires: python26-PyYAML
Requires: python26-httplib2
Requires: python26-jinja2
Requires: python26-keyczar
Requires: python26-paramiko
Requires: python26-setuptools
Requires: python26-six
Requires: sshpass
%endif
# RHEL > 5
%if 0%{?rhel} && 0%{?rhel} >= 5
BuildRequires: python-setuptools
BuildRequires: python2-devel
Requires: PyYAML
Requires: python-jinja2
Requires: python-paramiko
Requires: python-setuptools
Requires: python-six
Requires: sshpass
%endif
# RHEL == 6
%if 0%{?rhel} == 6
Requires: python-crypto
%endif
# RHEL >=7
%if 0%{?rhel} >= 7
Requires: python2-cryptography
BuildRequires: perl(Exporter)
%endif
%if 0%{?fedora} >= 18
BuildRequires: python-devel
BuildRequires: python-setuptools
Requires: PyYAML
Requires: python-httplib2
Requires: python-jinja2
Requires: python-keyczar
Requires: python-paramiko
Requires: python-setuptools
Requires: python-six
Requires: sshpass
%define __python %{__python2}
%endif
%description
Ansible is an IT automation system. It handles
configuration-management, application deployment, cloud provisioning, ad-hoc
task-execution, and multinode orchestration - including trivializing things
like zero downtime rolling updates with load balancers.
%package -n ansible-test
Summary: Tool for testing ansible plugin and module code
Requires: %{name} = %{version}
%if 0%{?rhel} >= 8
# Will use the python3 stdlib venv
#Requires: python3-virtualenv
#BuildRequires: python3-virtualenv
%else
%if 0%{?rhel} >= 7
Requires: python-virtualenv
BuildRequires: python-virtualenv
%endif # Requires for RHEL 7
%endif # Requires for RHEL 8
# SUSE/openSUSE
%if 0%{?suse_version}
Requires: python-virtualenv
BuildRequires: python-virtualenv
%endif
%description -n ansible-test
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 the ansible-test command for testing modules and plugins
developed for ansible.
%prep
%setup -q -n ansible-%{version}
find . -name .git_keep -o -name .travis.yml -delete
find contrib/ -type f -exec chmod 644 {} +
# Replace all #!/usr/bin/env lines to use #!/usr/bin/$1 directly.
find ./ -type f -exec \
sed -i '1s|^#!/usr/bin/env |#!/usr/bin/|' {} \;
%build
%{__python} setup.py build
%install
%{__python} setup.py install --prefix=%{_prefix} --root=%{buildroot}
mkdir -p %{buildroot}%{_sysconfdir}/ansible/
cp examples/hosts %{buildroot}%{_sysconfdir}/ansible/
cp examples/ansible.cfg %{buildroot}%{_sysconfdir}/ansible/
mkdir -p %{buildroot}/%{_mandir}/man1/
cp -v docs/man/man1/*.1 %{buildroot}/%{_mandir}/man1/
mkdir -p %{buildroot}/%{_datadir}/ansible
%if 0%{?suse_version} >= 01130
%fdupes %{buildroot}/%{python_sitelib}/ansible/
%endif
# Create system directories that Ansible defines as default locations in
# ansible/config/base.yml
DATADIR_LOCATIONS='%{_datadir}/ansible/collections
%{_datadir}/ansible/plugins/doc_fragments
%{_datadir}/ansible/plugins/action
%{_datadir}/ansible/plugins/become
%{_datadir}/ansible/plugins/cache
%{_datadir}/ansible/plugins/callback
%{_datadir}/ansible/plugins/cliconf
%{_datadir}/ansible/plugins/connection
%{_datadir}/ansible/plugins/filter
%{_datadir}/ansible/plugins/httpapi
%{_datadir}/ansible/plugins/inventory
%{_datadir}/ansible/plugins/lookup
%{_datadir}/ansible/plugins/modules
%{_datadir}/ansible/plugins/module_utils
%{_datadir}/ansible/plugins/netconf
%{_datadir}/ansible/roles
%{_datadir}/ansible/plugins/strategy
%{_datadir}/ansible/plugins/terminal
%{_datadir}/ansible/plugins/test
%{_datadir}/ansible/plugins/vars'
UPSTREAM_DATADIR_LOCATIONS=$(grep -ri default lib/ansible/config/base.yml| tr ':' '\n' | grep '/usr/share/ansible')
if [ "$SYSTEM_LOCATIONS" != "$UPSTREAM_SYSTEM_LOCATIONS" ] ; then
echo "The upstream Ansible datadir locations have changed. Spec file needs to be updated"
exit 1
fi
mkdir -p %{buildroot}%{_datadir}/ansible/plugins/
for location in $DATADIR_LOCATIONS ; do
mkdir %{buildroot}"$location"
done
mkdir -p %{buildroot}%{_sysconfdir}/ansible/
mkdir -p %{buildroot}%{_sysconfdir}/ansible/roles/
cp examples/hosts %{buildroot}%{_sysconfdir}/ansible/
cp examples/ansible.cfg %{buildroot}%{_sysconfdir}/ansible/
mkdir -p %{buildroot}/%{_mandir}/man1/
cp -v docs/man/man1/*.1 %{buildroot}/%{_mandir}/man1/
cp -pr docs/docsite/rst .
%files
%defattr(-,root,root,-)
%if 0%{?suse_version} >= 1200
%license COPYING
%else
%doc COPYING
%endif
%doc *.rst contrib examples changelogs
%{_bindir}/ansible
%{_bindir}/ansible-config
%{_bindir}/ansible-connection
%{_bindir}/ansible-console
%{_bindir}/ansible-doc
%{_bindir}/ansible-galaxy
%{_bindir}/ansible-inventory
%{_bindir}/ansible-playbook
%{_bindir}/ansible-pull
%{_bindir}/ansible-vault
%if %{with python3}
%{python3_sitelib}/*
%exclude %{python3_sitelib}/ansible_test
%else
%{python_sitelib}/*
%exclude %{python_sitelib}/ansible_test
%endif
%{_mandir}/man1/ansible.1%{?ext_man}*
%{_mandir}/man1/ansible-config.1%{?ext_man}*
%{_mandir}/man1/ansible-console.1%{?ext_man}*
%{_mandir}/man1/ansible-doc.1%{?ext_man}*
%{_mandir}/man1/ansible-galaxy.1%{?ext_man}*
%{_mandir}/man1/ansible-inventory.1%{?ext_man}*
%{_mandir}/man1/ansible-playbook.1%{?ext_man}*
%{_mandir}/man1/ansible-pull.1%{?ext_man}*
%{_mandir}/man1/ansible-vault.1%{?ext_man}*
%dir %{_sysconfdir}/ansible
%config(noreplace) %{_sysconfdir}/ansible/ansible.cfg
%config(noreplace) %{_sysconfdir}/ansible/hosts
%{_datadir}/ansible/
%files -n ansible-test
%{_bindir}/ansible-test
%if %{with python3}
%{python3_sitelib}/ansible_test
%else
%{python2_sitelib}/ansible_test
%endif
%changelog