Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3007.x] Update SSH wrappers, wrap more funcs #65517

Merged
merged 13 commits into from
Jan 2, 2024
1 change: 1 addition & 0 deletions changelog/48067.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Made cmd.script work with files from the fileserver via salt-ssh
1 change: 1 addition & 0 deletions changelog/50196.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Made slsutil.renderer work with salt-ssh
1 change: 1 addition & 0 deletions changelog/51605.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed defaults.merge is not available when using salt-ssh
1 change: 1 addition & 0 deletions changelog/56441.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed config.get does not support merge option with salt-ssh
1 change: 1 addition & 0 deletions changelog/61100.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed state.test does not work with salt-ssh
1 change: 1 addition & 0 deletions changelog/61143.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Made slsutil.findup work with salt-ssh
1 change: 1 addition & 0 deletions changelog/65067.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed slsutil.update with salt-ssh during template rendering
1 change: 1 addition & 0 deletions changelog/65630.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added SSH wrapper for logmod
2 changes: 1 addition & 1 deletion salt/client/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ def shim_cmd(self, cmd_str, extension="py"):
if self.winrm:
target_shim_file = saltwinshell.get_target_shim_file(self, target_shim_file)
stdout, stderr, retcode = self.shell.send(
shim_tmp_file.name, target_shim_file, makedirs=True
shim_tmp_file.name, target_shim_file, makedirs=self.winrm
)
if retcode != 0:
log.error("Could not copy the shim script to target")
Expand Down
14 changes: 11 additions & 3 deletions salt/client/ssh/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(
ssh_options=None,
):
self.opts = opts
# ssh <ipv6>, but scp [<ipv6]:/path
# ssh <ipv6>, but scp [<ipv6>]:/path
self.host = host.strip("[]")
self.user = user
self.port = port
Expand Down Expand Up @@ -339,9 +339,17 @@ def send(self, local, remote, makedirs=False):
scp a file or files to a remote system
"""
if makedirs:
self.exec_cmd(f"mkdir -p {os.path.dirname(remote)}")
pardir = os.path.dirname(remote)
if not pardir:
log.warning(
f"Makedirs called on relative filename: '{remote}'. Skipping."
)
else:
ret = self.exec_cmd("mkdir -p " + shlex.quote(pardir))
if ret[2]:
return ret

# scp needs [<ipv6}
# scp needs [<ipv6>]
host = self.host
if ":" in host:
host = f"[{host}]"
Expand Down
Loading
Loading