mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
cmdeploy: prepare for being able to run commands in docker containers
This commit is contained in:
@@ -61,7 +61,7 @@ def run_cmd_options(parser):
|
||||
parser.add_argument(
|
||||
"--ssh-host",
|
||||
dest="ssh_host",
|
||||
help="Deploy to 'localhost' or to a specific SSH host",
|
||||
help="Deploy to 'localhost', via 'docker', or to a specific SSH host",
|
||||
)
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ def run_cmd(args, out):
|
||||
pyinf = "pyinfra --dry" if args.dry_run else "pyinfra"
|
||||
|
||||
cmd = f"{pyinf} --ssh-user root {ssh_host} {deploy_path} -y"
|
||||
if ssh_host == "localhost":
|
||||
if ssh_host in ["localhost", "docker"]:
|
||||
cmd = f"{pyinf} @local {deploy_path} -y"
|
||||
|
||||
if version.parse(pyinfra.__version__) < version.parse("3"):
|
||||
@@ -125,7 +125,7 @@ def dns_cmd_options(parser):
|
||||
parser.add_argument(
|
||||
"--ssh-host",
|
||||
dest="ssh_host",
|
||||
help="Run the DNS queries on 'localhost' or on a specific SSH host",
|
||||
help="Run the DNS queries on 'localhost', via 'docker', or on a specific SSH host",
|
||||
)
|
||||
|
||||
|
||||
@@ -344,6 +344,8 @@ def get_parser():
|
||||
def get_sshexec(ssh_host: str, verbose=True):
|
||||
if ssh_host in ["localhost", "@local"]:
|
||||
return "localhost"
|
||||
elif ssh_host == "docker":
|
||||
return "docker"
|
||||
if verbose:
|
||||
print(f"[ssh] login to {ssh_host}")
|
||||
return SSHExec(ssh_host, verbose=verbose)
|
||||
|
||||
@@ -9,6 +9,8 @@ from . import remote
|
||||
def get_initial_remote_data(sshexec, mail_domain):
|
||||
if sshexec == "localhost":
|
||||
result = remote.rdns.perform_initial_checks(mail_domain)
|
||||
elif sshexec == "docker":
|
||||
result = remote.rdns.perform_initial_checks(mail_domain, pre_command="docker exec chatmail ")
|
||||
else:
|
||||
result = sshexec.logged(
|
||||
call=remote.rdns.perform_initial_checks, kwargs=dict(mail_domain=mail_domain)
|
||||
@@ -48,7 +50,7 @@ def check_full_zone(sshexec, remote_data, out, zonefile) -> int:
|
||||
"""Check existing DNS records, optionally write them to zone file
|
||||
and return (exitcode, remote_data) tuple."""
|
||||
|
||||
if sshexec == "localhost":
|
||||
if sshexec in ["localhost", "docker"]:
|
||||
required_diff, recommended_diff = remote.rdns.check_zonefile(
|
||||
zonefile=zonefile, verbose=False
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user