From 8f076a27bf3073087022b742dabc7220216e68ab Mon Sep 17 00:00:00 2001 From: Sergio Poppi Date: Tue, 13 Oct 2026 23:59:33 +0200 Subject: [PATCH 1/6] Fix container deployment from Ubuntu 26.04 / WSL hosts - sshLogin: raise the timeout from 2s to 15s and use BatchMode=yes and ConnectTimeout=5, so a slow sshd is no longer mistaken for a rejected key (which made discos-deploy ask for the root password). - Dockerfile: set UseDNS no and GSSAPIAuthentication no in the image, so sshd answers without waiting on reverse DNS before Ansible runs. - dockerEnsureContainer: inject the RSA public key also when the container already exists, not only on creation. - dependencies role: accept GitHub's host key on first connection (accept_newhostkey) when cloning the token branch. - key_exchange role: run ssh-keyscan with -q and keep only key type and key, since newer OpenSSH prints the banner comment on stdout and broke the known_hosts entry ("Host parameter does not match hashed host field"). Co-Authored-By: Claude Opus 5.5 --- Dockerfile | 3 +++ ansible/roles/dependencies/tasks/retrieve.yml | 1 + ansible/roles/key_exchange/tasks/main.yml | 2 +- deployment/__init__.py | 14 ++++++++++---- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ca0b8d4e..70f3d098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,9 @@ RUN rm -f /etc/machine-id /var/lib/dbus/machine-id && \ ln -sf /etc/machine-id /var/lib/dbus/machine-id RUN ssh-keygen -A +RUN sed -i -e 's/^#\?UseDNS .*/UseDNS no/' \ + -e 's/^#\?GSSAPIAuthentication .*/GSSAPIAuthentication no/' \ + /etc/ssh/sshd_config RUN echo 'root:rootpwd' | chpasswd COPY third-party/docker-systemctl-replacement/systemctl3.py /usr/local/bin/systemctl diff --git a/ansible/roles/dependencies/tasks/retrieve.yml b/ansible/roles/dependencies/tasks/retrieve.yml index b5d30298..e4e64262 100644 --- a/ansible/roles/dependencies/tasks/retrieve.yml +++ b/ansible/roles/dependencies/tasks/retrieve.yml @@ -13,6 +13,7 @@ force: true depth: 1 version: token + accept_newhostkey: true - name: Fetch the repository token value diff --git a/ansible/roles/key_exchange/tasks/main.yml b/ansible/roles/key_exchange/tasks/main.yml index 7523f4fb..d26381a7 100644 --- a/ansible/roles/key_exchange/tasks/main.yml +++ b/ansible/roles/key_exchange/tasks/main.yml @@ -30,7 +30,7 @@ hostvars[item.0][item.1] ~ ' ' ~ ( - lookup('pipe', 'ssh-keyscan -T 5 -t ecdsa ' ~ hostvars[item.0].ansible_host).split()[1:] | join(' ') + lookup('pipe', 'ssh-keyscan -q -T 5 -t ecdsa ' ~ hostvars[item.0].ansible_host).split()[1:3] | join(' ') ) }} with_nested: diff --git a/deployment/__init__.py b/deployment/__init__.py index 52ca5a92..376f04f3 100644 --- a/deployment/__init__.py +++ b/deployment/__init__.py @@ -117,11 +117,15 @@ def sshLogin(ip, user='root'): sp = subprocess.run( [ 'timeout', - '2', + '15', 'ssh', f'{user}@{ip}', '-o', 'PasswordAuthentication=false', + '-o', + 'BatchMode=yes', + '-o', + 'ConnectTimeout=5', '"exit"' ], stdout=STDOUT, @@ -553,9 +557,11 @@ def dockerEnsureContainer( ): """Create container if missing, otherwise start it.""" if dockerContainerExists(name): - if dockerContainerRunning(name): - return 0 - return dockerStartContainer(name, ip=ip) + if not dockerContainerRunning(name): + rc = dockerStartContainer(name, ip=ip) + if rc != 0: + return rc + return dockerInjectRSAKey(name) rc = _docker([ 'run', '-d', From 28b31e2b1a31749489b6f3e01f8665f414d5d58e Mon Sep 17 00:00:00 2001 From: Sergio Poppi Date: Wed, 14 Oct 2026 09:47:38 +0200 Subject: [PATCH 2/6] Add PowerShell wrappers for WSL and container support in discos-login - scripts/discos.ps1: PowerShell 7.3+ functions discos-deploy, discos-container and discos-login that forward to the tools installed in a WSL2 distribution (default Ubuntu-26.04, override with DISCOS_WSL_DISTRO). Arguments are passed through a login shell unchanged, so PATH and REPOSITORY_TOKEN come from ~/.profile. - dockerMachineList: list the inventory machines that exist as Docker containers (empty when Docker is not installed). - discos-login: accept those containers as machines too and check them with a direct SSH port probe, since machineList only knew about Vagrant/VirtualBox VMs. Co-Authored-By: Claude Opus 5.5 --- deployment/__init__.py | 9 +++++++++ scripts/discos-login | 11 +++++++++-- scripts/discos.ps1 | 43 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 scripts/discos.ps1 diff --git a/deployment/__init__.py b/deployment/__init__.py index 376f04f3..e747203c 100644 --- a/deployment/__init__.py +++ b/deployment/__init__.py @@ -549,6 +549,15 @@ def dockerContainerRunning(name): sp = _docker_output(['inspect', '-f', '{{.State.Running}}', name]) return sp.returncode == 0 and sp.stdout.strip() == 'true' +def dockerMachineList(inventory='development'): + """Return the inventory machines that exist as Docker containers.""" + try: + hosts, _, _ = parseInventory(inventory) + return [m for m in hosts if dockerContainerExists(m)] + except OSError: + # Docker not installed + return [] + def dockerEnsureContainer( name, ip, diff --git a/scripts/discos-login b/scripts/discos-login index 359537fb..536dbb79 100644 --- a/scripts/discos-login +++ b/scripts/discos-login @@ -15,10 +15,17 @@ parser.add_argument( required=False, default='discos' ) -parser.add_argument('machine', choices=deployment.machineList()) +vms = list(deployment.machineList()) +containers = [m for m in deployment.dockerMachineList() if m not in vms] +parser.add_argument('machine', choices=vms + containers) args = parser.parse_args() -if deployment.isRunning(args.machine): +if args.machine in containers: + running = deployment.ping(deployment.getIp(args.machine)) +else: + running = deployment.isRunning(args.machine) + +if running: try: subprocess.call([ 'ssh', diff --git a/scripts/discos.ps1 b/scripts/discos.ps1 new file mode 100644 index 00000000..acdbfa7f --- /dev/null +++ b/scripts/discos.ps1 @@ -0,0 +1,43 @@ +#Requires -Version 7.3 +<# +.SYNOPSIS + PowerShell wrappers for the DISCOS deployment tools installed in WSL2. + +.DESCRIPTION + Ansible cannot run on Windows, so discos-deploy and the other tools run + inside a WSL2 distribution. These functions forward each call to that + distribution, passing the arguments through unchanged. + + Requirements inside the distribution: + - the deployment package installed, so the tools are on the login + PATH (~/.local/bin); + - the Docker engine installed in the distribution itself, not Docker + Desktop: with Docker Desktop the container IPs (192.168.56.0/24) + are not reachable from WSL; + - REPOSITORY_TOKEN exported in ~/.profile, since a non-interactive + login shell does not read ~/.bashrc. + + File arguments must be WSL paths (/mnt/d/... or ~/...), not Windows ones. + +.EXAMPLE + . D:\Work\Develop\deployment\scripts\discos.ps1 + discos-deploy manager:development --docker + discos-container status + discos-login manager + + Add the first line to $PROFILE to load the functions in every session. + Set $env:DISCOS_WSL_DISTRO to use a distribution other than 'Ubuntu-26.04'. +#> + +$DiscosWslDistro = if ($env:DISCOS_WSL_DISTRO) { $env:DISCOS_WSL_DISTRO } else { 'Ubuntu-26.04' } + +# A login shell loads PATH and REPOSITORY_TOKEN from ~/.profile; +# "$0" "$@" hands the arguments over without re-parsing them. +$DiscosWslPrefix = @( + '-d', $DiscosWslDistro, '--cd', '~', '--exec', + 'bash', '-lc', 'exec "$0" "$@"' +) + +function discos-deploy { wsl.exe @DiscosWslPrefix discos-deploy @args } +function discos-container { wsl.exe @DiscosWslPrefix discos-container @args } +function discos-login { wsl.exe @DiscosWslPrefix discos-login @args } From c659dff3a984851d720e049247b10b3202c90f75 Mon Sep 17 00:00:00 2001 From: Sergio Poppi Date: Thu, 15 Oct 2026 19:26:28 +0200 Subject: [PATCH 3/6] Skip VirtualBox VM listing when vboxmanage is not installed On Docker-only hosts (e.g. WSL) discos-login printed "/bin/sh: 1: vboxmanage: not found" because machineList() always ran vboxmanage to list the VirtualBox VMs. _vboxList() now returns an empty list when vboxmanage is not on the PATH, so only the Docker containers are listed and no shell error is shown. Co-Authored-By: Claude Opus 5.5 --- deployment/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deployment/__init__.py b/deployment/__init__.py index e747203c..0be4fb98 100644 --- a/deployment/__init__.py +++ b/deployment/__init__.py @@ -390,6 +390,10 @@ def _vagrantList(): return [m.decode().strip().replace('discos_', '') for m in machines] def _vboxList(): + import shutil + if not shutil.which('vboxmanage'): + # VirtualBox not installed, e.g. Docker-only hosts + return [] cmd = subprocess.Popen( "vboxmanage list vms | awk '{print $1}' | sed 's/\"//g'", shell=True, From 44f2ae6287dc28d43baf89272cd6dfc52921abac Mon Sep 17 00:00:00 2001 From: Sergio Poppi Date: Thu, 15 Oct 2026 19:39:38 +0200 Subject: [PATCH 4/6] Support Docker containers in discos-vnc discos-vnc only offered Vagrant/VirtualBox VMs, so on Docker-only hosts (e.g. WSL) it failed with "invalid choice: 'manager' (choose from )". - isRunning: accept machines that exist as Docker containers, not only Vagrant VMs. - discos-vnc: add the Docker containers to the selectable machines. - discos-login: use isRunning again instead of its own container check. Co-Authored-By: Claude Opus 5.5 --- deployment/__init__.py | 2 +- scripts/discos-login | 7 +------ scripts/discos-vnc | 3 ++- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/deployment/__init__.py b/deployment/__init__.py index 0be4fb98..2afcc732 100644 --- a/deployment/__init__.py +++ b/deployment/__init__.py @@ -417,7 +417,7 @@ def machineList(inventory='development'): return machines def isRunning(name, inventory='development'): - if name not in machineList(): + if name not in machineList() and name not in dockerMachineList(inventory): error(f'Machine {name} unknown!') return ping(getIp(name, inventory)) diff --git a/scripts/discos-login b/scripts/discos-login index 536dbb79..3286888c 100644 --- a/scripts/discos-login +++ b/scripts/discos-login @@ -20,12 +20,7 @@ containers = [m for m in deployment.dockerMachineList() if m not in vms] parser.add_argument('machine', choices=vms + containers) args = parser.parse_args() -if args.machine in containers: - running = deployment.ping(deployment.getIp(args.machine)) -else: - running = deployment.isRunning(args.machine) - -if running: +if deployment.isRunning(args.machine): try: subprocess.call([ 'ssh', diff --git a/scripts/discos-vnc b/scripts/discos-vnc index 3132e537..1f669036 100644 --- a/scripts/discos-vnc +++ b/scripts/discos-vnc @@ -17,7 +17,8 @@ users = { 'discos': 1, 'observer': 2 } -machines = deployment.machineList() +machines = list(deployment.machineList()) +machines += [m for m in deployment.dockerMachineList() if m not in machines] try: machines.remove('storage') except: From c7408c9d6325183ef4b426679b245526db03b3a0 Mon Sep 17 00:00:00 2001 From: Sergio Poppi Date: Thu, 15 Oct 2026 19:53:03 +0200 Subject: [PATCH 5/6] Check for vncviewer before opening the VNC tunnel in discos-vnc When vncviewer was missing (e.g. only gvncviewer installed), discos-vnc crashed with FileNotFoundError after starting the SSH tunnel, leaving the tunnel running in the background. It now checks that vncviewer is on the PATH first and stops with a message suggesting the tigervnc-viewer package. Co-Authored-By: Claude Opus 5.5 --- scripts/discos-vnc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/discos-vnc b/scripts/discos-vnc index 1f669036..ea858ec9 100644 --- a/scripts/discos-vnc +++ b/scripts/discos-vnc @@ -6,6 +6,7 @@ $ discos-vnc -u observer console """ import os +import shutil import subprocess from multiprocessing import Process from argparse import ArgumentParser @@ -62,6 +63,12 @@ def detach(vnc_command, ssh_command): shell=True ) +if not shutil.which('vncviewer'): + deployment.error( + 'vncviewer not found, install a TigerVNC viewer ' + '(e.g. "sudo apt install tigervnc-viewer").' + ) + if deployment.isRunning(args.machine): remote_port = remote_starting_port + users[args.user] local_port = local_starting_port From e5b00aa2af9071f572042bc3770d443e3607f9c1 Mon Sep 17 00:00:00 2001 From: Sergio Poppi Date: Fri, 6 Nov 2026 19:53:04 +0100 Subject: [PATCH 6/6] Restored timeout Timeout set to old 2 seconds timeout --- deployment/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/__init__.py b/deployment/__init__.py index 2afcc732..ab3ea92e 100644 --- a/deployment/__init__.py +++ b/deployment/__init__.py @@ -117,7 +117,7 @@ def sshLogin(ip, user='root'): sp = subprocess.run( [ 'timeout', - '15', + '2', 'ssh', f'{user}@{ip}', '-o',