|
|
73f2b9 |
%if 0%{?rhel} && ! 0%{?epel}
|
|
|
73f2b9 |
%bcond_with ansible
|
|
|
73f2b9 |
%else
|
|
|
73f2b9 |
%bcond_without ansible
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%bcond_with collection_artifact
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%global collection_namespace_orig fedora
|
|
|
73f2b9 |
%global collection_name_orig linux_mgmt
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%if 0%{?rhel}
|
|
|
73f2b9 |
%global collection_namespace redhat
|
|
|
73f2b9 |
%global collection_name rhel_mgmt
|
|
|
73f2b9 |
%else
|
|
|
73f2b9 |
%global collection_namespace %{collection_namespace_orig}
|
|
|
73f2b9 |
%global collection_name %{collection_name_orig}
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
Name: ansible-collection-%{collection_namespace}-%{collection_name}
|
|
|
73f2b9 |
Url: https://github.com/pcahyna/fedora.linux_mgmt/
|
|
|
73f2b9 |
Summary: Ansible Collection of general system management and utility modules and other plugins
|
|
|
73f2b9 |
Version: 1.0.0
|
|
|
73f2b9 |
Release: 2%{?dist}
|
|
|
73f2b9 |
|
|
|
73f2b9 |
License: GPLv3+
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%global collection_version %{version}
|
|
|
73f2b9 |
%global archivename %{collection_namespace_orig}.%{collection_name_orig}-%{version}
|
|
|
73f2b9 |
%global extractdir %{archivename}
|
|
|
73f2b9 |
|
|
|
73f2b9 |
# Helper macros originally from macros.ansible by Igor Raits <ignatenkobrain>
|
|
|
73f2b9 |
# Not available on RHEL, so we must define those macros locally here without using ansible-galaxy
|
|
|
73f2b9 |
|
|
|
73f2b9 |
# Not used (yet). Could be made to point to AH in RHEL - but what about CentOS Stream?
|
|
|
73f2b9 |
#%%{!?ansible_collection_url:%%define ansible_collection_url() https://galaxy.ansible.com/%%{collection_namespace}/%%{collection_name}}
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%{!?ansible_collection_files:%define ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}}
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%if %{with ansible}
|
|
|
73f2b9 |
BuildRequires: ansible >= 2.9.10
|
|
|
73f2b9 |
Requires: ansible >= 2.9.10
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%if %{undefined ansible_collection_build}
|
|
|
73f2b9 |
%if %{without ansible}
|
|
|
73f2b9 |
# We don't have ansible-galaxy.
|
|
|
73f2b9 |
%define ansible_collection_build() tar -cf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz .
|
|
|
73f2b9 |
%else
|
|
|
73f2b9 |
%define ansible_collection_build() ansible-galaxy collection build
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%if %{undefined ansible_collection_install}
|
|
|
73f2b9 |
%if %{without ansible}
|
|
|
73f2b9 |
# Simply copy everything instead of galaxy-installing the built artifact.
|
|
|
73f2b9 |
%define ansible_collection_install() mkdir -p %{buildroot}%{ansible_collection_files}/%{collection_name}; (cd %{buildroot}%{ansible_collection_files}/%{collection_name}; tar -xf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz)
|
|
|
73f2b9 |
%else
|
|
|
73f2b9 |
%define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
Source: https://github.com/pcahyna/fedora.linux_mgmt/archive/%{version}/%{archivename}.tar.gz
|
|
|
73f2b9 |
|
|
|
73f2b9 |
BuildArch: noarch
|
|
|
73f2b9 |
|
|
|
73f2b9 |
BuildRequires: python3
|
|
|
73f2b9 |
BuildRequires: python3dist(ruamel.yaml)
|
|
|
73f2b9 |
|
|
|
73f2b9 |
# utility for build
|
|
|
73f2b9 |
# originally from: https://github.com/linux-system-roles/auto-maintenance
|
|
|
73f2b9 |
# rev. 20d31bf5d8e7eb67ce48af39e36c9f79d87490e3
|
|
|
73f2b9 |
# MIT license: https://github.com/linux-system-roles/auto-maintenance/blob/master/LICENSE
|
|
|
73f2b9 |
Source1: galaxy_transform.py
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%if %{undefined __ansible_provides}
|
|
|
73f2b9 |
Provides: ansible-collection(%{collection_namespace}.%{collection_name}) = %{collection_version}
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%description
|
|
|
73f2b9 |
%{summary}.
|
|
|
73f2b9 |
Targeted at GNU/Linux systems.
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%if %{with collection_artifact}
|
|
|
73f2b9 |
%package collection-artifact
|
|
|
73f2b9 |
Summary: Collection artifact to import to Automation Hub / Ansible Galaxy
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%description collection-artifact
|
|
|
73f2b9 |
Collection artifact for %{name}. This package contains %{collection_namespace}-%{collection_name}-%{version}.tar.gz
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%prep
|
|
|
73f2b9 |
%autosetup -n %{extractdir}
|
|
|
73f2b9 |
|
|
|
73f2b9 |
# Replacing original (Galaxy) collection name by downstream (Automation Hub) name
|
|
|
73f2b9 |
%if "%{collection_namespace_orig}" != "%{collection_namespace}" || "%{collection_name_orig}" != "%{collection_name}"
|
|
|
73f2b9 |
find -type f -exec \
|
|
|
73f2b9 |
sed "s/%{collection_namespace_orig}[.]%{collection_name_orig}/%{collection_namespace}.%{collection_name}/g" -i {} \;
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
# borrowed from from ansible-collection-ansible-netcommon
|
|
|
73f2b9 |
find -type f ! -executable -type f -name '*.py' -print -exec sed -i -e '1{\@^#!.*@d}' '{}' +
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%{SOURCE1} %{collection_namespace} %{collection_name} %{collection_version} > galaxy.yml.new
|
|
|
73f2b9 |
mv galaxy.yml.new galaxy.yml
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%build
|
|
|
73f2b9 |
%ansible_collection_build
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%install
|
|
|
73f2b9 |
%ansible_collection_install
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%if %{with collection_artifact}
|
|
|
73f2b9 |
# Copy collection artifact to /usr/share/ansible/collections/ for collection-artifact
|
|
|
73f2b9 |
if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then
|
|
|
73f2b9 |
mv %{collection_namespace}-%{collection_name}-%{version}.tar.gz \
|
|
|
73f2b9 |
$RPM_BUILD_ROOT%{_datadir}/ansible/collections/
|
|
|
73f2b9 |
fi
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%files
|
|
|
73f2b9 |
%dir %{_datadir}/ansible
|
|
|
73f2b9 |
%license COPYING
|
|
|
73f2b9 |
%{ansible_collection_files}
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%if %{with collection_artifact}
|
|
|
73f2b9 |
%files collection-artifact
|
|
|
73f2b9 |
%{_datadir}/ansible/collections/%{collection_namespace}-%{collection_name}-%{version}.tar.gz
|
|
|
73f2b9 |
%endif
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%changelog
|
|
|
73f2b9 |
* Thu Aug 26 2021 Pavel Cahyna <pcahyna@redhat.com> - 1.0.0-2
|
|
|
73f2b9 |
- Create collection artifact subpackage, disabled by default
|
|
|
73f2b9 |
Taken from rhel-system-roles.
|
|
|
73f2b9 |
|
|
|
73f2b9 |
* Thu Aug 05 2021 Pavel Cahyna <pcahyna@redhat.com> - 1.0.0-1
|
|
|
73f2b9 |
- Initial version
|