Skip to content

Commit

Permalink
Specify salt-ssh bin location
Browse files Browse the repository at this point in the history
  • Loading branch information
Akm0d committed Sep 3, 2024
1 parent b06e0fd commit eec4bba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/soluble/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"default": shutil.which("salt-key"),
"help": "Path to the salt-key command",
},
"salt_ssh_bin": {
"default": shutil.which("salt-ssh"),
"help": "Path to the salt-ssh command",
},
}

GROUP = "Soluble Options"
Expand Down Expand Up @@ -74,6 +78,10 @@
"subcommands": ["_global_"],
"group": GROUP,
},
"salt_ssh_bin": {
"subcommands": ["_global_"],
"group": GROUP,
},
}

SALT_SSH_GROUP = "Salt-SSH Options"
Expand Down
7 changes: 7 additions & 0 deletions src/soluble/salt/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ async def command(hub, name: str, action: Literal["-a", "-d"]):

process = await hub.lib.asyncio.create_subprocess_shell(
command,
stdout=hub.lib.asyncio.subprocess.PIPE,
)

stdout, _ = await process.communicate()
for line in stdout.splitlines():
if not line.strip():
continue
hub.log.debug(line)

retcode = await process.wait()
if retcode != 0:
raise ChildProcessError(f"Failed to accept minion keys")
Expand Down
3 changes: 1 addition & 2 deletions src/soluble/salt/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async def run_command(
config_dir = hub.soluble.RUN[name].salt_config_dir
options = " ".join(x.strip('"') for x in hub.soluble.RUN[name].salt_ssh_options)

cmd = hub.lib.shutil.which("salt-ssh")
cmd = hub.soluble.RUN[name].salt_ssh_bin
assert cmd, "Could not find salt-ssh"

full_command = f"{cmd} '{target}' --roster-file={roster} {command} --log-level={hub.OPT.pop_config.log_level} {options}"
Expand All @@ -36,7 +36,6 @@ async def run_command(
process = await hub.lib.asyncio.create_subprocess_shell(
full_command,
stdout=stdout,
# stderr=hub.lib.asyncio.subprocess.PIPE,
)

# Wait for the process to complete and capture stdout at the end
Expand Down

0 comments on commit eec4bba

Please sign in to comment.