mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Make sure the state tree files created have the right permissions
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
cdec086831
commit
74c4ea830f
5 changed files with 59 additions and 9 deletions
|
@ -336,13 +336,14 @@ def salt_master(salt_factories, install_salt, pkg_tests_account):
|
|||
check=True,
|
||||
)
|
||||
|
||||
# The engines_dirs is created in .nox path. We need to set correct perms
|
||||
# for the user running the Salt Master
|
||||
check_paths = [state_tree, pillar_tree, CODE_DIR / ".nox"]
|
||||
for path in check_paths:
|
||||
if os.path.exists(path) is False:
|
||||
continue
|
||||
subprocess.run(["chown", "-R", "salt:salt", str(path)], check=False)
|
||||
if not platform.is_windows() and not platform.is_darwin():
|
||||
# The engines_dirs is created in .nox path. We need to set correct perms
|
||||
# for the user running the Salt Master
|
||||
check_paths = [state_tree, pillar_tree, CODE_DIR / ".nox"]
|
||||
for path in check_paths:
|
||||
if os.path.exists(path) is False:
|
||||
continue
|
||||
subprocess.run(["chown", "-R", "salt:salt", str(path)], check=False)
|
||||
|
||||
with factory.started(start_timeout=start_timeout):
|
||||
yield factory
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import logging
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
from pytestskipmarkers.utils import platform
|
||||
from saltfactories.utils.functional import MultiStateResult
|
||||
|
||||
pytestmark = [
|
||||
|
@ -73,6 +75,16 @@ def state_name(salt_master):
|
|||
with salt_master.state_tree.base.temp_file(
|
||||
f"{name}.sls", CHECK_IMPORTS_SLS_CONTENTS
|
||||
):
|
||||
if not platform.is_windows() and not platform.is_darwin():
|
||||
subprocess.run(
|
||||
[
|
||||
"chown",
|
||||
"-R",
|
||||
"salt:salt",
|
||||
str(salt_master.state_tree.base.write_path),
|
||||
],
|
||||
check=False,
|
||||
)
|
||||
yield name
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import subprocess
|
||||
|
||||
import pytest
|
||||
from pytestskipmarkers.utils import platform
|
||||
|
||||
|
||||
def test_salt_call_local(salt_call_cli):
|
||||
|
@ -28,6 +31,16 @@ def state_name(salt_master):
|
|||
- name: foo
|
||||
"""
|
||||
with salt_master.state_tree.base.temp_file(f"{name}.sls", sls_contents):
|
||||
if not platform.is_windows() and not platform.is_darwin():
|
||||
subprocess.run(
|
||||
[
|
||||
"chown",
|
||||
"-R",
|
||||
"salt:salt",
|
||||
str(salt_master.state_tree.base.write_path),
|
||||
],
|
||||
check=False,
|
||||
)
|
||||
yield name
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import subprocess
|
||||
|
||||
import pytest
|
||||
from pytestskipmarkers.utils import platform
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.skip_on_windows,
|
||||
|
@ -19,6 +22,16 @@ def pillar_name(salt_master):
|
|||
with salt_master.pillar_tree.base.temp_file(
|
||||
"top.sls", top_file_contents
|
||||
), salt_master.pillar_tree.base.temp_file("test.sls", test_file_contents):
|
||||
if not platform.is_windows() and not platform.is_darwin():
|
||||
subprocess.run(
|
||||
[
|
||||
"chown",
|
||||
"-R",
|
||||
"salt:salt",
|
||||
str(salt_master.pillar_tree.base.write_path),
|
||||
],
|
||||
check=False,
|
||||
)
|
||||
yield name
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import sys
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
from pytestskipmarkers.utils import platform
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.skip_on_windows,
|
||||
|
@ -10,7 +11,7 @@ pytestmark = [
|
|||
@pytest.fixture
|
||||
def state_name(salt_master):
|
||||
name = "some-state"
|
||||
if sys.platform.startswith("win"):
|
||||
if platform.is_windows():
|
||||
sls_contents = """
|
||||
create_empty_file:
|
||||
file.managed:
|
||||
|
@ -31,6 +32,16 @@ def state_name(salt_master):
|
|||
- fullname: Salt Dude
|
||||
"""
|
||||
with salt_master.state_tree.base.temp_file(f"{name}.sls", sls_contents):
|
||||
if not platform.is_windows() and not platform.is_darwin():
|
||||
subprocess.run(
|
||||
[
|
||||
"chown",
|
||||
"-R",
|
||||
"salt:salt",
|
||||
str(salt_master.state_tree.base.write_path),
|
||||
],
|
||||
check=False,
|
||||
)
|
||||
yield name
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue