2021-08-05 15:05:24 +00:00
|
|
|
%if 0%{?rhel} && ! 0%{?epel}
|
|
|
|
%bcond_with ansible
|
|
|
|
%else
|
|
|
|
%bcond_without ansible
|
|
|
|
%endif
|
|
|
|
|
2021-08-26 07:32:50 +00:00
|
|
|
%bcond_with collection_artifact
|
|
|
|
|
2021-08-05 15:05:24 +00:00
|
|
|
%global collection_namespace_orig fedora
|
|
|
|
%global collection_name_orig linux_mgmt
|
2022-08-18 13:39:38 +00:00
|
|
|
%global collection_version_orig 1.0.0
|
2021-08-05 15:05:24 +00:00
|
|
|
|
|
|
|
%if 0%{?rhel}
|
|
|
|
%global collection_namespace redhat
|
|
|
|
%global collection_name rhel_mgmt
|
|
|
|
%else
|
|
|
|
%global collection_namespace %{collection_namespace_orig}
|
|
|
|
%global collection_name %{collection_name_orig}
|
|
|
|
%endif
|
|
|
|
|
|
|
|
Name: ansible-collection-%{collection_namespace}-%{collection_name}
|
2021-08-11 08:04:12 +00:00
|
|
|
Url: https://github.com/pcahyna/fedora.linux_mgmt/
|
2021-08-05 15:05:24 +00:00
|
|
|
Summary: Ansible Collection of general system management and utility modules and other plugins
|
2022-08-18 13:39:38 +00:00
|
|
|
Version: 1.1.0
|
|
|
|
Release: 1%{?dist}
|
2021-08-05 15:05:24 +00:00
|
|
|
|
|
|
|
License: GPLv3+
|
|
|
|
|
|
|
|
%global collection_version %{version}
|
2022-08-18 13:39:38 +00:00
|
|
|
%global archivename %{collection_namespace_orig}.%{collection_name_orig}-%{collection_version_orig}
|
2021-08-05 15:05:24 +00:00
|
|
|
%global extractdir %{archivename}
|
|
|
|
|
|
|
|
# Helper macros originally from macros.ansible by Igor Raits <ignatenkobrain>
|
|
|
|
# Not available on RHEL, so we must define those macros locally here without using ansible-galaxy
|
|
|
|
|
|
|
|
# Not used (yet). Could be made to point to AH in RHEL - but what about CentOS Stream?
|
|
|
|
#%%{!?ansible_collection_url:%%define ansible_collection_url() https://galaxy.ansible.com/%%{collection_namespace}/%%{collection_name}}
|
|
|
|
|
2021-08-26 07:32:50 +00:00
|
|
|
%{!?ansible_collection_files:%define ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}}
|
2021-08-05 15:05:24 +00:00
|
|
|
|
|
|
|
%if %{with ansible}
|
|
|
|
BuildRequires: ansible >= 2.9.10
|
|
|
|
Requires: ansible >= 2.9.10
|
|
|
|
%endif
|
|
|
|
|
|
|
|
%if %{undefined ansible_collection_build}
|
|
|
|
%if %{without ansible}
|
|
|
|
# We don't have ansible-galaxy.
|
|
|
|
%define ansible_collection_build() tar -cf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz .
|
|
|
|
%else
|
|
|
|
%define ansible_collection_build() ansible-galaxy collection build
|
|
|
|
%endif
|
|
|
|
%endif
|
|
|
|
|
|
|
|
%if %{undefined ansible_collection_install}
|
|
|
|
%if %{without ansible}
|
|
|
|
# Simply copy everything instead of galaxy-installing the built artifact.
|
|
|
|
%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)
|
|
|
|
%else
|
|
|
|
%define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz
|
|
|
|
%endif
|
|
|
|
%endif
|
|
|
|
|
2022-08-18 13:39:38 +00:00
|
|
|
Source: https://github.com/pcahyna/fedora.linux_mgmt/archive/%{collection_version_orig}/%{archivename}.tar.gz
|
2021-08-05 15:05:24 +00:00
|
|
|
|
2022-08-18 13:32:03 +00:00
|
|
|
# Collection tarballs from Galaxy
|
|
|
|
# Not used on Fedora.
|
|
|
|
Source901: https://galaxy.ansible.com/download/community-general-5.4.0.tar.gz
|
2022-08-18 14:04:18 +00:00
|
|
|
|
|
|
|
Patch1: redfish-metadata.patch
|
2022-08-18 13:32:03 +00:00
|
|
|
|
2021-08-05 15:05:24 +00:00
|
|
|
BuildArch: noarch
|
|
|
|
|
|
|
|
BuildRequires: python3
|
|
|
|
BuildRequires: python3dist(ruamel.yaml)
|
|
|
|
|
|
|
|
# utility for build
|
|
|
|
# originally from: https://github.com/linux-system-roles/auto-maintenance
|
|
|
|
# rev. 20d31bf5d8e7eb67ce48af39e36c9f79d87490e3
|
|
|
|
# MIT license: https://github.com/linux-system-roles/auto-maintenance/blob/master/LICENSE
|
|
|
|
Source1: galaxy_transform.py
|
|
|
|
|
|
|
|
%if %{undefined __ansible_provides}
|
|
|
|
Provides: ansible-collection(%{collection_namespace}.%{collection_name}) = %{collection_version}
|
|
|
|
%endif
|
|
|
|
|
|
|
|
%description
|
|
|
|
%{summary}.
|
|
|
|
Targeted at GNU/Linux systems.
|
|
|
|
|
2021-08-26 07:32:50 +00:00
|
|
|
%if %{with collection_artifact}
|
|
|
|
%package collection-artifact
|
|
|
|
Summary: Collection artifact to import to Automation Hub / Ansible Galaxy
|
|
|
|
|
|
|
|
%description collection-artifact
|
|
|
|
Collection artifact for %{name}. This package contains %{collection_namespace}-%{collection_name}-%{version}.tar.gz
|
|
|
|
%endif
|
|
|
|
|
2021-08-05 15:05:24 +00:00
|
|
|
%prep
|
2022-08-18 13:32:03 +00:00
|
|
|
%if 0%{?rhel}
|
|
|
|
%setup -T -a 901 -c -n .external/community/general
|
|
|
|
%endif
|
|
|
|
%setup -n %{extractdir}
|
|
|
|
|
2022-08-18 14:04:18 +00:00
|
|
|
%if 0%{?rhel}
|
|
|
|
%patch1 -p1
|
|
|
|
%endif
|
|
|
|
|
2022-08-18 13:32:03 +00:00
|
|
|
%if 0%{?rhel}
|
|
|
|
modules=( remote_management/redfish/redfish_{command,config,info}.py )
|
|
|
|
module_utils=( redfish_utils.py )
|
|
|
|
|
|
|
|
mkdir -p plugins/modules
|
|
|
|
mkdir -p plugins/module_utils
|
|
|
|
|
|
|
|
for dir in %{_builddir}/.external/*/*; do
|
|
|
|
name=$(basename "$dir")
|
|
|
|
ns=$(basename $(dirname "$dir"))
|
|
|
|
for module in "${modules[@]}"; do
|
2022-08-18 14:40:45 +00:00
|
|
|
dest_module=plugins/modules/$(basename $module)
|
|
|
|
cp -pL $dir/plugins/modules/$module $dest_module
|
|
|
|
# Replacing original collection name by downstream (vendored) name
|
|
|
|
if [ "${ns}" != "%{collection_namespace}" ] || [ "${name}" != "%{collection_name}" ] ; then
|
|
|
|
sed "s/${ns}[.]${name}/%{collection_namespace}.%{collection_name}/g" -i $dest_module
|
|
|
|
fi
|
2022-08-18 13:32:03 +00:00
|
|
|
done
|
|
|
|
for module_util in "${module_utils[@]}"; do
|
2022-08-18 14:40:45 +00:00
|
|
|
dest_module_util=plugins/module_utils/$module_util
|
|
|
|
cp -pL $dir/plugins/module_utils/$module_util $dest_module_util
|
|
|
|
# Replacing original collection name by downstream (vendored) name
|
|
|
|
if [ "${ns}" != "%{collection_namespace}" ] || [ "${name}" != "%{collection_name}" ] ; then
|
|
|
|
sed "s/${ns}[.]${name}/%{collection_namespace}.%{collection_name}/g" -i $dest_module_util
|
|
|
|
fi
|
2022-08-18 13:32:03 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
%endif
|
2021-08-05 15:05:24 +00:00
|
|
|
|
|
|
|
# Replacing original (Galaxy) collection name by downstream (Automation Hub) name
|
|
|
|
%if "%{collection_namespace_orig}" != "%{collection_namespace}" || "%{collection_name_orig}" != "%{collection_name}"
|
|
|
|
find -type f -exec \
|
|
|
|
sed "s/%{collection_namespace_orig}[.]%{collection_name_orig}/%{collection_namespace}.%{collection_name}/g" -i {} \;
|
|
|
|
%endif
|
|
|
|
|
|
|
|
# borrowed from from ansible-collection-ansible-netcommon
|
|
|
|
find -type f ! -executable -type f -name '*.py' -print -exec sed -i -e '1{\@^#!.*@d}' '{}' +
|
|
|
|
|
|
|
|
%build
|
2022-08-18 13:32:03 +00:00
|
|
|
mkdir -p .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
|
|
|
|
cp -a * .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
|
2022-08-18 14:04:18 +00:00
|
|
|
%{SOURCE1} %{collection_namespace} %{collection_name} %{collection_version} > .collections/ansible_collections/%{collection_namespace}/%{collection_name}/galaxy.yml
|
2022-08-18 13:32:03 +00:00
|
|
|
|
|
|
|
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
|
2021-08-05 15:05:24 +00:00
|
|
|
%ansible_collection_build
|
2022-08-18 13:32:03 +00:00
|
|
|
popd
|
2021-08-05 15:05:24 +00:00
|
|
|
|
|
|
|
%install
|
2022-08-18 13:32:03 +00:00
|
|
|
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
|
2021-08-05 15:05:24 +00:00
|
|
|
%ansible_collection_install
|
2022-08-18 13:32:03 +00:00
|
|
|
popd
|
2021-08-05 15:05:24 +00:00
|
|
|
|
2021-08-26 07:32:50 +00:00
|
|
|
%if %{with collection_artifact}
|
|
|
|
# Copy collection artifact to /usr/share/ansible/collections/ for collection-artifact
|
|
|
|
if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then
|
|
|
|
mv %{collection_namespace}-%{collection_name}-%{version}.tar.gz \
|
|
|
|
$RPM_BUILD_ROOT%{_datadir}/ansible/collections/
|
|
|
|
fi
|
|
|
|
%endif
|
|
|
|
|
2021-08-05 15:05:24 +00:00
|
|
|
%files
|
|
|
|
%dir %{_datadir}/ansible
|
|
|
|
%license COPYING
|
|
|
|
%{ansible_collection_files}
|
|
|
|
|
2021-08-26 07:32:50 +00:00
|
|
|
%if %{with collection_artifact}
|
|
|
|
%files collection-artifact
|
|
|
|
%{_datadir}/ansible/collections/%{collection_namespace}-%{collection_name}-%{version}.tar.gz
|
|
|
|
%endif
|
|
|
|
|
2021-08-05 15:05:24 +00:00
|
|
|
%changelog
|
2021-08-26 07:32:50 +00:00
|
|
|
* Thu Aug 26 2021 Pavel Cahyna <pcahyna@redhat.com> - 1.0.0-2
|
|
|
|
- Create collection artifact subpackage, disabled by default
|
|
|
|
Taken from rhel-system-roles.
|
|
|
|
|
2021-08-05 15:05:24 +00:00
|
|
|
* Thu Aug 05 2021 Pavel Cahyna <pcahyna@redhat.com> - 1.0.0-1
|
|
|
|
- Initial version
|