diff --git a/ansible-freeipa-1.12.1-utils-build-galaxy-release.sh-offline.patch b/ansible-freeipa-1.12.1-utils-build-galaxy-release.sh-offline.patch new file mode 100644 index 0000000..1e81fa9 --- /dev/null +++ b/ansible-freeipa-1.12.1-utils-build-galaxy-release.sh-offline.patch @@ -0,0 +1,194 @@ +From fe16df8a6c0a188b3621061932801587e2999383 Mon Sep 17 00:00:00 2001 +From: Thomas Woerner +Date: Wed, 20 Mar 2024 11:07:56 +0100 +Subject: [PATCH] utils/build-galaxy-release.sh: Enable offline generation for + rpm + +Two new options have been added to enable the offline build within rpm: + + -o Build offline without using git, using version A.B.C + Also enables -a + -p Installation the generated collection in the path, the + ansible_collections sub directory will be created and will + contain the collection: ansible_collections// + Also enables -i + +The usage text has been fixed also for specifying namespace and name. +The collection variable has been renamed to name. + +Example usage: + + utils/build-galaxy-release.sh -o 1.12.1 \ + -p %{buildroot}%{_datadir}/ansible/collections \ + freeipa ansible_freeipa +--- + utils/build-galaxy-release.sh | 57 ++++++++++++++++++++++++----------- + 1 file changed, 40 insertions(+), 17 deletions(-) + +diff --git a/utils/build-galaxy-release.sh b/utils/build-galaxy-release.sh +index e427013e..3c9c609a 100755 +--- a/utils/build-galaxy-release.sh ++++ b/utils/build-galaxy-release.sh +@@ -8,18 +8,24 @@ pwd=$(pwd) + + usage() { + cat < ] + + Build Anible Collection for ansible-freeipa. + +-The namespace defaults to freeipa an collection defaults to ansible_freeipa +-if namespace and collection are not given. Namespace and collection can not +-be givedn without the other one. ++The namespace defaults to freeipa an name defaults to ansible_freeipa, ++if namespace and name are not given. Namespace and name need to be set ++together. + + Options: + -a Add all files, no only files known to git repo + -k Keep build directory + -i Install the generated collection ++ -o Build offline without using git, using version A.B.C ++ Also enables -a ++ -p Installation the generated collection in the path, the ++ ansible_collections sub directory will be created and will ++ contain the collection: ansible_collections// ++ Also enables -i + -h Print this help + + EOF +@@ -28,7 +34,10 @@ EOF + all=0 + keep=0 + install=0 +-while getopts "ahki" arg; do ++path= ++offline=0 ++galaxy_version= ++while getopts "ahkio:p:" arg; do + case $arg in + a) + all=1 +@@ -43,6 +52,15 @@ while getopts "ahki" arg; do + i) + install=1 + ;; ++ o) ++ galaxy_version=$OPTARG ++ offline=1 ++ all=1 ++ ;; ++ p) ++ path=$OPTARG ++ install=1 ++ ;; + \?) + echo + usage +@@ -57,25 +75,26 @@ if [ $# != 0 ] && [ $# != 2 ]; then + exit 1 + fi + namespace="${1-freeipa}" +-collection="${2-ansible_freeipa}" ++name="${2-ansible_freeipa}" + if [ -z "$namespace" ]; then + echo "Namespace might not be empty" + exit 1 + fi +-if [ -z "$collection" ]; then +- echo "Collection might not be empty" ++if [ -z "$name" ]; then ++ echo "Name might not be empty" + exit 1 + fi +-collection_prefix="${namespace}.${collection}" ++collection_prefix="${namespace}.${name}" + +-galaxy_version=$(git describe --tags 2>/dev/null | sed -e "s/^v//") ++[ -z "$galaxy_version" ] && \ ++ galaxy_version=$(git describe --tags 2>/dev/null | sed -e "s/^v//") + + if [ -z "$galaxy_version" ]; then + echo "Version could not be detected" + exit 1 + fi + +-echo "Building collection: ${namespace}-${collection}-${galaxy_version}" ++echo "Building collection: ${namespace}-${name}-${galaxy_version}" + + GALAXY_BUILD=".galaxy-build" + +@@ -103,14 +122,18 @@ cd "$GALAXY_BUILD" || exit 1 + + sed -i -e "s/version: .*/version: \"$galaxy_version\"/" galaxy.yml + sed -i -e "s/namespace: .*/namespace: \"$namespace\"/" galaxy.yml +-sed -i -e "s/name: .*/name: \"$collection\"/" galaxy.yml ++sed -i -e "s/name: .*/name: \"$name\"/" galaxy.yml + + find . -name "*~" -exec rm {} \; + + +-echo "Creating CHANGELOG.rst..." +-"$(dirname "$0")/changelog" --galaxy > CHANGELOG.rst +-echo -e "\033[ACreating CHANGELOG.rst... \033[32;1mDONE\033[0m" ++if [ $offline == 0 ]; then ++ echo "Creating CHANGELOG.rst..." ++ "$(dirname "$0")/changelog" --galaxy > CHANGELOG.rst ++ echo -e "\033[ACreating CHANGELOG.rst... \033[32;1mDONE\033[0m" ++else ++ echo "Empty changelog, offline generated." > CHANGELOG.rst ++fi + + sed -i -e "s/ansible.module_utils.ansible_freeipa_module/ansible_collections.${collection_prefix}.plugins.module_utils.ansible_freeipa_module/" plugins/modules/*.py + +@@ -198,6 +221,6 @@ else + fi + + if [ $install == 1 ]; then +- echo "Installing collection ${namespace}-${collection}-${galaxy_version}.tar.gz ..." +- ansible-galaxy collection install "${namespace}-${collection}-${galaxy_version}.tar.gz" --force ++ echo "Installing collection ${namespace}-${name}-${galaxy_version}.tar.gz ..." ++ ansible-galaxy collection install ${path:+"-p$path"} "${namespace}-${name}-${galaxy_version}.tar.gz" --force ${offline/1/--offline} + fi +-- +2.44.0 + +From 2804ec3f8391d03b7bc9a63996160df76ec2ca1c Mon Sep 17 00:00:00 2001 +From: Thomas Woerner +Date: Tue, 26 Mar 2024 14:46:11 +0100 +Subject: [PATCH] utils/build-galaxy-release.sh: Fix offline default value + +The offline default value was 0, which resulted in 0 for +${offline/1/--offline}. + +This broke the ansible-galaxy collection install call. +--- + utils/build-galaxy-release.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/utils/build-galaxy-release.sh b/utils/build-galaxy-release.sh +index 3c9c609..a1681e0 100755 +--- a/utils/build-galaxy-release.sh ++++ b/utils/build-galaxy-release.sh +@@ -35,7 +35,7 @@ all=0 + keep=0 + install=0 + path= +-offline=0 ++offline= + galaxy_version= + while getopts "ahkio:p:" arg; do + case $arg in +@@ -127,7 +127,7 @@ sed -i -e "s/name: .*/name: \"$name\"/" galaxy.yml + find . -name "*~" -exec rm {} \; + + +-if [ $offline == 0 ]; then ++if [ $offline != 1 ]; then + echo "Creating CHANGELOG.rst..." + "$(dirname "$0")/changelog" --galaxy > CHANGELOG.rst + echo -e "\033[ACreating CHANGELOG.rst... \033[32;1mDONE\033[0m" +-- +2.44.0 + diff --git a/ansible-freeipa.spec b/ansible-freeipa.spec index eaad236..4b23d49 100644 --- a/ansible-freeipa.spec +++ b/ansible-freeipa.spec @@ -5,14 +5,21 @@ %global python %{__python3} +%global collection_namespace freeipa +%global collection_name ansible_freeipa +%global ansible_collections_dir %{_datadir}/ansible/collections/ansible_collections + Summary: Roles and playbooks to deploy FreeIPA servers, replicas and clients Name: ansible-freeipa Version: 1.12.1 -Release: 1%{?dist} +Release: 2%{?dist} URL: https://github.com/freeipa/ansible-freeipa License: GPL-3.0-or-later Source: https://github.com/freeipa/ansible-freeipa/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Patch0: ansible-freeipa-1.12.1-utils-build-galaxy-release.sh-offline.patch BuildArch: noarch +BuildRequires: ansible-core +BuildRequires: python %description Ansible roles to install and uninstall FreeIPA servers, replicas and clients, @@ -111,13 +118,24 @@ Requires: %{name} = %{version}-%{release} %description tests ansible-freeipa tests. +The tests for the collection are part of the collection sub package. + Please have a look at %{_datadir}/ansible-freeipa/requirements-tests.txt to get the needed requrements to run the tests. +%package collection +Summary: %{collection_namespace}.%{collection_name} collection +Provides: ansible-collection-%{collection_namespace}-%{collection_name} = %{version}-%{release} + +%description collection +The %{collection_namespace}.%{collection_name} collection, including tests. + + %prep %setup -q # Do not create backup files with patches +%patch 0 -p1 # Fix python modules and module utils: # - Remove shebang @@ -161,6 +179,11 @@ cp -rp utils %{buildroot}%{_datadir}/ansible-freeipa/ install -m 755 -d %{buildroot}%{_datadir}/ansible-freeipa/tests cp -rp tests %{buildroot}%{_datadir}/ansible-freeipa/ +# Create collection and install to %{buildroot}%{ansible_collections_dir} +# ansible-galaxy collection install creates ansible_collections directory +# automatically in given path, therefore /.. +utils/build-galaxy-release.sh -o "%{version}" -p %{buildroot}%{ansible_collections_dir}/.. %{collection_namespace} %{collection_name} + %files %license COPYING %{_datadir}/ansible/roles/ipaserver @@ -182,7 +205,16 @@ cp -rp tests %{buildroot}%{_datadir}/ansible-freeipa/ %{_datadir}/ansible-freeipa/tests %{_datadir}/ansible-freeipa/requirements-tests.txt +%files collection +%dir %{ansible_collections_dir}/%{collection_namespace} +%{ansible_collections_dir}/%{collection_namespace}/%{collection_name} + %changelog +* Tue Apr 2 2024 Thomas Woerner - 1.12.1-2 +- New -collection sub package providing the freeipa.ansible_freeipa + collection +- New build requires for ansible-core and python + * Mon Feb 12 2024 Thomas Woerner - 1.12.1-1 - Update to version 1.12.1 https://github.com/freeipa/ansible-freeipa/releases/tag/v1.12.1