From 29bebc4af4944348e4c332b1acb6397e26a36e84 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 31 May 2017 09:55:33 +0200 Subject: [PATCH] Shorten ssh control path. On macos the path is too long due to long default TMP dir. --- cdist/config.py | 17 ++++++++++++----- docs/changelog | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index 6b57e7bf..c25c029b 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -27,6 +27,8 @@ import time import itertools import tempfile import socket +import atexit +import shutil import cdist import cdist.hostsource @@ -92,7 +94,6 @@ class Config(object): "failed: %s" % e)) args.manifest = initial_manifest_temp_path - import atexit atexit.register(lambda: os.remove(initial_manifest_temp_path)) # default remote cmd patterns @@ -176,8 +177,15 @@ class Config(object): " ".join(failed_hosts)) @classmethod - def _resolve_remote_cmds(cls, args, host_base_path): - control_path = os.path.join(host_base_path, "ssh-control-path") + def _resolve_ssh_control_path(cls): + base_path = tempfile.mkdtemp() + control_path = os.path.join(base_path, "s") + atexit.register(lambda: shutil.rmtree(base_path)) + return control_path + + @classmethod + def _resolve_remote_cmds(cls, args): + control_path = cls._resolve_ssh_control_path() # If we constructed patterns for remote commands then there is # placeholder for ssh ControlPath, format it and we have unique # ControlPath for each host. @@ -200,8 +208,7 @@ class Config(object): log = logging.getLogger(host) try: - remote_exec, remote_copy = cls._resolve_remote_cmds( - args, host_base_path) + remote_exec, remote_copy = cls._resolve_remote_cmds(args) log.debug("remote_exec for host \"{}\": {}".format( host, remote_exec)) log.debug("remote_copy for host \"{}\": {}".format( diff --git a/docs/changelog b/docs/changelog index 524257a7..be0ed2e3 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Type __go_get: Install go packages using go get (Kamila Součková) * Explorer kernel_name: uname -s (Kamila Součková) * Type __sysctl: Add devuan support (Nico Schottelius) + * Core: Shorten ssh control path (Darko Poljak) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak)