Accepting request 1152011 from systemsmanagement:saltstack

- Fix problematic tests and allow smooth tests executions on containers
- Added:
  * fix-problematic-tests-and-allow-smooth-tests-executi.patch 

- Discover Ansible playbook files as "*.yml" or "*.yaml" files (bsc#1211888)
- Added:
  * discover-both-.yml-and-.yaml-playbooks-bsc-1211888.patch

- Extend dependencies for python3-salt-testsuite and python3-salt packages
- Improve Salt and testsuite packages multibuild

- Enable multibuilld and create test flavor
- Additionally we require python-mock just for older Python versions.

- Remove python-boto dependency for the python3-salt-testsuite package for Tumbleweed
- Rename salt-tests to python3-salt-testsuite

OBS-URL: https://build.opensuse.org/request/show/1152011
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=144
This commit is contained in:
Ana Guerrero 2024-02-27 21:45:29 +00:00 committed by Git OBS Bridge
commit e632e7e3be
6 changed files with 3017 additions and 24 deletions

View File

@ -1 +1 @@
d0c2f35ff4a0b21786b20c884cbb191ad2e63904
32a086961fa3b3b60287a78169b2ad66a000073a

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<flavor>testsuite</flavor>
</multibuild>

View File

@ -0,0 +1,188 @@
From 05fbd376090c5d7f997c510db0abb62be54d6d40 Mon Sep 17 00:00:00 2001
From: Johannes Hahn <johannes.hahn@suse.com>
Date: Tue, 20 Feb 2024 15:38:08 +0100
Subject: [PATCH] Discover both *.yml and *.yaml playbooks (bsc#1211888)
Allow for 'playbook_extension' to be either a string or a tuple and
change the default behavior to discover both.
---
changelog/66048.changed.md | 1 +
salt/modules/ansiblegate.py | 46 +++++++++----------
.../pytests/unit/modules/test_ansiblegate.py | 3 ++
.../example_playbooks/playbook1.yaml | 5 ++
4 files changed, 30 insertions(+), 25 deletions(-)
create mode 100644 changelog/66048.changed.md
create mode 100644 tests/unit/files/playbooks/example_playbooks/playbook1.yaml
diff --git a/changelog/66048.changed.md b/changelog/66048.changed.md
new file mode 100644
index 0000000000..b042e0d313
--- /dev/null
+++ b/changelog/66048.changed.md
@@ -0,0 +1 @@
+Ansiblegate discover_playbooks was changed to find playbooks as either *.yml or *.yaml files
diff --git a/salt/modules/ansiblegate.py b/salt/modules/ansiblegate.py
index 2f60a7444f..920c374e5a 100644
--- a/salt/modules/ansiblegate.py
+++ b/salt/modules/ansiblegate.py
@@ -111,7 +111,7 @@ def __virtual__():
if proc.returncode != 0:
return (
False,
- "Failed to get the listing of ansible modules:\n{}".format(proc.stderr),
+ f"Failed to get the listing of ansible modules:\n{proc.stderr}",
)
module_funcs = dir(sys.modules[__name__])
@@ -240,7 +240,7 @@ def call(module, *args, **kwargs):
_kwargs = {k: v for (k, v) in kwargs.items() if not k.startswith("__pub")}
for key, value in _kwargs.items():
- module_args.append("{}={}".format(key, salt.utils.json.dumps(value)))
+ module_args.append(f"{key}={salt.utils.json.dumps(value)}")
with NamedTemporaryFile(mode="w") as inventory:
@@ -367,15 +367,15 @@ def playbooks(
if diff:
command.append("--diff")
if isinstance(extra_vars, dict):
- command.append("--extra-vars='{}'".format(json.dumps(extra_vars)))
+ command.append(f"--extra-vars='{json.dumps(extra_vars)}'")
elif isinstance(extra_vars, str) and extra_vars.startswith("@"):
- command.append("--extra-vars={}".format(extra_vars))
+ command.append(f"--extra-vars={extra_vars}")
if flush_cache:
command.append("--flush-cache")
if inventory:
- command.append("--inventory={}".format(inventory))
+ command.append(f"--inventory={inventory}")
if limit:
- command.append("--limit={}".format(limit))
+ command.append(f"--limit={limit}")
if list_hosts:
command.append("--list-hosts")
if list_tags:
@@ -383,25 +383,25 @@ def playbooks(
if list_tasks:
command.append("--list-tasks")
if module_path:
- command.append("--module-path={}".format(module_path))
+ command.append(f"--module-path={module_path}")
if skip_tags:
- command.append("--skip-tags={}".format(skip_tags))
+ command.append(f"--skip-tags={skip_tags}")
if start_at_task:
- command.append("--start-at-task={}".format(start_at_task))
+ command.append(f"--start-at-task={start_at_task}")
if syntax_check:
command.append("--syntax-check")
if tags:
- command.append("--tags={}".format(tags))
+ command.append(f"--tags={tags}")
if playbook_kwargs:
for key, value in playbook_kwargs.items():
key = key.replace("_", "-")
if value is True:
- command.append("--{}".format(key))
+ command.append(f"--{key}")
elif isinstance(value, str):
- command.append("--{}={}".format(key, value))
+ command.append(f"--{key}={value}")
elif isinstance(value, dict):
- command.append("--{}={}".format(key, json.dumps(value)))
- command.append("--forks={}".format(forks))
+ command.append(f"--{key}={json.dumps(value)}")
+ command.append(f"--forks={forks}")
cmd_kwargs = {
"env": {
"ANSIBLE_STDOUT_CALLBACK": "json",
@@ -502,7 +502,7 @@ def discover_playbooks(
List of paths to discover playbooks from.
:param playbook_extension:
- File extension of playbooks file to search for. Default: "yml"
+ File extension(s) of playbook files to search for, can be a string or tuple of strings. Default: (".yml", ".yaml")
:param hosts_filename:
Filename of custom playbook inventory to search for. Default: "hosts"
@@ -533,19 +533,17 @@ def discover_playbooks(
)
if not playbook_extension:
- playbook_extension = "yml"
+ playbook_extension = (".yml", ".yaml")
if not hosts_filename:
hosts_filename = "hosts"
if path:
if not os.path.isabs(path):
raise CommandExecutionError(
- "The given path is not an absolute path: {}".format(path)
+ f"The given path is not an absolute path: {path}"
)
if not os.path.isdir(path):
- raise CommandExecutionError(
- "The given path is not a directory: {}".format(path)
- )
+ raise CommandExecutionError(f"The given path is not a directory: {path}")
return {
path: _explore_path(path, playbook_extension, hosts_filename, syntax_check)
}
@@ -573,7 +571,7 @@ def _explore_path(path, playbook_extension, hosts_filename, syntax_check):
# Check files in the given path
for _f in os.listdir(path):
_path = os.path.join(path, _f)
- if os.path.isfile(_path) and _path.endswith("." + playbook_extension):
+ if os.path.isfile(_path) and _path.endswith(playbook_extension):
ret[_f] = {"fullpath": _path}
# Check for custom inventory file
if os.path.isfile(os.path.join(path, hosts_filename)):
@@ -584,9 +582,7 @@ def _explore_path(path, playbook_extension, hosts_filename, syntax_check):
# Check files in the 1st level of subdirectories
for _f2 in os.listdir(_path):
_path2 = os.path.join(_path, _f2)
- if os.path.isfile(_path2) and _path2.endswith(
- "." + playbook_extension
- ):
+ if os.path.isfile(_path2) and _path2.endswith(playbook_extension):
ret[os.path.join(_f, _f2)] = {"fullpath": _path2}
# Check for custom inventory file
if os.path.isfile(os.path.join(_path, hosts_filename)):
@@ -599,7 +595,7 @@ def _explore_path(path, playbook_extension, hosts_filename, syntax_check):
)
except Exception as exc:
raise CommandExecutionError(
- "There was an exception while discovering playbooks: {}".format(exc)
+ f"There was an exception while discovering playbooks: {exc}"
)
# Run syntax check validation
diff --git a/tests/pytests/unit/modules/test_ansiblegate.py b/tests/pytests/unit/modules/test_ansiblegate.py
index 6201809c22..272da721bf 100644
--- a/tests/pytests/unit/modules/test_ansiblegate.py
+++ b/tests/pytests/unit/modules/test_ansiblegate.py
@@ -198,6 +198,9 @@ def test_ansible_discover_playbooks_single_path():
assert ret[playbooks_dir]["playbook1.yml"] == {
"fullpath": os.path.join(playbooks_dir, "playbook1.yml")
}
+ assert ret[playbooks_dir]["playbook1.yaml"] == {
+ "fullpath": os.path.join(playbooks_dir, "playbook1.yaml")
+ }
assert ret[playbooks_dir]["example-playbook2/site.yml"] == {
"fullpath": os.path.join(playbooks_dir, "example-playbook2/site.yml"),
"custom_inventory": os.path.join(playbooks_dir, "example-playbook2/hosts"),
diff --git a/tests/unit/files/playbooks/example_playbooks/playbook1.yaml b/tests/unit/files/playbooks/example_playbooks/playbook1.yaml
new file mode 100644
index 0000000000..e258a101e1
--- /dev/null
+++ b/tests/unit/files/playbooks/example_playbooks/playbook1.yaml
@@ -0,0 +1,5 @@
+---
+- hosts: all
+ gather_facts: false
+ tasks:
+ - ping:
--
2.43.1

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,37 @@
-------------------------------------------------------------------
Mon Feb 26 10:43:37 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
- Fix problematic tests and allow smooth tests executions on containers
- Added:
* fix-problematic-tests-and-allow-smooth-tests-executi.patch
-------------------------------------------------------------------
Wed Feb 21 12:21:03 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
- Discover Ansible playbook files as "*.yml" or "*.yaml" files (bsc#1211888)
- Added:
* discover-both-.yml-and-.yaml-playbooks-bsc-1211888.patch
-------------------------------------------------------------------
Tue Feb 20 12:58:58 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
- Extend dependencies for python3-salt-testsuite and python3-salt packages
- Improve Salt and testsuite packages multibuild
-------------------------------------------------------------------
Thu Feb 8 12:17:39 UTC 2024 - Yeray Gutiérrez Cedrés <yeray.gutierrez@suse.com>
- Enable multibuilld and create test flavor
- Additionally we require python-mock just for older Python versions.
-------------------------------------------------------------------
Mon Feb 5 09:55:33 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>
- Remove python-boto dependency for the python3-salt-testsuite package for Tumbleweed
- Rename salt-tests to python3-salt-testsuite
-------------------------------------------------------------------
Thu Feb 1 12:19:06 UTC 2024 - Pablo Suárez Hernández <pablo.suarezhernandez@suse.com>

119
salt.spec
View File

@ -16,6 +16,13 @@
#
%global debug_package %{nil}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "testsuite"
%define psuffix -test
%else
%define psuffix %{nil}
%endif
%if 0%{?suse_version} > 1210 || 0%{?rhel} >= 7 || 0%{?fedora} >=28
%bcond_without systemd
%else
@ -31,11 +38,10 @@
%bcond_with fish_completion
%bcond_with zsh_completion
%endif
%bcond_with test
%bcond_without docs
%bcond_with builddocs
Name: salt
Name: salt%{psuffix}
Version: 3006.0
Release: 0
Summary: A parallel remote execution system
@ -343,6 +349,10 @@ Patch97: fixed-keyerror-in-logs-when-running-a-state-that-fai.patch
Patch98: improve-pip-target-override-condition-with-venv_pip_.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/65819
Patch99: allow-kwargs-for-fileserver-roots-update-bsc-1218482.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66048
Patch100: discover-both-.yml-and-.yaml-playbooks-bsc-1211888.patch
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66130
Patch101: fix-problematic-tests-and-allow-smooth-tests-executi.patch
### IMPORTANT: The line below is used as a snippet marker. Do not touch it.
@ -424,6 +434,8 @@ malleable. Salt accomplishes this via its ability to handle larger loads of
information, and not just dozens, but hundreds or even thousands of individual
servers, handle them quickly and through a simple and manageable interface.
%if "%{flavor}" != "testsuite"
%package -n python3-salt
Summary: python3 library for salt
Group: System/Management
@ -464,7 +476,7 @@ BuildRequires: python3-packaging
# requirements/zeromq.txt
%if %{with test}
BuildRequires: python3-boto >= 2.32.1
BuildRequires: python3-mock
BuildRequires: %{python3-mock if %python-base < 3.8}
BuildRequires: python3-moto >= 0.3.6
BuildRequires: python3-pip
BuildRequires: python3-salt-testing >= 2015.2.16
@ -533,6 +545,12 @@ Recommends: python3-netaddr
Recommends: python3-pyinotify
%endif
# Required by Salt modules
Requires: iputils
Requires: sudo
Requires: file
Requires: man
Provides: bundled(python3-tornado) = 4.5.3
%description -n python3-salt
@ -701,13 +719,6 @@ Requires(pre): %fillup_prereq
Salt ssh is a master running without zmq.
it enables the management of minions over a ssh connection.
%package tests
Summary: Unit and integration tests for Salt
Requires: %{name} = %{version}-%{release}
%description tests
Collections of unit and integration tests for Salt
%if %{with bash_completion}
%package bash-completion
Summary: Bash Completion for %{name}
@ -774,6 +785,51 @@ For transactional systems, like MicroOS, Salt can operate
transparently if the executor "transactional-update" is registered in
list of active executors. This package add the configuration file.
%endif
%if "%{flavor}" == "testsuite"
%package -n python3-salt-testsuite
Summary: Unit and integration tests for Salt
%if 0%{?rhel} == 8
BuildRequires: platform-python
%else
BuildRequires: python3
%endif
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Requires: salt = %{version}
Requires: python3-CherryPy
Requires: python3-Genshi
Requires: python3-Mako
%if !0%{?suse_version} > 1600 || 0%{?centos}
Requires: python3-boto
%endif
Requires: python3-boto3
Requires: python3-docker
%if 0%{?suse_version} < 1600
Requires: python3-mock
%endif
Requires: python3-pygit2
Requires: python3-pytest >= 7.0.1
Requires: python3-pytest-httpserver
Requires: python3-pytest-salt-factories >= 1.0.0~rc21
Requires: python3-pytest-subtests
Requires: python3-testinfra
Requires: python3-yamllint
Requires: python3-pip
Requires: docker
Requires: openssh
Requires: git
Obsoletes: %{name}-tests
%description -n python3-salt-testsuite
Collection of unit, functional, and integration tests for %{name}.
%endif
%prep
%setup -q -n salt-%{version}-suse
@ -783,6 +839,8 @@ cp %{S:6} .
%autopatch -p1
%build
%if "%{flavor}" != "testsuite"
# Putting /usr/bin at the front of $PATH is needed for RHEL/RES 7. Without this
# change, the RPM will require /bin/python, which is not provided by any package
# on RHEL/RES 7.
@ -805,7 +863,11 @@ popd
cd doc && make html && rm _build/html/.buildinfo && rm _build/html/_images/proxy_minions.png && cd _build/html && chmod -R -x+X *
%endif
%endif
%install
%if "%{flavor}" != "testsuite"
mv _build.python3 build
python3 setup.py --salt-transport=both install --prefix=%{_prefix} --root=%{buildroot}
mv build _build.python3
@ -853,11 +915,19 @@ install -Dd -m 0755 %{buildroot}%{_sysconfdir}/logrotate.d/
# Install salt-support profiles
install -Dpm 0644 salt/cli/support/profiles/* %{buildroot}%{python3_sitelib}/salt/cli/support/profiles
%endif
%if "%{flavor}" == "testsuite"
# Install Salt tests
install -Dd -m 0750 %{buildroot}%{_datadir}/salt
install -Dd -m 0750 %{buildroot}%{_datadir}/salt/tests
cp -a tests/* %{buildroot}%{_datadir}/salt/tests/
sed -i '1s=^#!/usr/bin/\(python\|env python\)[0-9.]*=#!/usr/bin/python3=' %{buildroot}%{_datadir}/salt/tests/runtests.py
install -Dd %{buildroot}%{python3_sitelib}/salt-testsuite
cp -a tests %{buildroot}%{python3_sitelib}/salt-testsuite/
# Remove runtests.py which is not used as deprecated method of running the tests
rm %{buildroot}%{python3_sitelib}/salt-testsuite/tests/runtests.py
# Copy conf files to the testsuite as they are used by the tests
cp -a conf %{buildroot}%{python3_sitelib}/salt-testsuite/
%endif
%if "%{flavor}" != "testsuite"
## Install Zypper plugins only on SUSE machines
%if 0%{?suse_version}
@ -968,11 +1038,10 @@ install -Dpm 0640 conf/suse/standalone-formulas-configuration.conf %{buildroot}%
%fdupes %{buildroot}%{python3_sitelib}
%endif
%check
%if %{with test}
python3 setup.py test --runtests-opts=-u
%endif
%if "%{flavor}" != "testsuite"
%pre
S_HOME="/var/lib/salt"
S_PHOME="/srv/salt"
@ -1434,7 +1503,10 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
%files -n python3-salt
%defattr(-,root,root,-)
%{python3_sitelib}/*
%dir %{python3_sitelib}/salt
%dir %{python3_sitelib}/salt-*.egg-info
%{python3_sitelib}/salt/*
%{python3_sitelib}/salt-*.egg-info/*
%exclude %{python3_sitelib}/salt/cloud/deploy/*.sh
%if %{with docs}
@ -1443,11 +1515,6 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
%doc doc/_build/html
%endif
%files tests
%dir %{_datadir}/salt/
%dir %{_datadir}/salt/tests/
%{_datadir}/salt/tests/*
%if %{with bash_completion}
%files bash-completion
%defattr(-,root,root)
@ -1484,6 +1551,12 @@ rm -f %{_localstatedir}/cache/salt/minion/thin/version
%defattr(-,root,root)
%config(noreplace) %attr(0640, root, root) %{_sysconfdir}/salt/minion.d/transactional_update.conf
%endif
%if "%{flavor}" == "testsuite"
%files -n python3-salt-testsuite
%{python3_sitelib}/salt-testsuite
%endif
%changelog