From e668cdabf791b62ffa9c713fafce58c3ba1a4348 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Wed, 4 Nov 2026 21:59:58 +0100 Subject: [PATCH 1/2] Keep ansible's default ssh_args when running plays Setting ANSIBLE_SSH_ARGS replaces ansible's ssh_args instead of adding to them, so plays ran without the default ControlMaster and ControlPersist options. Every task then opened a new ssh connection and authenticated again. Start from ansible's default ssh_args when ANSIBLE_SSH_ARGS is not set. An ANSIBLE_SSH_ARGS from the environment is still extended as before. --- confluent_server/confluent/runansible.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/runansible.py b/confluent_server/confluent/runansible.py index 47bddc2c..e2b11357 100644 --- a/confluent_server/confluent/runansible.py +++ b/confluent_server/confluent/runansible.py @@ -187,8 +187,11 @@ class PlayRunner(object): 'w') as hostvarsout: json.dump(self.hostvars, hostvarsout, default=str) localenv['CONFLUENT_HOSTVARS'] = hostvarspath + # ANSIBLE_SSH_ARGS replaces ansible's ssh_args, so start from + # its defaults to keep ControlPersist + ansiblesshargs = os.environ.get( + 'ANSIBLE_SSH_ARGS', '-C -o ControlMaster=auto -o ControlPersist=60s') # limit host based algorithms to avoid excessive authentication attempts - ansiblesshargs = os.environ.get('ANSIBLE_SSH_ARGS', '') if 'hostbasedkeytypes' not in ansiblesshargs.lower() and 'hostbasedacceptedalgorithms' not in ansiblesshargs.lower(): ansiblesshargs += ' -o HostbasedAcceptedAlgorithms=*ed25519*' # notice a node that was reset mid play, else ssh waits forever From 098d0a66c3fe0fe0c109537b8de5cfd292f50f63 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Wed, 4 Nov 2026 21:59:58 +0100 Subject: [PATCH 2/2] Enable ansible pipelining for plays by default Without pipelining every task copies the module to the node over sftp, then makes it executable, runs it and removes it, each a separate ssh operation. With pipelining the module is fed to the interpreter over the ssh session, so a task takes one operation and nothing is written to the node's temporary directory. Pipelining breaks become through sudo with requiretty, which rarely applies here: plays connect as root and drop become unless become_user is set. Setting ANSIBLE_PIPELINING or ANSIBLE_SSH_PIPELINING still overrides this default. --- confluent_server/confluent/runansible.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/confluent_server/confluent/runansible.py b/confluent_server/confluent/runansible.py index e2b11357..c31f7188 100644 --- a/confluent_server/confluent/runansible.py +++ b/confluent_server/confluent/runansible.py @@ -198,6 +198,9 @@ class PlayRunner(object): if 'serveraliveinterval' not in ansiblesshargs.lower(): ansiblesshargs += ' -o ServerAliveInterval=15 -o ServerAliveCountMax=4' localenv['ANSIBLE_SSH_ARGS'] = ansiblesshargs + # feed modules over the ssh session rather than copying them over first + if 'ANSIBLE_PIPELINING' not in localenv and 'ANSIBLE_SSH_PIPELINING' not in localenv: + localenv['ANSIBLE_PIPELINING'] = 'True' with feedback: for playfilename in self.playfiles: worker = await asyncio.create_subprocess_exec(