SHA256
1
0
forked from pool/salt

osc copypac from project:systemsmanagement:saltstack:testing package:salt revision:320

OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=160
This commit is contained in:
Jochen Breuer 2020-02-03 13:30:18 +00:00 committed by Git OBS Bridge
parent ddaff062ff
commit 6aa440cf36
9 changed files with 274 additions and 16 deletions

View File

@ -1 +1 @@
d3f65020201314619013243463c3fe8098529e3e
e44665e8c48cfb6d2c3ef0189e3712e474ddbff6

View File

@ -3,7 +3,7 @@
<param name="url">https://github.com/openSUSE/salt-packaging.git</param>
<param name="subdir">salt</param>
<param name="filename">package</param>
<param name="revision">2019.2.2</param>
<param name="revision">2019.2.3</param>
<param name="scm">git</param>
</service>
<service name="extract_file" mode="disabled">
@ -12,8 +12,8 @@
</service>
<service name="download_url" mode="disabled">
<param name="host">codeload.github.com</param>
<param name="path">openSUSE/salt/tar.gz/v2019.2.2-suse</param>
<param name="filename">v2019.2.2.tar.gz</param>
<param name="path">openSUSE/salt/tar.gz/v2019.2.3-suse</param>
<param name="filename">v2019.2.3.tar.gz</param>
</service>
<service name="update_changelog" mode="disabled"></service>
</services>

View File

@ -0,0 +1,132 @@
From 79f566ba99f48d60e4948c9b8df9c6b6f497eced Mon Sep 17 00:00:00 2001
From: Abid Mehmood <amehmood@suse.de>
Date: Thu, 1 Aug 2019 13:14:22 +0200
Subject: [PATCH] enable passing grains to start event based on
'start_event_grains' configuration parameter
unit tests
---
conf/minion | 5 +++++
doc/ref/configuration/minion.rst | 15 +++++++++++++++
salt/config/__init__.py | 1 +
salt/minion.py | 5 +++++
tests/unit/test_minion.py | 32 ++++++++++++++++++++++++++++++++
5 files changed, 58 insertions(+)
diff --git a/conf/minion b/conf/minion
index f2b6655932..cc7e962120 100644
--- a/conf/minion
+++ b/conf/minion
@@ -548,6 +548,11 @@
# - edit.vim
# - hyper
#
+# List of grains to pass in start event when minion starts up:
+#start_event_grains:
+# - machine_id
+# - uuid
+#
# Top file to execute if startup_states is 'top':
#top_file: ''
diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst
index 30343ebd8e..fe556ef9ce 100644
--- a/doc/ref/configuration/minion.rst
+++ b/doc/ref/configuration/minion.rst
@@ -2000,6 +2000,21 @@ List of states to run when the minion starts up if ``startup_states`` is set to
- edit.vim
- hyper
+.. conf_minion:: start_event_grains
+
+``start_event_grains``
+----------------------
+
+Default: ``[]``
+
+List of grains to pass in start event when minion starts up.
+
+.. code-block:: yaml
+
+ start_event_grains:
+ - machine_id
+ - uuid
+
.. conf_minion:: top_file
``top_file``
diff --git a/salt/config/__init__.py b/salt/config/__init__.py
index ee90eb3120..788128b903 100644
--- a/salt/config/__init__.py
+++ b/salt/config/__init__.py
@@ -1283,6 +1283,7 @@ DEFAULT_MINION_OPTS = {
'state_top_saltenv': None,
'startup_states': '',
'sls_list': [],
+ 'start_event_grains': [],
'top_file': '',
'thoriumenv': None,
'thorium_top': 'top.sls',
diff --git a/salt/minion.py b/salt/minion.py
index 2c0a18604e..2b53da4f18 100644
--- a/salt/minion.py
+++ b/salt/minion.py
@@ -1456,6 +1456,11 @@ class Minion(MinionBase):
else:
return
+ if self.opts['start_event_grains']:
+ grains_to_add = dict(
+ [(k, v) for k, v in six.iteritems(self.opts.get('grains', {})) if k in self.opts['start_event_grains']])
+ load['grains'] = grains_to_add
+
if sync:
try:
self._send_req_sync(load, timeout)
diff --git a/tests/unit/test_minion.py b/tests/unit/test_minion.py
index b78e0f6abd..83215151ee 100644
--- a/tests/unit/test_minion.py
+++ b/tests/unit/test_minion.py
@@ -305,6 +305,38 @@ class MinionTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
finally:
minion.destroy()
+ def test_when_passed_start_event_grains(self):
+ mock_opts = self.get_config('minion', from_scratch=True)
+ mock_opts['start_event_grains'] = ["os"]
+ io_loop = tornado.ioloop.IOLoop()
+ io_loop.make_current()
+ minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
+ try:
+ minion.tok = MagicMock()
+ minion._send_req_sync = MagicMock()
+ minion._fire_master('Minion has started', 'minion_start')
+ load = minion._send_req_sync.call_args[0][0]
+
+ self.assertTrue('grains' in load)
+ self.assertTrue('os' in load['grains'])
+ finally:
+ minion.destroy()
+
+ def test_when_not_passed_start_event_grains(self):
+ mock_opts = self.get_config('minion', from_scratch=True)
+ io_loop = tornado.ioloop.IOLoop()
+ io_loop.make_current()
+ minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
+ try:
+ minion.tok = MagicMock()
+ minion._send_req_sync = MagicMock()
+ minion._fire_master('Minion has started', 'minion_start')
+ load = minion._send_req_sync.call_args[0][0]
+
+ self.assertTrue('grains' not in load)
+ finally:
+ minion.destroy()
+
def test_minion_retry_dns_count(self):
'''
Tests that the resolve_dns will retry dns look ups for a maximum of
--
2.16.4

View File

@ -0,0 +1,102 @@
From 127f0fa48ed2e5f05320c6c82f928f0d59a94bd9 Mon Sep 17 00:00:00 2001
From: Abid Mehmood <amehmood@suse.de>
Date: Thu, 16 Jan 2020 11:28:04 +0100
Subject: [PATCH] Restrict the 'start_event_grains' only to the start
events
add test for custom events
---
salt/minion.py | 11 ++++++++---
tests/unit/test_minion.py | 18 +++++++++++++++++-
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/salt/minion.py b/salt/minion.py
index 2b53da4f18..a2fb203bfe 100644
--- a/salt/minion.py
+++ b/salt/minion.py
@@ -1437,7 +1437,7 @@ class Minion(MinionBase):
finally:
channel.close()
- def _fire_master(self, data=None, tag=None, events=None, pretag=None, timeout=60, sync=True, timeout_handler=None):
+ def _fire_master(self, data=None, tag=None, events=None, pretag=None, timeout=60, sync=True, timeout_handler=None, include_startup_grains=False):
'''
Fire an event on the master, or drop message if unable to send.
'''
@@ -1456,7 +1456,7 @@ class Minion(MinionBase):
else:
return
- if self.opts['start_event_grains']:
+ if include_startup_grains:
grains_to_add = dict(
[(k, v) for k, v in six.iteritems(self.opts.get('grains', {})) if k in self.opts['start_event_grains']])
load['grains'] = grains_to_add
@@ -2149,6 +2149,9 @@ class Minion(MinionBase):
})
def _fire_master_minion_start(self):
+ include_grains = False
+ if self.opts['start_event_grains']:
+ include_grains = True
# Send an event to the master that the minion is live
if self.opts['enable_legacy_startup_events']:
# Old style event. Defaults to False in Sodium release.
@@ -2157,7 +2160,8 @@ class Minion(MinionBase):
self.opts['id'],
time.asctime()
),
- 'minion_start'
+ 'minion_start',
+ include_startup_grains=include_grains
)
# send name spaced event
self._fire_master(
@@ -2166,6 +2170,7 @@ class Minion(MinionBase):
time.asctime()
),
tagify([self.opts['id'], 'start'], 'minion'),
+ include_startup_grains=include_grains
)
def module_refresh(self, force_refresh=False, notify=False):
diff --git a/tests/unit/test_minion.py b/tests/unit/test_minion.py
index 83215151ee..41dfab0f45 100644
--- a/tests/unit/test_minion.py
+++ b/tests/unit/test_minion.py
@@ -314,7 +314,7 @@ class MinionTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
try:
minion.tok = MagicMock()
minion._send_req_sync = MagicMock()
- minion._fire_master('Minion has started', 'minion_start')
+ minion._fire_master('Minion has started', 'minion_start', include_startup_grains=True)
load = minion._send_req_sync.call_args[0][0]
self.assertTrue('grains' in load)
@@ -337,6 +337,22 @@ class MinionTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
finally:
minion.destroy()
+ def test_when_other_events_fired_and_start_event_grains_are_set(self):
+ mock_opts = self.get_config('minion', from_scratch=True)
+ mock_opts['start_event_grains'] = ["os"]
+ io_loop = tornado.ioloop.IOLoop()
+ io_loop.make_current()
+ minion = salt.minion.Minion(mock_opts, io_loop=io_loop)
+ try:
+ minion.tok = MagicMock()
+ minion._send_req_sync = MagicMock()
+ minion._fire_master('Custm_event_fired', 'custom_event')
+ load = minion._send_req_sync.call_args[0][0]
+
+ self.assertTrue('grains' not in load)
+ finally:
+ minion.destroy()
+
def test_minion_retry_dns_count(self):
'''
Tests that the resolve_dns will retry dns look ups for a maximum of
--
2.16.4

View File

@ -1,3 +1,21 @@
-------------------------------------------------------------------
Mon Feb 3 10:42:42 UTC 2020 - Jochen Breuer <jbreuer@suse.de>
- Update to Salt version 2019.2.3 (CVE-2019-17361)
See release notes: https://docs.saltstack.com/en/latest/topics/releases/2019.2.3.html
- Modified:
* use-adler32-algorithm-to-compute-string-checksums.patch
-------------------------------------------------------------------
Wed Jan 29 15:38:36 UTC 2020 - Jochen Breuer <jbreuer@suse.de>
- Enable passing grains to start event based on 'start_event_grains' configuration parameter
- Added:
* restrict-the-start_event_grains-only-to-the-start-ev.patch
* enable-passing-grains-to-start-event-based-on-start_.patch
-------------------------------------------------------------------
Mon Jan 13 16:09:36 UTC 2020 - Jochen Breuer <jbreuer@suse.de>

View File

@ -58,7 +58,7 @@
%bcond_with builddocs
Name: salt
Version: 2019.2.2
Version: 2019.2.3
Release: 0
Summary: A parallel remote execution system
License: Apache-2.0
@ -288,6 +288,10 @@ Patch102: add-virt.network_get_xml-function.patch
Patch103: list_downloaded-for-apt-module.patch
# PATCH_FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/200
Patch104: support-for-btrfs-and-xfs-in-parted-and-mkfs.patch
# PATCH_FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/204
Patch105: enable-passing-grains-to-start-event-based-on-start_.patch
# PATCH_FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/205
Patch106: restrict-the-start_event_grains-only-to-the-start-ev.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: logrotate
@ -801,7 +805,7 @@ This package adds the standalone configuration for the Salt master in order to m
%prep
# %setup -q -n salt-%{version}
%setup -q -n salt-2019.2.2-suse
%setup -q -n salt-2019.2.3-suse
cp %{S:1} .
cp %{S:5} ./.travis.yml
%patch1 -p1
@ -908,6 +912,8 @@ cp %{S:5} ./.travis.yml
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%build
%if 0%{?build_py2}

View File

@ -1,4 +1,4 @@
From 815042712007e3bc9e5326b3a13b2880534630b9 Mon Sep 17 00:00:00 2001
From c1e2410749479940275a217d598b22b24eef8758 Mon Sep 17 00:00:00 2001
From: Bo Maryniuk <bo@suse.de>
Date: Sat, 28 Jul 2018 22:59:04 +0200
Subject: [PATCH] Use Adler32 algorithm to compute string checksums
@ -20,13 +20,13 @@ Add warning for Sodium.
2 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/salt/config/__init__.py b/salt/config/__init__.py
index b3dfc8e43d..ee90eb3120 100644
index f4496f3a61..b272610fa4 100644
--- a/salt/config/__init__.py
+++ b/salt/config/__init__.py
@@ -1217,6 +1217,10 @@ VALID_OPTS = {
# Thorium top file location
'thorium_top': six.string_types,
@@ -1221,6 +1221,10 @@ VALID_OPTS = {
# Allow raw_shell option when using the ssh
# client via the Salt API
'netapi_allow_raw_shell': bool,
+
+ # Use Adler32 hashing algorithm for server_id (default False until Sodium, "adler32" after)
+ # Possible values are: False, adler32, crc32
@ -34,7 +34,7 @@ index b3dfc8e43d..ee90eb3120 100644
}
# default configurations
@@ -1525,7 +1529,8 @@ DEFAULT_MINION_OPTS = {
@@ -1529,7 +1533,8 @@ DEFAULT_MINION_OPTS = {
},
'discovery': False,
'schedule': {},

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:aced5a5a79def23af3d4bd7a77bd9cb3e14a1e5b2dd57a72a67c5242930fa2a4
size 14656820

3
v2019.2.3.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:76745e1d409f01004e9bdc677ecc5ac48edba5b532996a341499ad1bacd8007c
size 14661032