renamed from ansible-base to ansible-core; added upstream patch to fix gpg_key with binary keys [release 2.11.0-2mamba;Sat May 22 2021]

This commit is contained in:
Silvan Calarco 2024-01-05 20:26:18 +01:00
parent 9031e21781
commit 193fc68f87
3 changed files with 210 additions and 0 deletions

View File

@ -1,2 +1,4 @@
# ansible-core
A radically simple IT automation system.

View File

@ -0,0 +1,78 @@
From 03750708710b2e44a7ffa068c65f969ae4ed51f1 Mon Sep 17 00:00:00 2001
From: Maxim Masiutin <maxim@masiutin.com>
Date: Wed, 28 Apr 2021 08:27:38 +0200
Subject: [PATCH] Binary GnuPG keys downloaded via URLs by the
'ansible.builtin.apt_key' module were corrupted so 'gpg' could not import
them (https://github.com/ansible/ansible/issues/74424)
---
.../74474-apt_key-gpg-binary-import.yaml | 3 +++
lib/ansible/modules/apt_key.py | 5 ++++-
.../apt_key/samples/apt-key-example-binary.gpg | Bin 0 -> 1787 bytes
.../targets/apt_key/tasks/apt_key_binary.yml | 13 +++++++++++++
test/integration/targets/apt_key/tasks/main.yml | 3 +++
5 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 changelogs/fragments/74474-apt_key-gpg-binary-import.yaml
create mode 100644 test/integration/targets/apt_key/samples/apt-key-example-binary.gpg
create mode 100644 test/integration/targets/apt_key/tasks/apt_key_binary.yml
diff --git a/changelogs/fragments/74474-apt_key-gpg-binary-import.yaml b/changelogs/fragments/74474-apt_key-gpg-binary-import.yaml
new file mode 100644
index 00000000000000..47e416b94399cf
--- /dev/null
+++ b/changelogs/fragments/74474-apt_key-gpg-binary-import.yaml
@@ -0,0 +1,3 @@
+---
+bugfixes:
+ - Binary GnuPG keys downloaded via URLs by the 'ansible.builtin.apt_key' module were corrupted so 'gpg' could not import them (https://github.com/ansible/ansible/issues/74424).
diff --git a/lib/ansible/modules/apt_key.py b/lib/ansible/modules/apt_key.py
index 87b6410a630b70..58e23216a99e9f 100644
--- a/lib/ansible/modules/apt_key.py
+++ b/lib/ansible/modules/apt_key.py
@@ -283,12 +283,15 @@ def download_key(module, url):
def get_key_id_from_file(module, filename, data=None):
+ native_data = to_native(data)
+ is_armored = native_data.find("-----BEGIN PGP PUBLIC KEY BLOCK-----") >= 0
+
global lang_env
key = None
cmd = [gpg_bin, '--with-colons', filename]
- (rc, out, err) = module.run_command(cmd, environ_update=lang_env, data=to_native(data))
+ (rc, out, err) = module.run_command(cmd, environ_update=lang_env, data=(native_data if is_armored else data), binary_data=not is_armored)
if rc != 0:
module.fail_json(msg="Unable to extract key from '%s'" % ('inline data' if data is None else filename), stdout=out, stderr=err)
diff --git a/test/integration/targets/apt_key/tasks/apt_key_binary.yml b/test/integration/targets/apt_key/tasks/apt_key_binary.yml
new file mode 100644
index 00000000000000..9f55b90dd2acea
--- /dev/null
+++ b/test/integration/targets/apt_key/tasks/apt_key_binary.yml
@@ -0,0 +1,13 @@
+---
+
+- name: Ensure import of binary key downloaded using URLs works
+ apt_key: url=https://packages.cloud.google.com/apt/doc/apt-key.gpg
+ # replace the above URL to the following, after the pull request is accepted
+ # apt_key: url=https://github.com/ansible/ansible/tree/devel/test/integration/targets/apt_key/samples/apt-key-example-binary.gpg
+ register: apt_key_binary_test
+
+- name: Validate the results
+ assert:
+ that:
+ - 'apt_key_binary_test.changed is defined'
+ - 'apt_key_binary_test.changed'
diff --git a/test/integration/targets/apt_key/tasks/main.yml b/test/integration/targets/apt_key/tasks/main.yml
index acafd3edda33a2..f5292d3a71e17b 100644
--- a/test/integration/targets/apt_key/tasks/main.yml
+++ b/test/integration/targets/apt_key/tasks/main.yml
@@ -29,3 +29,6 @@
- import_tasks: 'file.yml'
when: ansible_distribution in ('Ubuntu', 'Debian')
+
+- import_tasks: 'apt_key_binary.yml'
+ when: ansible_distribution in ('Ubuntu', 'Debian')

130
ansible-core.spec Normal file
View File

@ -0,0 +1,130 @@
Name: ansible-core
Version: 2.11.0
Release: 2mamba
Summary: A radically simple IT automation system
Group: System/Libraries
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: https://www.ansible.com/
Source: https://pypi.debian.net/ansible-core/ansible-core-%{version}.tar.gz
Patch0: ansible-base-2.11.0-upstream-gpg_key-fix-for-binary-keys.patch
License: GPL
## AUTOBUILDREQ-BEGIN
BuildRequires: libpython3-devel
BuildRequires: python3.7dist(cryptography)
BuildRequires: python3.7dist(jinja2)
BuildRequires: python3.7dist(packaging)
BuildRequires: python3.7dist(pyyaml)
BuildRequires: python3.7dist(resolvelib)
## AUTOBUILDREQ-END
Provides: ansible-base
Obsoletes: ansible-base <= 2.11.0-1mamba
%description
%{summary}.
%if 0%{?with_pyver}
%pyver_package
%endif
%prep
%setup -q -n ansible-core-%{version}
%patch0 -p1
%build
export ANSIBLE_SKIP_CONFLICT_CHECK=1
CFLAGS="%{optflags}" %{__python3} setup.py build
%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
export ANSIBLE_SKIP_CONFLICT_CHECK=1
%{__python3} setup.py install \
-O1 --skip-build \
--root="%{buildroot}" \
--install-headers=%{python3_inc} \
--install-lib=%{python3_sitearch} \
--record=%{name}.filelist
sed -i "\,\.egg-info/,d;s,.*/man/.*,&.gz," %{name}.filelist
sed -i "/ /d" %{name}.filelist
%files %{?pyappend} -f %{name}.filelist
%defattr(-,root,root)
%{python3_sitearch}/ansible_test/_data/injector/ansible-inventory
%dir %{python3_sitearch}/ansible_core-%{version}-py*.egg-info
%{python3_sitearch}/ansible_core-%{version}-py*.egg-info/*
%doc COPYING
%changelog
* Sat May 22 2021 Silvan Calarco <silvan.calarco@mambasoft.it> 2.11.0-2mamba
- renamed from ansible-base to ansible-core; added upstream patch to fix gpg_key with binary keys
* Wed May 19 2021 Silvan Calarco <silvan.calarco@mambasoft.it> 2.11.0-1mamba
- update to 2.11.0
* Wed May 05 2021 Automatic Build System <autodist@mambasoft.it> 2.10.9-1mamba
- automatic version update by autodist
* Wed Apr 14 2021 Automatic Build System <autodist@mambasoft.it> 2.10.8-1mamba
- automatic version update by autodist
* Wed Mar 17 2021 Automatic Build System <autodist@mambasoft.it> 2.10.7-1mamba
- automatic version update by autodist
* Sat Feb 20 2021 Automatic Build System <autodist@mambasoft.it> 2.10.6-1mamba
- automatic version update by autodist
* Tue Jan 19 2021 Automatic Build System <autodist@mambasoft.it> 2.10.5-1mamba
- automatic version update by autodist
* Tue Dec 15 2020 Automatic Build System <autodist@mambasoft.it> 2.10.4-1mamba
- automatic version update by autodist
* Sun Nov 08 2020 Silvan Calarco <silvan.calarco@mambasoft.it> 2.10.3-3mamba
- resource from pypi and renamed to ansible-base
* Sun Nov 08 2020 Silvan Calarco <silvan.calarco@mambasoft.it> 2.10.3-2mamba
- switch back to github repository providing full version with bin tools
* Thu Nov 05 2020 Automatic Build System <autodist@mambasoft.it> 2.10.3-1mamba
- automatic version update by autodist
* Wed Oct 14 2020 Automatic Build System <autodist@mambasoft.it> 2.10.1-1mamba
- automatic version update by autodist
* Sat Sep 26 2020 Automatic Build System <autodist@mambasoft.it> 2.10.0-1mamba
- automatic version update by autodist
* Tue Sep 08 2020 Silvan Calarco <silvan.calarco@mambasoft.it> 2.9.13-2mamba
- rebuilt with python3
* Fri Sep 04 2020 Automatic Build System <autodist@mambasoft.it> 2.9.13-1mamba
- automatic version update by autodist
* Wed Aug 12 2020 Automatic Build System <autodist@mambasoft.it> 2.9.12-1mamba
- automatic version update by autodist
* Tue Jul 21 2020 Automatic Build System <autodist@mambasoft.it> 2.9.11-1mamba
- automatic version update by autodist
* Sun Jun 21 2020 Automatic Build System <autodist@mambasoft.it> 2.9.10-1mamba
- automatic version update by autodist
* Wed May 13 2020 Automatic Build System <autodist@mambasoft.it> 2.9.9-1mamba
- automatic version update by autodist
* Mon Apr 20 2020 Automatic Build System <autodist@mambasoft.it> 2.9.7-1mamba
- automatic version update by autodist
* Thu Mar 12 2020 Automatic Build System <autodist@mambasoft.it> 2.9.6-1mamba
- automatic version update by autodist
* Fri Feb 14 2020 Automatic Build System <autodist@mambasoft.it> 2.9.5-1mamba
- automatic version update by autodist
* Sun Feb 09 2020 Silvan Calarco <silvan.calarco@mambasoft.it> 2.9.4-1mamba
- update to 2.9.4
* Thu May 03 2018 Silvan Calarco <silvan.calarco@mambasoft.it> 2.5.2-1mamba
- package created using the webbuild interface