import ansible-collection-microsoft-sql-1.3.0-3.el8

This commit is contained in:
CentOS Sources 2023-03-28 09:37:11 +00:00 committed by root
parent 945c2bd024
commit b12fc949bc
3 changed files with 220 additions and 255 deletions

View File

@ -1,2 +1,2 @@
99df2e20aff7ec8c244218a45bbcd3d68b791311 SOURCES/auto-maintenance-cdc706f14614ef5e80bbce8db10beb369e889df9.tar.gz 06bdf4fd47cd57661f657fa4f29ec3031198ba11 SOURCES/auto-maintenance-73800682a3293ef5ab5ed5880329ce792cd34bbf.tar.gz
efe869a482b93c0b0289621a82e1718ac55e4ed4 SOURCES/mssql-1.2.3.tar.gz 43136931b6fa02984e7e0c30564f8202114ed2bd SOURCES/mssql-1.3.0.tar.gz

4
.gitignore vendored
View File

@ -1,2 +1,2 @@
SOURCES/auto-maintenance-cdc706f14614ef5e80bbce8db10beb369e889df9.tar.gz SOURCES/auto-maintenance-73800682a3293ef5ab5ed5880329ce792cd34bbf.tar.gz
SOURCES/mssql-1.2.3.tar.gz SOURCES/mssql-1.3.0.tar.gz

View File

@ -3,19 +3,18 @@
# ansible-core as a build_dep on RHEL8 # ansible-core as a build_dep on RHEL8
%if 0%{?fedora} || 0%{?rhel} >= 9 %if 0%{?fedora} || 0%{?rhel} >= 9
%bcond_without ansible %bcond_without ansible
%global ansible_build_dep ansible-core >= 2.11.0 %if 0%{?fedora}
BuildRequires: ansible-packaging
%else %else
%if 0%{?rhel} && ! 0%{?epel} BuildRequires: ansible-core >= 2.11.0
%bcond_with ansible
%else
%bcond_without ansible
%global ansible_build_dep ansible >= 2.9.10
%endif %endif
%else
%bcond_with ansible
%endif %endif
%bcond_with collection_artifact %bcond_with collection_artifact
# Do not convert .md to .html on RHEL 7 because tools the conversion are not available # Do not convert .md to .html on RHEL 7 because pandoc is not available
%if 0%{?fedora} || 0%{?rhel} >= 8 %if 0%{?fedora} || 0%{?rhel} >= 8
%bcond_without html %bcond_without html
%else %else
@ -25,33 +24,39 @@
Name: ansible-collection-microsoft-sql Name: ansible-collection-microsoft-sql
Url: https://github.com/linux-system-roles/mssql Url: https://github.com/linux-system-roles/mssql
Summary: The Ansible collection for Microsoft SQL Server management Summary: The Ansible collection for Microsoft SQL Server management
Version: 1.2.3 Version: 1.3.0
Release: 1%{?dist} Release: 3%{?dist}
#Group: Development/Libraries
License: MIT License: MIT
%global installbase %{_datadir}/microsoft
%global _pkglicensedir %{_licensedir}/%{name}
%global rolename mssql
%global collection_namespace microsoft %global collection_namespace microsoft
%global collection_name sql %global collection_name sql
%global collection_rolename server
%global collection_version %{version} %global collection_version %{version}
%global legacy_rolename %{collection_namespace}.sql-server
%global _pkglicensedir %{_licensedir}/%{name}
# Helper macros originally from macros.ansible by Igor Raits <ignatenkobrain> # 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 # On RHEL, not available, so we must define those macros locally
# On Fedora, provided by ansible-packager
# Not used (yet). Could be made to point to AH in RHEL - but what about CentOS Stream? # 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}} #%%{!?ansible_collection_url:%%define ansible_collection_url() https://galaxy.ansible.com/%%{collection_namespace}/%%{collection_name}}
%if 0%{?rhel}
%if 0%{?fedora} || 0%{?rhel} >= 8 Provides: ansible-collection(%{collection_namespace}.%{collection_name}) = %{collection_version}
%{!?ansible_collection_files:%define ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}/} %global ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}/
%define ansible_roles_dir %{_datadir}/ansible/roles
%if %{without ansible}
# Untar and copy everything instead of galaxy-installing the built artifact when ansible is not available
%define ansible_collection_build() tar -cf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz .
%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 %else
# Define undefined macro using "!?ansible_collection_files:..." does not work for rhel-7 %define ansible_collection_build() ansible-galaxy collection build
%if %{?ansible_collection_files:0}%{!?ansible_collection_files:1} %define ansible_collection_install() ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz
%define ansible_collection_files %{_datadir}/ansible/collections/ansible_collections/%{collection_namespace}/
%endif %endif
%endif %endif
# be compatible with the usual Fedora Provides:
Provides: ansible-collection-%{collection_namespace}-%{collection_name} = %{collection_version}-%{release}
# ansible-core is in rhel 8.6 and later - default to ansible-core, but allow # ansible-core is in rhel 8.6 and later - default to ansible-core, but allow
# the use of ansible if present - we may revisit this if the automatic dependency # the use of ansible if present - we may revisit this if the automatic dependency
@ -64,60 +69,19 @@ License: MIT
Requires: (ansible-core >= 2.11.0 or ansible >= 2.9.0) Requires: (ansible-core >= 2.11.0 or ansible >= 2.9.0)
%endif %endif
%if 0%{?fedora} %if 0%{?rhel}
Requires: linux-system-roles
%else
Requires: rhel-system-roles Requires: rhel-system-roles
%endif
%if %{with ansible}
BuildRequires: %{ansible_build_dep}
%endif
%if %{without ansible}
# We don't have ansible-galaxy.
# Simply copy everything instead of galaxy-installing the built artifact.
%define ansible_collection_build_install() tar -cf %{_tmppath}/%{collection_namespace}-%{collection_name}-%{version}.tar.gz .; 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 %else
%define ansible_collection_build_install() ansible-galaxy collection build; ansible-galaxy collection install -n -p %{buildroot}%{_datadir}/ansible/collections %{collection_namespace}-%{collection_name}-%{version}.tar.gz Requires: linux-system-roles
%endif %endif
# For each role, call defsource() and the point to it with SourceN: %{archiveurlN}. %global mainid 73800682a3293ef5ab5ed5880329ce792cd34bbf
%global archiveext tar.gz # Use either hash or tag for source1id
# list of source role names # %%global source1id 50edba099ab2c8b25b225fe760cb5a459b320030
%global rolenames %nil %global source1id %{version}
# list of assignments that can be used to populate a bash associative array variable
%global rolestodir %nil
# list of target rolenames to copy the roles to
%global target_rolenames %nil
# list of collection rolenames to convert the roles to
%global collection_rolenames %nil
%define getarchivedir() %(p=%{basename:%{S:%{1}}}; echo ${p%%.%{archiveext}})
%global parenturl https://github.com/linux-system-roles %global parenturl https://github.com/linux-system-roles
# You can feed either tag or commit to defsource
%define defsource() %{expand:%%global ref%{1} %{2}
%%global extractdir%{1} %%{expand:%%getarchivedir %{1}}
%%global archiveurl%{1} %%{parenturl}/%%{rolename%{1}}/archive/%%{ref%{1}}/%%{rolename%{1}}-%%{ref%{1}}.tar.gz
%%global rolenames %%{?rolenames} %%{rolename%{1}}
%%global roletodir%{1} [%{rolename%{1}}]="%{extractdir%{1}}"
%%global rolestodir %%{?rolestodir} %{roletodir%{1}}
%%{!?target_rolename%{1}:%%global target_rolename%{1} %%{rolename%{1}}}
%%global target_rolenames %%{?target_rolenames} [%{rolename%{1}}]="%{target_rolename%{1}}"
%%{!?collection_rolename%{1}:%%global collection_rolename%{1} %%{rolename%{1}}}
%%global collection_rolenames %%{?collection_rolenames} [%{rolename%{1}}]="%{collection_rolename%{1}}"
}
%defsource 1 1.2.3
%global rolename1 mssql
%global target_rolename1 sql-server
%global collection_rolename1 server
%global mainid cdc706f14614ef5e80bbce8db10beb369e889df9
Source: %{parenturl}/auto-maintenance/archive/%{mainid}/auto-maintenance-%{mainid}.tar.gz Source: %{parenturl}/auto-maintenance/archive/%{mainid}/auto-maintenance-%{mainid}.tar.gz
Source1: %{archiveurl1} Source1: %{parenturl}/%{rolename}/archive/%{source1id}/%{rolename}-%{source1id}.tar.gz
BuildArch: noarch BuildArch: noarch
@ -134,200 +98,166 @@ BuildRequires: highlight
# Requirements for galaxy_transform.py # Requirements for galaxy_transform.py
BuildRequires: python3 BuildRequires: python3
%if 0%{?fedora} || 0%{?rhel} >= 8 BuildRequires: python%{python3_pkgversion}-ruamel-yaml
BuildRequires: %{py3_dist ruamel.yaml}
%else
BuildRequires: python3-ruamel-yaml
%endif
%if %{undefined __ansible_provides}
Provides: ansible-collection(%{collection_namespace}.%{collection_name}) = %{collection_version}
%endif
# be compatible with the usual Fedora Provides:
Provides: ansible-collection-%{collection_namespace}-%{collection_name} = %{version}-%{release}
%description %description
This RPM installs the Ansible collection for Microsoft SQL Server management This RPM installs the %{collection_namespace}.%{collection_name} Ansible
microsoft.sql. This RPM also installs the roles provided by the collection in collection that provides the %{collection_rolename} role for Microsoft SQL
the legacy roles format for users of Ansible < 2.9. Server management. This RPM also installs the %{legacy_rolename} role
in the legacy roles format for users of Ansible < 2.9.
%if %{with collection_artifact} %if %{with collection_artifact}
%package collection-artifact %package collection-artifact
Summary: Collection artifact to import to Automation Hub / Ansible Galaxy Summary: Collection artifact to import to Automation Hub / Ansible Galaxy
%description collection-artifact %description collection-artifact
Collection artifact for %{name}. This package contains %{collection_namespace}-%{collection_name}-%{version}.tar.gz Collection artifact for %{name}. This package contains
%{collection_namespace}-%{collection_name}-%{version}.tar.gz
%endif %endif
%pretrans -p <lua>
path = "%{ansible_roles_dir}/%{legacy_rolename}"
st = posix.stat(path)
if st and st.type == "link" then
os.remove(path)
end
%prep %prep
%setup -q -a1 -n %{getarchivedir 0} %setup -q -a1 -n auto-maintenance-%{mainid}
# Declare the array containing names of directories to copy roles to for prep mv %{rolename}-%{source1id} %{rolename}
declare -A ROLESTODIR=(%{rolestodir})
for rolename in %{rolenames}; do
mv "${ROLESTODIR[${rolename}]}" ${rolename}
done
# Removing symlinks in tests/roles # Remove symlinks in tests/roles
for rolename in %{rolenames}; do if [ -d %{rolename}/tests/roles ]; then
if [ -d ${rolename}/tests/roles ]; then find %{rolename}/tests/roles -type l -exec rm {} \;
find ${rolename}/tests/roles -type l -exec rm {} \; if [ -d %{rolename}/tests/roles/linux-system-roles.%{rolename} ]; then
if [ -d ${rolename}/tests/roles/linux-system-roles.${rolename} ]; then rm -r %{rolename}/tests/roles/linux-system-roles.%{rolename}
rm -r ${rolename}/tests/roles/linux-system-roles.${rolename}
fi
fi fi
done fi
# transform ambiguous #!/usr/bin/env python shebangs to python3 to stop brp-mangle-shebangs complaining
find -type f -executable -name '*.py' -exec \
sed -i -r -e '1s@^(#! */usr/bin/env python)(\s|$)@#\13\2@' '{}' +
%build %build
%if %{with html} %if %{with html}
# Convert README.md to README.html in the source roles # Convert README.md to README.html in the source roles
readmes="" sh md2html.sh -t %{rolename}/README.md
for rolename in %{rolenames}; do
readmes="${readmes} $rolename/README.md"
done
sh md2html.sh $readmes
%endif %endif
mkdir .collections mkdir .collections
# Copy README.md for the collection build # Copy README.md for the collection build
cp %{rolename1}/.collection/README.md lsr_role2collection/collection_readme.md cp %{rolename}/.collection/README.md lsr_role2collection/collection_readme.md
# Copy galaxy.yml for the collection build # Copy galaxy.yml for the collection build
cp %{rolename1}/.collection/galaxy.yml ./ cp %{rolename}/.collection/galaxy.yml ./
# Ensure the correct entries in galaxy.yml
%if 0%{?rhel} %if 0%{?rhel}
./galaxy_transform.py "%{collection_namespace}" "%{collection_name}" "%{collection_version}" \ # Ensure the correct entries in galaxy.yml
./galaxy_transform.py "%{collection_namespace}" "%{collection_name}" "%{version}" \
"Ansible collection for Microsoft SQL Server management" \ "Ansible collection for Microsoft SQL Server management" \
"https://github.com/linux-system-roles/mssql" \ "https://github.com/linux-system-roles/mssql" \
"https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/administration_and_configuration_tasks_using_system_roles_in_rhel/assembly_configuring-microsoft-sql-server-using-microsoft-sql-server-ansible-role_assembly_updating-packages-to-enable-automation-for-the-rhel-system-roles" \ "https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/administration_and_configuration_tasks_using_system_roles_in_rhel/assembly_configuring-microsoft-sql-server-using-microsoft-sql-server-ansible-role_assembly_updating-packages-to-enable-automation-for-the-rhel-system-roles" \
"https://github.com/linux-system-roles/mssql/blob/master/README.md" \ "https://github.com/linux-system-roles/mssql/blob/main/README.md" \
"https://bugzilla.redhat.com/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%208&component=ansible-collection-microsoft-sql" \ "https://bugzilla.redhat.com/enter_bug.cgi?product=Red%20Hat%20Enterprise%20Linux%208&component=ansible-collection-microsoft-sql" \
> galaxy.yml.tmp > galaxy.yml.tmp
%else %else
./galaxy_transform.py "%{collection_namespace}" "%{collection_name}" "%{collection_version}" \ ./galaxy_transform.py "%{collection_namespace}" "%{collection_name}" "%{version}" \
"Ansible collection for Microsoft SQL Server management" \ "Ansible collection for Microsoft SQL Server management" \
> galaxy.yml.tmp > galaxy.yml.tmp
%endif %endif
mv galaxy.yml.tmp galaxy.yml mv galaxy.yml.tmp galaxy.yml
# Declare the array containing collection rolenames to convert roles to
declare -A COLLECTION_ROLENAMES=(%{collection_rolenames})
# Replace fedora.linux_system_roles with redhat.rhel_system_roles
%if 0%{?rhel} %if 0%{?rhel}
for rolename in %{rolenames}; do # Replace "fedora.linux_system_roles" with "redhat.rhel_system_roles"
sed -i 's/fedora\.linux_system_roles/redhat.rhel_system_roles/g' \ # This is for the "roles calling other roles" case
$rolename/CHANGELOG.md \ find %{rolename} -type f -exec \
$rolename/README.md \ sed -e "s/fedora[.]linux_system_roles[.]/redhat.rhel_system_roles./g" \
$rolename/tasks/*.yml \ -i {} \;
$rolename/tests/*.yml \
$rolename/meta/*.yml
done
%endif %endif
# Convert roles to the collection format # Convert to the collection format
for rolename in %{rolenames}; do python3 lsr_role2collection.py --role "%{rolename}" \
python3 lsr_role2collection.py --role "$rolename" \ --src-path "%{rolename}" \
--src-path "$rolename" \ --src-owner linux-system-roles \
--src-owner linux-system-roles \ --dest-path .collections \
--dest-path .collections \ --readme lsr_role2collection/collection_readme.md \
--readme lsr_role2collection/collection_readme.md \ --namespace %{collection_namespace} \
--namespace %{collection_namespace} --collection %{collection_name} \ --collection %{collection_name} \
--new-role "${COLLECTION_ROLENAMES[${rolename}]}" \ --new-role "%{collection_rolename}" \
--meta-runtime lsr_role2collection/runtime.yml --meta-runtime lsr_role2collection/runtime.yml
done
# Replace remnants of "linux-system-roles.mssql" with collection FQDN
find .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ -type f -exec \
sed -e "s/linux-system-roles[.]%{rolename}\\>/%{collection_namespace}.%{collection_name}.%{collection_rolename}/g" \
-i {} \;
# removing dot files/dirs # removing dot files/dirs
rm -r .collections/ansible_collections/%{collection_namespace}/%{collection_name}/.[A-Za-z]* rm -r .collections/ansible_collections/%{collection_namespace}/%{collection_name}/.[A-Za-z]*
rm -r .collections/ansible_collections/%{collection_namespace}/%{collection_name}/tests/%{collection_rolename}/.[A-Za-z]*
# Copy galaxy.yml to the collection directory # Copy galaxy.yml to the collection directory
cp -p galaxy.yml .collections/ansible_collections/%{collection_namespace}/%{collection_name} cp -p galaxy.yml .collections/ansible_collections/%{collection_namespace}/%{collection_name}
# Update CHANGELOG.md with the current date and copy it to collection dir # Copy CHANGELOG.md from mssql to collection dir
curr_date=$(date +'%Y-%m-%d') mv .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{collection_rolename}/CHANGELOG.md \
sed -i "s/^\([%{version}] - \).*/\1$curr_date/g" \
.collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{collection_rolename1}/CHANGELOG.md
mv .collections/ansible_collections/%{collection_namespace}/%{collection_name}/roles/%{collection_rolename1}/CHANGELOG.md \
.collections/ansible_collections/%{collection_namespace}/%{collection_name}/ .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
%install # Build collection
mkdir -p $RPM_BUILD_ROOT%{installbase}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/ansible/roles
# Declare the array containing target rolenames to copy roles to
declare -A TARGET_ROLENAMES=(%{target_rolenames})
# Copy roles to the target directory within the microsoft directory and rename
for rolename in %{rolenames}; do
cp -pR "$rolename" "$RPM_BUILD_ROOT%{installbase}/${TARGET_ROLENAMES[${rolename}]}"
sed -i "s/linux-system-roles\.$rolename/microsoft\.${TARGET_ROLENAMES[${rolename}]}/g" \
$RPM_BUILD_ROOT%{installbase}/${TARGET_ROLENAMES[${rolename}]}/tests/*.yml
done
# Generate symlinks for roles in /usr/share/ansible/roles
for rolename in %{rolenames}; do
ln -s "%{installbase}/${TARGET_ROLENAMES[${rolename}]}" "$RPM_BUILD_ROOT%{_datadir}/ansible/roles/microsoft.${TARGET_ROLENAMES[${rolename}]}"
done
# Copy README, COPYING, and LICENSE files to the corresponding directories
mkdir -p $RPM_BUILD_ROOT%{_pkglicensedir}
for rolename in %{rolenames}; do
mkdir -p "$RPM_BUILD_ROOT%{_pkgdocdir}/${TARGET_ROLENAMES[${rolename}]}"
cp -p "$RPM_BUILD_ROOT%{installbase}/${TARGET_ROLENAMES[${rolename}]}/README.md" \
"$RPM_BUILD_ROOT%{_pkgdocdir}/${TARGET_ROLENAMES[${rolename}]}"
%if %{with html}
cp -p "$RPM_BUILD_ROOT%{installbase}/${TARGET_ROLENAMES[${rolename}]}/README.html" \
"$RPM_BUILD_ROOT%{_pkgdocdir}/${TARGET_ROLENAMES[${rolename}]}"
%endif
if [ -f "$RPM_BUILD_ROOT%{installbase}/${TARGET_ROLENAMES[${rolename}]}/COPYING" ]; then
cp -p "$RPM_BUILD_ROOT%{installbase}/${TARGET_ROLENAMES[${rolename}]}/COPYING" \
"$RPM_BUILD_ROOT%{_pkglicensedir}/${TARGET_ROLENAMES[${rolename}]}.COPYING"
fi
if [ -f "$RPM_BUILD_ROOT%{installbase}/${TARGET_ROLENAMES[${rolename}]}/LICENSE" ]; then
cp -p "$RPM_BUILD_ROOT%{installbase}/${TARGET_ROLENAMES[${rolename}]}/LICENSE" \
"$RPM_BUILD_ROOT%{_pkglicensedir}/${TARGET_ROLENAMES[${rolename}]}.LICENSE"
fi
done
# Remove dot files
rm -r $RPM_BUILD_ROOT%{installbase}/*/.[A-Za-z]*
# Remove the molecule directory
rm -r $RPM_BUILD_ROOT%{installbase}/*/molecule
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
%ansible_collection_build_install %ansible_collection_build
popd popd
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection %install
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles mkdir -p %{buildroot}%{ansible_roles_dir}
# Copy role in legacy format and rename rolename in tests
cp -pR "%{rolename}" "%{buildroot}%{ansible_roles_dir}/%{legacy_rolename}"
find %{buildroot}%{ansible_roles_dir}/%{legacy_rolename} -type f -exec \
sed -e "s/linux-system-roles\.%{rolename}/%{legacy_rolename}/g" \
-i {} \;
# Copy README, COPYING, and LICENSE files to the corresponding directories
mkdir -p %{buildroot}%{_pkglicensedir}
mkdir -p "%{buildroot}%{_pkgdocdir}/%{legacy_rolename}"
ln -sr "%{buildroot}%{ansible_roles_dir}/%{legacy_rolename}/README.md" \
"%{buildroot}%{_pkgdocdir}/%{legacy_rolename}"
%if %{with html}
ln -sr "%{buildroot}%{ansible_roles_dir}/%{legacy_rolename}/README.html" \
"%{buildroot}%{_pkgdocdir}/%{legacy_rolename}"
%endif
if [ -f "%{buildroot}%{ansible_roles_dir}/%{legacy_rolename}/COPYING" ]; then
ln -sr "%{buildroot}%{ansible_roles_dir}/%{legacy_rolename}/COPYING" \
"%{buildroot}%{_pkglicensedir}/%{legacy_rolename}.COPYING"
fi
if [ -f "%{buildroot}%{ansible_roles_dir}/%{legacy_rolename}/LICENSE" ]; then
ln -sr "%{buildroot}%{ansible_roles_dir}/%{legacy_rolename}/LICENSE" \
"%{buildroot}%{_pkglicensedir}/%{legacy_rolename}.LICENSE"
fi
# Remove dot files
rm -r %{buildroot}%{ansible_roles_dir}/*/.[A-Za-z]*
rm -r %{buildroot}%{ansible_roles_dir}/%{legacy_rolename}/tests/.[A-Za-z]*
# Remove the molecule directory
rm -r %{buildroot}%{ansible_roles_dir}/*/molecule
# Install collection
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
%ansible_collection_install
popd
mkdir -p %{buildroot}%{_pkgdocdir}/collection/roles
# Copy the collection README files to the collection # Copy the collection README files to the collection
cp -p %{buildroot}%{ansible_collection_files}%{collection_name}/README.md \ ln -sr %{buildroot}%{ansible_collection_files}%{collection_name}/README.md \
$RPM_BUILD_ROOT%{_pkgdocdir}/collection %{buildroot}%{_pkgdocdir}/collection
# Declare the array containing collection rolenames to convert roles to # Copy role's readme to /usr/share/doc/
declare -A COLLECTION_ROLENAMES=(%{collection_rolenames}) if [ -f "%{buildroot}%{ansible_collection_files}%{collection_name}/roles/%{collection_rolename}/README.md" ]; then
mkdir -p %{buildroot}%{_pkgdocdir}/collection/roles/%{collection_rolename}
for rolename in %{rolenames}; do ln -sr %{buildroot}%{ansible_collection_files}%{collection_name}/roles/%{collection_rolename}/README.md \
if [ -f "%{buildroot}%{ansible_collection_files}%{collection_name}/roles/${COLLECTION_ROLENAMES[${rolename}]}/README.md" ]; then %{buildroot}%{_pkgdocdir}/collection/roles/%{collection_rolename}
mkdir -p $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${COLLECTION_ROLENAMES[${rolename}]} fi
cp -p %{buildroot}%{ansible_collection_files}%{collection_name}/roles/${COLLECTION_ROLENAMES[${rolename}]}/README.md \
$RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${COLLECTION_ROLENAMES[${rolename}]}
fi
done
%if %{with html} %if %{with html}
# converting README.md to README.html for collection in $RPM_BUILD_ROOT%{_pkgdocdir}/collection # Convert README.md to README.html for collection in %%{buildroot}%%{_pkgdocdir}/collection
readmes="$RPM_BUILD_ROOT%{_pkgdocdir}/collection/README.md" sh md2html.sh -t %{buildroot}%{_pkgdocdir}/collection/roles/%{collection_rolename}/README.md
for rolename in %{rolenames}; do
readmes="${readmes} $RPM_BUILD_ROOT%{_pkgdocdir}/collection/roles/${COLLECTION_ROLENAMES[${rolename}]}/README.md"
done
sh md2html.sh $readmes
%endif %endif
%if %{with collection_artifact} %if %{with collection_artifact}
@ -335,19 +265,21 @@ sh md2html.sh $readmes
pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/ pushd .collections/ansible_collections/%{collection_namespace}/%{collection_name}/
if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then if [ -f %{collection_namespace}-%{collection_name}-%{version}.tar.gz ]; then
mv %{collection_namespace}-%{collection_name}-%{version}.tar.gz \ mv %{collection_namespace}-%{collection_name}-%{version}.tar.gz \
$RPM_BUILD_ROOT%{_datadir}/ansible/collections/ %{buildroot}%{_datadir}/ansible/collections/
fi fi
popd popd
%endif %endif
# generate the %files section in the file files_section.txt # Generate the %%files section in files_section.txt
# Bulk files inclusion is not possible because roles store doc and licence
# files together with other files
format_item_for_files() { format_item_for_files() {
# $1 is directory or file name in buildroot # $1 is directory or file name in buildroot
# $2 - if true, and item is a directory, use %dir # $2 - if true, and item is a directory, use %%dir
local item local item
local files_item local files_item
item="$1" item="$1" # full path including buildroot
files_item=${item##"%{buildroot}"} files_item=${item##"%{buildroot}"} # path with cut buildroot to be added to %%files
if [ -L "$item" ]; then if [ -L "$item" ]; then
echo "$files_item" echo "$files_item"
elif [ -d "$item" ]; then elif [ -d "$item" ]; then
@ -358,16 +290,16 @@ format_item_for_files() {
else else
echo "$files_item" echo "$files_item"
fi fi
elif [[ "$item" == */README.md ]] || [[ "$item" == */README.html ]]; then elif [[ "$item" == */README.md ]] || [[ "$item" == */README.html ]] || [[ "$item" == */CHANGELOG.md ]]; then
if [[ "$item" == */private_* ]]; then if [[ "$item" == */private_* ]]; then
# mark as regular file, not %doc # mark as regular file, not %%doc
echo "$files_item" echo "$files_item"
else else
echo "%doc $files_item" echo "%doc $files_item"
fi fi
elif [[ "$item" != */COPYING* ]] && [[ "$item" != */LICENSE* ]]; then elif [[ "$item" == */COPYING* ]] || [[ "$item" == */LICENSE* ]]; then
# Avoid dynamically using the license macro since the license macro echo "%""%""license" "$files_item"
# is replaced with the value of License directive in the older rpmbuild. else
echo "$files_item" echo "$files_item"
fi fi
} }
@ -375,15 +307,7 @@ format_item_for_files() {
files_section=files_section.txt files_section=files_section.txt
rm -f $files_section rm -f $files_section
touch $files_section touch $files_section
%if %{without ansible} # Dynamically generate files section entries for %%{ansible_collection_files}
echo '%dir %{_datadir}/ansible' >> $files_section
echo '%dir %{_datadir}/ansible/roles' >> $files_section
%endif
%if "%{installbase}" != "%{_datadir}/ansible/roles"
echo '%dir %{installbase}' >> $files_section
%endif
echo '%dir %{ansible_collection_files}' >> $files_section
echo '%dir %{ansible_collection_files}%{collection_name}' >> $files_section
find %{buildroot}%{ansible_collection_files}%{collection_name} -mindepth 1 -maxdepth 1 | \ find %{buildroot}%{ansible_collection_files}%{collection_name} -mindepth 1 -maxdepth 1 | \
while read item; do while read item; do
if [[ "$item" == */roles ]]; then if [[ "$item" == */roles ]]; then
@ -399,7 +323,8 @@ find %{buildroot}%{ansible_collection_files}%{collection_name} -mindepth 1 -maxd
fi fi
done done
find %{buildroot}%{installbase} -mindepth 1 -maxdepth 1 | \ # Dynamically generate files section entries for %%{ansible_roles_dir}
find %{buildroot}%{ansible_roles_dir} -mindepth 1 -maxdepth 1 | \
while read item; do while read item; do
if [ -d "$item" ]; then if [ -d "$item" ]; then
format_item_for_files "$item" true >> $files_section format_item_for_files "$item" true >> $files_section
@ -410,32 +335,14 @@ find %{buildroot}%{installbase} -mindepth 1 -maxdepth 1 | \
format_item_for_files "$item" >> $files_section format_item_for_files "$item" >> $files_section
fi fi
done done
if [ "%{installbase}" != "%{_datadir}/ansible/roles" ]; then
find %{buildroot}%{_datadir}/ansible/roles -mindepth 1 -maxdepth 1 | \
while read item; do
if [ -d "$item" ]; then
format_item_for_files "$item" true >> $files_section
find "$item" -mindepth 1 -maxdepth 1 | while read roles_item; do
format_item_for_files "$roles_item" >> $files_section
done
else
format_item_for_files "$item" >> $files_section
fi
done
fi
# cat files_section.txt
# done with files_section.txt generation
%files -f files_section.txt %files -f files_section.txt
%{_pkgdocdir}/*/README.md %dir %{_datadir}/ansible
%{_pkgdocdir}/collection/roles/*/README.md %dir %{ansible_roles_dir}
%if %{with html} %dir %{ansible_collection_files}
%{_pkgdocdir}/*/README.html %dir %{ansible_collection_files}%{collection_name}
%{_pkgdocdir}/collection/roles/*/README.html %doc %{_pkgdocdir}
%endif %license %{_pkglicensedir}
%license %{_pkglicensedir}/*
%license %{installbase}/*/LICENSE*
%license %{ansible_collection_files}/%{collection_name}/LICENSE*
%if %{with collection_artifact} %if %{with collection_artifact}
%files collection-artifact %files collection-artifact
@ -443,6 +350,64 @@ fi
%endif %endif
%changelog %changelog
* Thu Feb 23 2023 Sergei Petrosian <spetrosi@redhat.com> - 1.3.0-3
- Spec: add functionality to build from a commit hash
- Use latest 1.3.0 to add flexibility to AD integration functionality
Resolves: rhbz#2163696
* Thu Feb 16 2023 Sergei Petrosian <spetrosi@redhat.com> - 1.3.0-2
- Replace fedora.linux_system_roles/redhat.rhel_system_roles and
linux-system-roles.mssql with microsoft.sql.server in the role.
Resolves: rhbz#2129106
- Use latest 1.3.0 to fix ad_Integration issues
Resolves: rhbz#2163696
* Wed Feb 1 2023 Sergei Petrosian <spetrosi@redhat.com> - 1.3.0-1
- Keep spec consistent with linux-system-roles
- Return conditionals related to EL to keep up- and downstream consistent
- Add pretrans scriplet to remove symlinks if exist to fix issue with update
- Instead of copying doc and license files create symlinks
- Dynamically generate %%files section
- Add -t to md2html to generate TOC
Resolves: rhbz#2129106
- On SQL Server Enterprise Edition, support configuring asynchronous replication
Resolves: rhbz#2144820
- Support configuring a read-scale SQL server availability group (without pacemaker
Resolves: rhbz#2144821
- Use the certificate role to create the cert and the key
Resolves: rhbz#2144852
- Support SQL Server version 2022
Resolves: rhbz#2153427
- Support integrating with AD Server for authentication
Resolves: rhbz#2163696
* Thu Sep 22 2022 Sergei Petrosian <spetrosi@redhat.com> - 1.2.4-2
- Simplify spec file
- Do not install roles to /usr/share/microsoft and then create symlinks
to /usr/share/ansible/roles/, instead install directly to
/usr/share/ansible/roles/
- Remove unused removal of ambiguous python shebangs
- Remove all loops because this RPM contains only one role
- Remove defsource - simply define the source for mssql
- 's|$RPM_BUILD_ROOT|%%{buildroot}|' for consistency
- Remove getarchivedir for simplicity
- Wrap description by 80 symbols and clarify it
- Remove tests/.fmf dir from the RPM
Resolves: rhbz#2129106
* Thu Sep 1 2022 Sergei Petrosian <spetrosi@redhat.com> - 1.2.4-1
- Replicate all provided databases
- This change fixes the bug where only the first database provided with
mssql_ha_db_names got replicated
- Clarify that the role does not remove not listed databases
Resolves: rhbz#2129869
- Input multiple sql scripts
- Allow _input_sql_file vars to accept list of files
- Flush handlers prior to inputting post sql script
Resolves: rhbz#2129872
- Note that ha_cluster is not idempotent
- SPEC: Do not update dates in CHANGELOG.md
* Thu Aug 25 2022 Sergei Petrosian <spetrosi@redhat.com> - 1.2.3-1 * Thu Aug 25 2022 Sergei Petrosian <spetrosi@redhat.com> - 1.2.3-1
- Use firewall role to configure firewall for SQL Server - Use firewall role to configure firewall for SQL Server
Resolves: rhbz#2120714 Resolves: rhbz#2120714