Skip to content

Commit 6b7c2eb

Browse files
authored
Fix clush group resolver error by moving SSH options to clush.conf (#2142)
The previous commits added SSH options via clush's -o CLI flag, which broke clush's argument parsing and caused "Group resolver error: Default group source not found: ansible". Move all SSH options (IdentityFile, StrictHostKeyChecking, UserKnownHostsFile, LogLevel) into clush.conf where they belong. Add UserKnownHostsFile=/dev/null to clush.conf to avoid known_hosts race conditions with fanout:64 concurrent connections. AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
1 parent 669e7e4 commit 6b7c2eb

2 files changed

Lines changed: 12 additions & 30 deletions

File tree

files/clustershell/clush.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ fd_max: 8192
77
history_size: 100
88
node_count: yes
99
verbosity: 1
10-
ssh_options: -o IdentityFile=/ansible/secrets/id_rsa.operator -o StrictHostKeyChecking=no -o LogLevel=ERROR
10+
ssh_options: -o IdentityFile=/ansible/secrets/id_rsa.operator -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR

osism/commands/console.py

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
import json
4-
import os
54
import shlex
6-
import shutil
75
import socket
86
import subprocess
9-
import tempfile
107
from typing import Optional
118

129
from cliff.command import Command
@@ -212,32 +209,17 @@ def take_action(self, parsed_args):
212209
if type_console == "ansible":
213210
subprocess.call(["/run-ansible-console.sh", host])
214211
elif type_console == "clush":
215-
# Create a per-invocation known_hosts file to avoid race conditions
216-
# with fanout:64 concurrent SSH connections while still persisting
217-
# host keys during the session.
218-
fd, tmp_known_hosts = tempfile.mkstemp(prefix="clush_known_hosts_")
219-
try:
220-
os.close(fd)
221-
if os.path.exists(KNOWN_HOSTS_PATH):
222-
shutil.copy2(KNOWN_HOSTS_PATH, tmp_known_hosts)
223-
subprocess.call(
224-
[
225-
"/usr/local/bin/clush",
226-
"-l",
227-
settings.OPERATOR_USER,
228-
"-o",
229-
"StrictHostKeyChecking=no",
230-
"-o",
231-
"LogLevel=ERROR",
232-
"-o",
233-
f"UserKnownHostsFile={tmp_known_hosts}",
234-
"-g",
235-
host,
236-
]
237-
)
238-
finally:
239-
if os.path.exists(tmp_known_hosts):
240-
os.unlink(tmp_known_hosts)
212+
# SSH options (IdentityFile, StrictHostKeyChecking, LogLevel)
213+
# are configured in clush.conf, no need to pass them here.
214+
subprocess.call(
215+
[
216+
"/usr/local/bin/clush",
217+
"-l",
218+
settings.OPERATOR_USER,
219+
"-g",
220+
host,
221+
]
222+
)
241223
elif type_console == "ssh":
242224
# Try to resolve as an inventory group
243225
group_hosts = get_hosts_from_group(host)

0 commit comments

Comments
 (0)