Rebase patches and remove upstreamed ones

Relates: https://github.com/ansible/ansible/pull/81395
This commit is contained in:
Maxwell G 2023-08-18 00:17:28 +00:00
parent 66164773e0
commit 8d01926207
No known key found for this signature in database
GPG Key ID: F79E4E25E8C661F8
4 changed files with 26 additions and 211 deletions

View File

@ -1,4 +1,4 @@
From 734f38b2594692707d1fd3cbcfc8dc8a677f4ee3 Mon Sep 17 00:00:00 2001 From 3e76a568f0b63a0faa336125448ee284549da9da Mon Sep 17 00:00:00 2001
From: Maxwell G <maxwell@gtmx.me> From: Maxwell G <maxwell@gtmx.me>
Date: Fri, 21 Apr 2023 07:29:10 -0500 Date: Fri, 21 Apr 2023 07:29:10 -0500
Subject: [PATCH] Add GALAXY_COLLECTIONS_PATH_WARNINGS option. (#78487) Subject: [PATCH] Add GALAXY_COLLECTIONS_PATH_WARNINGS option. (#78487)
@ -8,16 +8,18 @@ Subject: [PATCH] Add GALAXY_COLLECTIONS_PATH_WARNINGS option. (#78487)
This allows users to disable warnings from `ansible-galaxy collection This allows users to disable warnings from `ansible-galaxy collection
install` about `--collections-path` missing from Ansible's configured install` about `--collections-path` missing from Ansible's configured
collections_paths. collections_paths.
(cherry picked from commit 734f38b2594692707d1fd3cbcfc8dc8a677f4ee3)
--- ---
.../fragments/78487-galaxy-collections-path-warnings.yml | 6 ++++++ .../fragments/78487-galaxy-collections-path-warnings.yml | 6 ++++++
lib/ansible/cli/galaxy.py | 5 ++++- lib/ansible/cli/galaxy.py | 2 +-
lib/ansible/config/base.yml | 9 +++++++++ lib/ansible/config/base.yml | 9 +++++++++
3 files changed, 19 insertions(+), 1 deletion(-) 3 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 changelogs/fragments/78487-galaxy-collections-path-warnings.yml create mode 100644 changelogs/fragments/78487-galaxy-collections-path-warnings.yml
diff --git a/changelogs/fragments/78487-galaxy-collections-path-warnings.yml b/changelogs/fragments/78487-galaxy-collections-path-warnings.yml diff --git a/changelogs/fragments/78487-galaxy-collections-path-warnings.yml b/changelogs/fragments/78487-galaxy-collections-path-warnings.yml
new file mode 100644 new file mode 100644
index 00000000000000..4702e94f961d82 index 0000000000..4702e94f96
--- /dev/null --- /dev/null
+++ b/changelogs/fragments/78487-galaxy-collections-path-warnings.yml +++ b/changelogs/fragments/78487-galaxy-collections-path-warnings.yml
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
@ -28,23 +30,20 @@ index 00000000000000..4702e94f961d82
+ given by ``ansible-galaxy collection install`` when installing a collection + given by ``ansible-galaxy collection install`` when installing a collection
+ to a path that isn't in the configured collection paths. + to a path that isn't in the configured collection paths.
diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py
index fc88137ff63604..0deb0331a582b9 100755 index d8a7c03756..3649be56f2 100755
--- a/lib/ansible/cli/galaxy.py --- a/lib/ansible/cli/galaxy.py
+++ b/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py
@@ -1393,7 +1393,10 @@ def _execute_install_collection( @@ -1401,7 +1401,7 @@ class GalaxyCLI(CLI):
upgrade = context.CLIARGS.get('upgrade', False) managed_paths = set(validate_collection_path(p) for p in C.COLLECTIONS_PATHS)
read_req_paths = set(validate_collection_path(p) for p in AnsibleCollectionConfig.collection_paths)
collections_path = C.COLLECTIONS_PATHS - unexpected_path = not any(p.startswith(path) for p in managed_paths)
- if len([p for p in collections_path if p.startswith(path)]) == 0: + unexpected_path = C.GALAXY_COLLECTIONS_PATH_WARNING and not any(p.startswith(path) for p in managed_paths)
+ if ( if unexpected_path and any(p.startswith(path) for p in read_req_paths):
+ C.GALAXY_COLLECTIONS_PATH_WARNING display.warning(
+ and len([p for p in collections_path if p.startswith(path)]) == 0 f"The specified collections path '{path}' appears to be part of the pip Ansible package. "
+ ):
display.warning("The specified collections path '%s' is not part of the configured Ansible "
"collections paths '%s'. The installed collection will not be picked up in an Ansible "
"run, unless within a playbook-adjacent collections directory." % (to_text(path), to_text(":".join(collections_path))))
diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml
index 052a8f0834e4ca..206deb76d2e916 100644 index 052a8f0834..206deb76d2 100644
--- a/lib/ansible/config/base.yml --- a/lib/ansible/config/base.yml
+++ b/lib/ansible/config/base.yml +++ b/lib/ansible/config/base.yml
@@ -1366,6 +1366,15 @@ GALAXY_COLLECTION_SKELETON_IGNORE: @@ -1366,6 +1366,15 @@ GALAXY_COLLECTION_SKELETON_IGNORE:
@ -63,3 +62,6 @@ index 052a8f0834e4ca..206deb76d2e916 100644
# TODO: unused? # TODO: unused?
#GALAXY_SCMS: #GALAXY_SCMS:
# name: Galaxy SCMS # name: Galaxy SCMS
--
2.41.0

View File

@ -20,20 +20,18 @@ License: GPL-3.0-or-later AND BSD-2-Clause AND PSF-2.0 AND MIT AND Apache-2.0
Source0: https://github.com/ansible/ansible/archive/v%{uversion}/%{name}-%{uversion}.tar.gz Source0: https://github.com/ansible/ansible/archive/v%{uversion}/%{name}-%{uversion}.tar.gz
Source1: https://github.com/ansible/ansible-documentation/archive/v%{uversion}/ansible-documentation-%{uversion}.tar.gz Source1: https://github.com/ansible/ansible-documentation/archive/v%{uversion}/ansible-documentation-%{uversion}.tar.gz
Source2: build_manpages.py
Patch: https://github.com/ansible/ansible/commit/734f38b2594692707d1fd3cbcfc8dc8a677f4ee3.patch#/GALAXY_COLLECTIONS_PATH_WARNINGS.patch # Add GALAXY_COLLECTIONS_PATH_WARNINGS option. (#78487)
# urls - remove deprecated client key calls (#80751) # Backport of https://github.com/ansible/ansible/pull/78487.
# This is needed for Python 3.12, but we apply it unconditionally so Patch: GALAXY_COLLECTIONS_PATH_WARNINGS.patch
# controllers running on older Fedora versions can still work with Python 3.12
# F39+ targets.
Patch: https://github.com/ansible/ansible/commit/0df794e5a4fe4597ee65b0d492fbf0d0989d5ca0.patch#/urls-remove-deprecated-client-key-calls.patch
# These patches are only applied on Rawhide to enable support for Python 3.12 # These patches are only applied on Rawhide to enable support for Python 3.12
# See https://bugzilla.redhat.com/2196539 # See https://bugzilla.redhat.com/2196539
# #
# Essential # # Essential #
# add Python 3.12 support to ansible-test (#80834) # add Python 3.12 support to ansible-test (#80834)
Patch5000: https://github.com/ansible/ansible/pull/80834.patch#/support-Python-3.12-in-ansible-test.patch # Slightly modified version of https://github.com/ansible/ansible/pull/80834
Patch5000: support-Python-3.12-in-ansible-test.patch
# Fix unit test asserts (#80500) # Fix unit test asserts (#80500)
Patch5001: https://github.com/ansible/ansible/commit/3ec828703f020551241b4169f6a3f07c701e240a.patch#/fix-unit-test-asserts.patch Patch5001: https://github.com/ansible/ansible/commit/3ec828703f020551241b4169f6a3f07c701e240a.patch#/fix-unit-test-asserts.patch
# Fix galaxy CLI unit test assertions (#80504) # Fix galaxy CLI unit test assertions (#80504)
@ -268,7 +266,7 @@ install -Dpm 0644 licenses/* -t %{buildroot}%{_pkglicensedir}
%files -f %{pyproject_files} %files -f %{pyproject_files}
%license COPYING %license COPYING
%license %{_pkglicensedir}/{Apache-License,MIT-license,PSF-license,simplified_bsd}.txt %license %{_pkglicensedir}/{Apache-License,MIT-license,PSF-license,simplified_bsd}.txt
%doc README.rst changelogs/CHANGELOG-v2.1?.rst %doc README.md changelogs/CHANGELOG-v2.1?.rst
%dir %{_sysconfdir}/ansible/ %dir %{_sysconfdir}/ansible/
%config(noreplace) %{_sysconfdir}/ansible/* %config(noreplace) %{_sysconfdir}/ansible/*
%{_bindir}/ansible* %{_bindir}/ansible*

View File

@ -3,8 +3,6 @@ From: s-hertel <19572925+s-hertel@users.noreply.github.com>
Date: Tue, 16 May 2023 13:48:12 -0400 Date: Tue, 16 May 2023 13:48:12 -0400
Subject: [PATCH] add Python 3.12 support to ansible-test Subject: [PATCH] add Python 3.12 support to ansible-test
skip docs build sanity test on Python 3.12 until aiohttp has a compatible version
skip Python 3.12 tests on windows/networking until the default container is skip Python 3.12 tests on windows/networking until the default container is
updated updated
@ -12,14 +10,12 @@ add interpreter fallback?
--- ---
lib/ansible/config/base.yml | 1 + lib/ansible/config/base.yml | 1 +
setup.cfg | 1 + setup.cfg | 1 +
.../minimum-build-constraints.txt | 4 +++-
test/lib/ansible_test/_data/requirements/ansible-test.txt | 2 +- test/lib/ansible_test/_data/requirements/ansible-test.txt | 2 +-
test/lib/ansible_test/_internal/bootstrap.py | 4 ++++ test/lib/ansible_test/_internal/bootstrap.py | 4 ++++
test/lib/ansible_test/_internal/coverage_util.py | 2 +- test/lib/ansible_test/_internal/coverage_util.py | 2 +-
test/lib/ansible_test/_internal/python_requirements.py | 4 ++-- test/lib/ansible_test/_internal/python_requirements.py | 4 ++--
test/lib/ansible_test/_util/target/common/constants.py | 1 + test/lib/ansible_test/_util/target/common/constants.py | 1 +
test/lib/ansible_test/_util/target/setup/bootstrap.sh | 2 +- test/lib/ansible_test/_util/target/setup/bootstrap.sh | 2 +-
test/sanity/code-smell/docs-build.json | 1 +
10 files changed, 16 insertions(+), 6 deletions(-) 10 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml diff --git a/lib/ansible/config/base.yml b/lib/ansible/config/base.yml
@ -46,22 +42,6 @@ index e020ee3b15caea..af79337f91e9de 100644
Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3 :: Only
Topic :: System :: Installation/Setup Topic :: System :: Installation/Setup
Topic :: System :: Systems Administration Topic :: System :: Systems Administration
diff --git a/test/integration/targets/canonical-pep517-self-packaging/minimum-build-constraints.txt b/test/integration/targets/canonical-pep517-self-packaging/minimum-build-constraints.txt
index 3ba47aeb4b69b4..765ca85c17d8d3 100644
--- a/test/integration/targets/canonical-pep517-self-packaging/minimum-build-constraints.txt
+++ b/test/integration/targets/canonical-pep517-self-packaging/minimum-build-constraints.txt
@@ -2,8 +2,10 @@
setuptools == 57.0.0; python_version == "3.9" or python_version == "3.10"
# Lowest supporting Python 3.11:
-setuptools == 60.0.0; python_version >= "3.11"
+setuptools == 60.0.0; python_version == "3.11"
+# Lowest supporting Python 3.12:
+setuptools == 66.1.0; python_version >= "3.12"
# An arbitrary old version that was released before Python 3.9.0:
wheel == 0.33.6
diff --git a/test/lib/ansible_test/_data/requirements/ansible-test.txt b/test/lib/ansible_test/_data/requirements/ansible-test.txt diff --git a/test/lib/ansible_test/_data/requirements/ansible-test.txt b/test/lib/ansible_test/_data/requirements/ansible-test.txt
index f7cb9c27780856..8b1772fb915bc3 100644 index f7cb9c27780856..8b1772fb915bc3 100644
--- a/test/lib/ansible_test/_data/requirements/ansible-test.txt --- a/test/lib/ansible_test/_data/requirements/ansible-test.txt
@ -138,14 +118,3 @@ index ea17dad38751cc..367dcfcb4ce17e 100644
;; ;;
esac esac
diff --git a/test/sanity/code-smell/docs-build.json b/test/sanity/code-smell/docs-build.json
index a43fa923b2b002..eedeca35dcba20 100644
--- a/test/sanity/code-smell/docs-build.json
+++ b/test/sanity/code-smell/docs-build.json
@@ -1,5 +1,6 @@
{
"disabled": true,
+ "maximum_python_version": "3.11",
"no_targets": true,
"output": "path-line-column-message"
}

View File

@ -1,154 +0,0 @@
From 0df794e5a4fe4597ee65b0d492fbf0d0989d5ca0 Mon Sep 17 00:00:00 2001
From: Jordan Borean <jborean93@gmail.com>
Date: Thu, 18 May 2023 08:17:25 +1000
Subject: [PATCH] urls - remove deprecated client key calls (#80751)
---
.../fragments/urls-client-cert-py12.yml | 2 ++
lib/ansible/module_utils/urls.py | 28 +++++++++++--------
test/units/module_utils/urls/test_Request.py | 14 ++++------
3 files changed, 24 insertions(+), 20 deletions(-)
create mode 100644 changelogs/fragments/urls-client-cert-py12.yml
diff --git a/changelogs/fragments/urls-client-cert-py12.yml b/changelogs/fragments/urls-client-cert-py12.yml
new file mode 100644
index 00000000000000..aab129ed96e94b
--- /dev/null
+++ b/changelogs/fragments/urls-client-cert-py12.yml
@@ -0,0 +1,2 @@
+bugfixes:
+- urls.py - fixed cert_file and key_file parameters when running on Python 3.12 - https://github.com/ansible/ansible/issues/80490
diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py
index 0e5fbb74c4fae2..0197d86e1033b2 100644
--- a/lib/ansible/module_utils/urls.py
+++ b/lib/ansible/module_utils/urls.py
@@ -535,15 +535,18 @@ def __init__(self, message, import_traceback, module=None):
UnixHTTPSConnection = None
if hasattr(httplib, 'HTTPSConnection') and hasattr(urllib_request, 'HTTPSHandler'):
class CustomHTTPSConnection(httplib.HTTPSConnection): # type: ignore[no-redef]
- def __init__(self, *args, **kwargs):
+ def __init__(self, client_cert=None, client_key=None, *args, **kwargs):
httplib.HTTPSConnection.__init__(self, *args, **kwargs)
self.context = None
if HAS_SSLCONTEXT:
self.context = self._context
elif HAS_URLLIB3_PYOPENSSLCONTEXT:
self.context = self._context = PyOpenSSLContext(PROTOCOL)
- if self.context and self.cert_file:
- self.context.load_cert_chain(self.cert_file, self.key_file)
+
+ self._client_cert = client_cert
+ self._client_key = client_key
+ if self.context and self._client_cert:
+ self.context.load_cert_chain(self._client_cert, self._client_key)
def connect(self):
"Connect to a host on a given (SSL) port."
@@ -564,10 +567,10 @@ def connect(self):
if HAS_SSLCONTEXT or HAS_URLLIB3_PYOPENSSLCONTEXT:
self.sock = self.context.wrap_socket(sock, server_hostname=server_hostname)
elif HAS_URLLIB3_SSL_WRAP_SOCKET:
- self.sock = ssl_wrap_socket(sock, keyfile=self.key_file, cert_reqs=ssl.CERT_NONE, # pylint: disable=used-before-assignment
- certfile=self.cert_file, ssl_version=PROTOCOL, server_hostname=server_hostname)
+ self.sock = ssl_wrap_socket(sock, keyfile=self._client_key, cert_reqs=ssl.CERT_NONE, # pylint: disable=used-before-assignment
+ certfile=self._client_cert, ssl_version=PROTOCOL, server_hostname=server_hostname)
else:
- self.sock = ssl.wrap_socket(sock, keyfile=self.key_file, certfile=self.cert_file, ssl_version=PROTOCOL)
+ self.sock = ssl.wrap_socket(sock, keyfile=self._client_key, certfile=self._client_cert, ssl_version=PROTOCOL)
class CustomHTTPSHandler(urllib_request.HTTPSHandler): # type: ignore[no-redef]
@@ -602,10 +605,6 @@ def https_open(self, req):
return self.do_open(self._build_https_connection, req)
def _build_https_connection(self, host, **kwargs):
- kwargs.update({
- 'cert_file': self.client_cert,
- 'key_file': self.client_key,
- })
try:
kwargs['context'] = self._context
except AttributeError:
@@ -613,7 +612,7 @@ def _build_https_connection(self, host, **kwargs):
if self._unix_socket:
return UnixHTTPSConnection(self._unix_socket)(host, **kwargs)
if not HAS_SSLCONTEXT:
- return CustomHTTPSConnection(host, **kwargs)
+ return CustomHTTPSConnection(host, client_cert=self.client_cert, client_key=self.client_key, **kwargs)
return httplib.HTTPSConnection(host, **kwargs)
@contextmanager
@@ -979,7 +978,7 @@ def atexit_remove_file(filename):
pass
-def make_context(cafile=None, cadata=None, ciphers=None, validate_certs=True):
+def make_context(cafile=None, cadata=None, ciphers=None, validate_certs=True, client_cert=None, client_key=None):
if ciphers is None:
ciphers = []
@@ -1006,6 +1005,9 @@ def make_context(cafile=None, cadata=None, ciphers=None, validate_certs=True):
if ciphers:
context.set_ciphers(':'.join(map(to_native, ciphers)))
+ if client_cert:
+ context.load_cert_chain(client_cert, keyfile=client_key)
+
return context
@@ -1514,6 +1516,8 @@ def open(self, method, url, data=None, headers=None, use_proxy=None,
cadata=cadata,
ciphers=ciphers,
validate_certs=validate_certs,
+ client_cert=client_cert,
+ client_key=client_key,
)
handlers.append(HTTPSClientAuthHandler(client_cert=client_cert,
client_key=client_key,
diff --git a/test/units/module_utils/urls/test_Request.py b/test/units/module_utils/urls/test_Request.py
index d2c4ea38012a49..a8bc3a0b6bde3b 100644
--- a/test/units/module_utils/urls/test_Request.py
+++ b/test/units/module_utils/urls/test_Request.py
@@ -33,6 +33,7 @@ def install_opener_mock(mocker):
def test_Request_fallback(urlopen_mock, install_opener_mock, mocker):
here = os.path.dirname(__file__)
pem = os.path.join(here, 'fixtures/client.pem')
+ client_key = os.path.join(here, 'fixtures/client.key')
cookies = cookiejar.CookieJar()
request = Request(
@@ -46,8 +47,8 @@ def test_Request_fallback(urlopen_mock, install_opener_mock, mocker):
http_agent='ansible-tests',
force_basic_auth=True,
follow_redirects='all',
- client_cert='/tmp/client.pem',
- client_key='/tmp/client.key',
+ client_cert=pem,
+ client_key=client_key,
cookies=cookies,
unix_socket='/foo/bar/baz.sock',
ca_path=pem,
@@ -68,8 +69,8 @@ def test_Request_fallback(urlopen_mock, install_opener_mock, mocker):
call(None, 'ansible-tests'), # http_agent
call(None, True), # force_basic_auth
call(None, 'all'), # follow_redirects
- call(None, '/tmp/client.pem'), # client_cert
- call(None, '/tmp/client.key'), # client_key
+ call(None, pem), # client_cert
+ call(None, client_key), # client_key
call(None, cookies), # cookies
call(None, '/foo/bar/baz.sock'), # unix_socket
call(None, pem), # ca_path
@@ -358,10 +359,7 @@ def test_Request_open_client_cert(urlopen_mock, install_opener_mock):
assert ssl_handler.client_cert == client_cert
assert ssl_handler.client_key == client_key
- https_connection = ssl_handler._build_https_connection('ansible.com')
-
- assert https_connection.key_file == client_key
- assert https_connection.cert_file == client_cert
+ ssl_handler._build_https_connection('ansible.com')
def test_Request_open_cookies(urlopen_mock, install_opener_mock):