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