|
|
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
|
|
|
5f1a24 |
%global collection_version_orig 1.0.0
|
|
|
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
|
|
|
5f1a24 |
Version: 1.1.0
|
|
|
73f2b9 |
Release: 2%{?dist}
|
|
|
73f2b9 |
|
|
|
73f2b9 |
License: GPLv3+
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%global collection_version %{version}
|
|
|
5f1a24 |
%global archivename %{collection_namespace_orig}.%{collection_name_orig}-%{collection_version_orig}
|
|
|
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 |
|
|
|
5f1a24 |
Source: https://github.com/pcahyna/fedora.linux_mgmt/archive/%{collection_version_orig}/%{archivename}.tar.gz
|
|
|
5f1a24 |
|
|
|
5f1a24 |
# Collection tarballs from Galaxy
|
|
|
5f1a24 |
# Not used on Fedora.
|
|
|
5f1a24 |
Source901: https://galaxy.ansible.com/download/community-general-5.4.0.tar.gz
|
|
|
5f1a24 |
|
|
|
5f1a24 |
Patch1: redfish-metadata.patch
|
|
|
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
|
|
|
5f1a24 |
%if 0%{?rhel}
|
|
|
5f1a24 |
%setup -T -a 901 -c -n .external/community/general
|
|
|
5f1a24 |
%endif
|
|
|
5f1a24 |
%setup -n %{extractdir}
|
|
|
5f1a24 |
|
|
|
5f1a24 |
%if 0%{?rhel}
|
|
|
5f1a24 |
%patch1 -p1
|
|
|
5f1a24 |
%endif
|
|
|
5f1a24 |
|
|
|
5f1a24 |
%if 0%{?rhel}
|
|
|
5f1a24 |
modules=( remote_management/redfish/redfish_{command,config,info}.py )
|
|
|
5f1a24 |
module_utils=( redfish_utils.py )
|
|
|
5f1a24 |
|
|
|
5f1a24 |
mkdir -p plugins/modules
|
|
|
5f1a24 |
mkdir -p plugins/module_utils
|
|
|
5f1a24 |
|
|
|
5f1a24 |
for dir in %{_builddir}/.external/*/*; do
|
|
|
5f1a24 |
name=$(basename "$dir")
|
|
|
5f1a24 |
ns=$(basename $(dirname "$dir"))
|
|
|
5f1a24 |
for module in "${modules[@]}"; do
|
|
|
5f1a24 |
dest_module=plugins/modules/$(basename $module)
|
|
|
5f1a24 |
cp -pL $dir/plugins/modules/$module $dest_module
|
|
|
5f1a24 |
# Replacing original collection name by downstream (vendored) name
|
|
|
5f1a24 |
if [ "${ns}" != "%{collection_namespace}" ] || [ "${name}" != "%{collection_name}" ] ; then
|
|
|
5f1a24 |
sed "s/${ns}[.]${name}/%{collection_namespace}.%{collection_name}/g" -i $dest_module
|
|
|
5f1a24 |
fi
|
|
|
5f1a24 |
done
|
|
|
5f1a24 |
for module_util in "${module_utils[@]}"; do
|
|
|
5f1a24 |
dest_module_util=plugins/module_utils/$module_util
|
|
|
5f1a24 |
cp -pL $dir/plugins/module_utils/$module_util $dest_module_util
|
|
|
5f1a24 |
# Replacing original collection name by downstream (vendored) name
|
|
|
5f1a24 |
if [ "${ns}" != "%{collection_namespace}" ] || [ "${name}" != "%{collection_name}" ] ; then
|
|
|
5f1a24 |
sed "s/${ns}[.]${name}/%{collection_namespace}.%{collection_name}/g" -i $dest_module_util
|
|
|
5f1a24 |
fi
|
|
|
5f1a24 |
done
|
|
|
5f1a24 |
done
|
|
|
5f1a24 |
%endif
|
|
|
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 |
%build
|
|
|
5f1a24 |
mkdir -p .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
|
|
|
5f1a24 |
cp -a * .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
|
|
|
5f1a24 |
%{SOURCE1} %{collection_namespace} %{collection_name} %{collection_version} > .collections/ansible_collections/%{collection_namespace}/%{collection_name}/galaxy.yml
|
|
|
5f1a24 |
|
|
|
5f1a24 |
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
|
|
|
73f2b9 |
%ansible_collection_build
|
|
|
5f1a24 |
popd
|
|
|
73f2b9 |
|
|
|
73f2b9 |
%install
|
|
|
5f1a24 |
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
|
|
|
73f2b9 |
%ansible_collection_install
|
|
|
5f1a24 |
popd
|
|
|
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
|
|
|
5f1a24 |
* Fri Aug 19 2022 Pavel Cahyna <pcahyna@redhat.com> - 1.1.0-2
|
|
|
5f1a24 |
- Add redfish_* modules from community.general
|
|
|
5f1a24 |
|
|
|
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
|