Skip to content

Commit

Permalink
Make Salt-SSH sync custom utils
Browse files Browse the repository at this point in the history
  • Loading branch information
lkubb committed Dec 19, 2023
1 parent 53c7e6b commit 556eeac
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/53666.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Made salt-ssh sync custom utils
1 change: 1 addition & 0 deletions salt/client/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,7 @@ def mod_data(fsclient):
"grains",
"renderers",
"returners",
"utils",
]
ret = {}
with fsclient:
Expand Down
38 changes: 38 additions & 0 deletions tests/pytests/integration/ssh/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,41 @@ def test_wrapper_unwrapped_command_invalid_return(salt_ssh_cli):
assert ret.data["parsed"] == {
"local": {"no_return_key_present": "Chaos is a ladder though"}
}


@pytest.fixture(scope="module")
def utils_dependent_module(salt_run_cli, salt_master):
module_contents = r"""
import customutilsmodule
def __virtual__():
return "utilsync"
def test():
return customutilsmodule.test()
"""
utils_contents = r"""
def test():
return "success"
"""
module_tempfile = salt_master.file_roots.base.temp_file(
"_modules/utilsync.py", contents=module_contents
)
util_tempfile = salt_master.file_roots.base.temp_file(
"_utils/customutilsmodule.py", contents=utils_contents
)
try:
with module_tempfile, util_tempfile:
yield
finally:
ret = salt_run_cli.run("saltutil.sync_modules")
assert ret.returncode == 0


@pytest.mark.usefixtures("utils_dependent_module")
def test_custom_utils_are_present_on_target(salt_ssh_cli):
ret = salt_ssh_cli.run("utilsync.test")
assert ret.returncode == 0
assert ret.data == "success"

0 comments on commit 556eeac

Please sign in to comment.