100 lines
3.5 KiB
RPMSpec
100 lines
3.5 KiB
RPMSpec
#
|
|
# spec file for package ansible-sap-operations
|
|
#
|
|
# Copyright (c) 2025 SUSE LLC
|
|
#
|
|
# 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/
|
|
#
|
|
|
|
%define ansible_collection_name sap_operations
|
|
%define ansible_collection_path %{_datadir}/ansible/collections/ansible_collections/suse/%{ansible_collection_name}
|
|
|
|
|
|
Name: ansible-sap-operations
|
|
Summary: Ansible collection suse.sap_operations for SAP Automation
|
|
License: Apache-2.0
|
|
Version: 0.9.1
|
|
Release: 0
|
|
URL: https://github.com/SUSE/community.sap_operations/
|
|
Source0: %{url}archive/refs/tags/%{version}.tar.gz#/%{name}-%{version}.tar.gz
|
|
Source1: %{name}.yaml
|
|
Source2: transformation.py
|
|
Source3: README.md
|
|
|
|
BuildArch: noarch
|
|
|
|
|
|
Requires: ansible-core >= 2.16
|
|
Requires: ansible >= 9
|
|
BuildRequires: ansible-core >= 2.16
|
|
BuildRequires: ansible >= 9
|
|
|
|
# Python module ruamel.yaml for collection-update.py
|
|
BuildRequires: python3-ruamel.yaml
|
|
|
|
%description
|
|
This package provides a Ansible collection suse.sap_operations.
|
|
|
|
It automates suite of day to day operations for existing SAP landscape.
|
|
|
|
This collection can be used to execute sapcontrol functions,
|
|
update SAP profiles, configure firewall rules, execute RFC, etc.
|
|
|
|
%prep
|
|
%autosetup -p1 -n community.%{ansible_collection_name}-%{version}
|
|
# Update readme file
|
|
install -m 644 %{SOURCE3} README.md
|
|
|
|
%build
|
|
# Execute python script to update documentation and remove unsupported roles
|
|
python3 %{_sourcedir}/transformation.py --config %{_sourcedir}/%{name}.yaml --build_dir .
|
|
# Build the Ansible collection
|
|
ansible-galaxy collection build --output-path %{_builddir}
|
|
|
|
%install
|
|
mkdir -p %{buildroot}%{_datadir}/ansible/collections
|
|
mkdir -p %{buildroot}%{_datadir}/ansible/roles/
|
|
|
|
# ansible-galaxy always appends ansible_collections folder into collections path
|
|
ansible-galaxy collection install --force %{_builddir}/suse-%{ansible_collection_name}-%{version}.tar.gz \
|
|
--collections-path %{buildroot}%{_datadir}/ansible/collections
|
|
|
|
%post
|
|
# Loop through roles in collection and create symlinks under /usr/share/ansible/roles/
|
|
# Installed community collection will take precedence over role symlinks.
|
|
for role in %{ansible_collection_path}/roles/*; do
|
|
role_name=$(basename "$role")
|
|
if [ ! -e %{_datadir}/ansible/roles/community.%{ansible_collection_name}.${role_name} ]; then
|
|
ln -sf %{ansible_collection_path}/roles/${role_name} \
|
|
%{_datadir}/ansible/roles/community.%{ansible_collection_name}.${role_name}
|
|
fi
|
|
done
|
|
|
|
%postun
|
|
# Loop through roles in /usr/share/ansible/roles/ and remove those that link to collection
|
|
if [ "$1" -eq 0 ]; then
|
|
for role in %{_datadir}/ansible/roles/community.%{ansible_collection_name}.*; do
|
|
if [ -L "$role" ]; then
|
|
target=$(readlink "$role")
|
|
if ( [ -e "$target" ] && [ "$target" = "%{ansible_collection_path}/roles/$(basename "$role")" ] ) || [ ! -e "$target" ]; then
|
|
rm -f "$role"
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
|
|
%files
|
|
%{_datadir}/ansible/collections/
|
|
%{_datadir}/ansible/roles/
|
|
|
|
%changelog
|