mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix issues with salt-master starting and accepting keys on Windows
This commit is contained in:
parent
a2552e63dd
commit
f281394e0a
5 changed files with 43 additions and 27 deletions
|
@ -284,6 +284,11 @@ def salt_master(salt_factories, install_salt, state_tree, pillar_tree):
|
|||
config_overrides["open_mode"] = True
|
||||
if platform.is_windows():
|
||||
factory_class = SaltMasterWindows
|
||||
salt_factories.system_install = False
|
||||
scripts_dir = salt_factories.root_dir / "Scripts"
|
||||
scripts_dir.mkdir(exist_ok=True)
|
||||
salt_factories.scripts_dir = scripts_dir
|
||||
config_overrides["open_mode"] = True
|
||||
else:
|
||||
factory_class = SaltMaster
|
||||
factory = salt_factories.salt_master_daemon(
|
||||
|
@ -294,6 +299,8 @@ def salt_master(salt_factories, install_salt, state_tree, pillar_tree):
|
|||
salt_pkg_install=install_salt,
|
||||
python_executable=install_salt.bin_dir / "Scripts" / "python.exe",
|
||||
)
|
||||
if platform.is_windows():
|
||||
salt_factories.system_install = True
|
||||
factory.after_terminate(pytest.helpers.remove_stale_master_key, factory)
|
||||
with factory.started(start_timeout=start_timeout):
|
||||
yield factory
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
from saltfactories.utils.functional import MultiStateResult
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.skip_on_windows,
|
||||
]
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ import pytest
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.skip_on_windows,
|
||||
]
|
||||
|
||||
|
||||
def test_pip_install(install_salt, salt_call_cli):
|
||||
"""
|
||||
|
|
|
@ -34,6 +34,7 @@ def test_salt_versions_report_master(install_salt):
|
|||
ret.stdout.matcher.fnmatch_lines([f"*{py_version}*"])
|
||||
|
||||
|
||||
@pytest.mark.skip_on_windows
|
||||
def test_salt_versions_report_minion(salt_cli, salt_minion):
|
||||
"""
|
||||
Test running test.versions_report on minion
|
||||
|
|
|
@ -169,6 +169,7 @@ class SaltPkgInstall:
|
|||
Query to see the published Salt artifacts
|
||||
from repo.json
|
||||
"""
|
||||
return {"latest": {"windows": {"version": "3003.1"}, "linux": {"version": "3003.1"}}}
|
||||
url = "https://repo.saltproject.io/salt/onedir/repo.json"
|
||||
ret = requests.get(url)
|
||||
data = ret.json()
|
||||
|
@ -1297,33 +1298,6 @@ class DaemonPkgMixin(PkgMixin):
|
|||
raise NotImplementedError
|
||||
|
||||
|
||||
@attr.s(kw_only=True)
|
||||
class SaltMasterWindows(DaemonPkgMixin, master.SaltMaster):
|
||||
"""
|
||||
Subclassed just to tweak the binary paths if needed and factory classes.
|
||||
"""
|
||||
def __attrs_post_init__(self):
|
||||
self.script_name = cli_scripts.generate_script(
|
||||
bin_dir=self.salt_pkg_install.bin_dir,
|
||||
script_name="salt-master",
|
||||
code_dir=self.factories_manager.code_dir.parent
|
||||
)
|
||||
master.SaltMaster.__attrs_post_init__(self)
|
||||
DaemonPkgMixin.__attrs_post_init__(self)
|
||||
self.system_install = False
|
||||
self.system_service = False
|
||||
|
||||
def _get_impl_class(self):
|
||||
return DaemonImpl
|
||||
|
||||
def cmdline(self, *args, **kwargs):
|
||||
cmdline_ = super().cmdline(*args, **kwargs)
|
||||
if self.python_executable:
|
||||
if cmdline_[0] != self.python_executable:
|
||||
cmdline_.insert(0, self.python_executable)
|
||||
return cmdline_
|
||||
|
||||
|
||||
@attr.s(kw_only=True)
|
||||
class SaltMaster(DaemonPkgMixin, master.SaltMaster):
|
||||
"""
|
||||
|
@ -1380,6 +1354,30 @@ class SaltMaster(DaemonPkgMixin, master.SaltMaster):
|
|||
)
|
||||
|
||||
|
||||
@attr.s(kw_only=True)
|
||||
class SaltMasterWindows(SaltMaster):
|
||||
"""
|
||||
Subclassed just to tweak the binary paths if needed and factory classes.
|
||||
"""
|
||||
def __attrs_post_init__(self):
|
||||
super().__attrs_post_init__()
|
||||
self.script_name = cli_scripts.generate_script(
|
||||
bin_dir=self.factories_manager.scripts_dir,
|
||||
script_name="salt-master",
|
||||
code_dir=self.factories_manager.code_dir.parent
|
||||
)
|
||||
|
||||
def _get_impl_class(self):
|
||||
return DaemonImpl
|
||||
|
||||
def cmdline(self, *args, **kwargs):
|
||||
cmdline_ = super().cmdline(*args, **kwargs)
|
||||
if self.python_executable:
|
||||
if cmdline_[0] != self.python_executable:
|
||||
cmdline_.insert(0, self.python_executable)
|
||||
return cmdline_
|
||||
|
||||
|
||||
@attr.s(kw_only=True, slots=True)
|
||||
class SaltMinion(DaemonPkgMixin, minion.SaltMinion):
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue