[KVM / cloud-init] Duplication du suffixe .lab dans le FQDN des VM — comportement attendu ?

オープン 初心者向け
#413 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, terraform

調査の方向性

指定された templates/cloud-init/almalinux.yaml.tmpl、templates/cloud-init/ubuntu.yaml.tmpl、templates/cloud-init/debian.yaml.tmpl の cloud-init テンプレートから始め、KVM プロバイダーの main.tf がどのようにホスト名を渡しているかを追ってください。カタログ名にすでに .lab が含まれているか確認し、生成されるホスト名と FQDN の値を比較してください。ゲストの FQDN が重複したサフィックスなしでカタログ名と一致すれば完了です。影響を受けるすべてのテンプレートで動作を確認してください。

索引モデルが issue の本文から書いたものです。

説明

bug

Bonjour Stéphane,

Tout d'abord, merci pour ton travail sur dsoxlab, que je découvre actuellement dans le cadre de ma préparation aux certifications Linux.

Lors du provisionnement des machines du catalogue linux-dsoxlab-training avec le provider KVM sous WSL2, j'ai constaté une duplication du suffixe .lab dans le FQDN des trois machines virtuelles.

Le comportement est reproductible avec les versions 0.11.2 et 0.11.3 de dsoxlab, y compris après destruction et reprovisionnement des machines.

Avant de considérer cela comme un bug, je souhaitais vérifier si ce comportement était intentionnel, notamment dans le cadre des exercices pédagogiques.

Résultats observés

Machine hostname hostname -f
AlmaLinux 1 alma-rhcsa-1.lab.lab alma-rhcsa-1.lab.lab
AlmaLinux 2 alma-rhcsa-2.lab.lab alma-rhcsa-2.lab.lab
Ubuntu ubuntu-lfcs-1.lab ubuntu-lfcs-1.lab.lab

Le comportement diffère légèrement entre AlmaLinux et Ubuntu, mais le FQDN présente systématiquement une duplication du suffixe .lab.

Analyse

En examinant les données cloud-init générées, j'obtiens par exemple pour la première machine AlmaLinux :

hostname: alma-rhcsa-1.lab
fqdn: alma-rhcsa-1.lab.lab
manage_etc_hosts: true
preserve_hostname: false

Le fichier /etc/hosts contient notamment :

127.0.0.1 alma-rhcsa-1.lab.lab alma-rhcsa-1.lab
::1 alma-rhcsa-1.lab.lab alma-rhcsa-1.lab

Après investigation, cette duplication semble provenir des templates suivants :

  • templates/cloud-init/almalinux.yaml.tmpl
  • templates/cloud-init/ubuntu.yaml.tmpl
  • templates/cloud-init/debian.yaml.tmpl

Ces trois templates contiennent :

hostname: ${hostname}
fqdn: ${hostname}.lab
manage_etc_hosts: true
preserve_hostname: false

Or, dans le fichier main.tf du provider KVM, la variable transmise au template est :

hostname = h.name

Les noms déclarés dans le fichier meta.yml du catalogue comportant déjà le suffixe .lab, celui-ci semble donc être ajouté une seconde fois lors de la génération du user-data cloud-init.

Comportement attendu

Je m'attendais plutôt à une distinction entre le nom court et le FQDN, par exemple :

hostname: alma-rhcsa-1
fqdn: alma-rhcsa-1.lab
manage_etc_hosts: true
preserve_hostname: false

Cela permettrait de conserver une cohérence entre le nom déclaré dans le catalogue, le DNS libvirt, la configuration SSH et le FQDN du système invité.

Impact

Le provisionnement, les connexions SSH et la résolution DNS via le serveur DNS libvirt fonctionnent correctement malgré cette anomalie.

Il existe cependant une incohérence entre le FQDN déclaré dans le catalogue et celui retourné par le système invité.

Périmètre des vérifications

  • Reproduit avec dsoxlab 0.11.2 et 0.11.3.
  • Reproduit après destruction et reprovisionnement des VM.
  • Confirmé sur les deux machines AlmaLinux et la machine Ubuntu.
  • Même configuration identifiée dans le template Debian, mais non testée sur une VM Debian.
  • Autres providers (Incus et Outscale) non testés.
  • Aucune modification locale des templates.
  • Aucun correctif appliqué ni testé.

Est-ce un comportement attendu ou s'agit-il effectivement d'une petite incohérence dans la génération des configurations cloud-init ?

Merci d'avance pour ton retour et encore bravo pour le travail réalisé sur ce projet !

Vincent

Steps to reproduce

Depuis le répertoire personnel, avec le catalogue linux-dsoxlab-training déjà installé et le provider KVM sélectionné :

1. Provisionner les machines
cd ~
dsoxlab provision
2. Vérifier les noms d'hôtes et les configurations cloud-init
for host in alma-rhcsa-1.lab alma-rhcsa-2.lab ubuntu-lfcs-1.lab; do
    echo "=== $host ==="
    ssh "$host" '
        hostname
        hostname -s
        hostname -f
        cat /etc/hostname
        cat /etc/hosts
        sudo grep -E "^(hostname|fqdn|manage_etc_hosts|preserve_hostname):" /var/lib/cloud/instance/user-data.txt
    '
done
3. Constater les résultats

La commande hostname -f retourne les valeurs suivantes :

Machine FQDN attendu FQDN obtenu
AlmaLinux 1 alma-rhcsa-1.lab alma-rhcsa-1.lab.lab
AlmaLinux 2 alma-rhcsa-2.lab alma-rhcsa-2.lab.lab
Ubuntu ubuntu-lfcs-1.lab ubuntu-lfcs-1.lab.lab

La duplication du suffixe .lab est également présente dans /etc/hosts et dans les données cloud-init.

Le comportement a été reproduit après destruction et reprovisionnement des machines virtuelles, avec les versions 0.11.2 et 0.11.3 de dsoxlab.

Aucune modification manuelle des templates cloud-init ou des fichiers de configuration des machines virtuelles n'a été effectuée.

Diagnostic report
## dsoxlab support

### Environment

| | |
|---|---|
| dsoxlab | 0.11.3 |
| python | 3.12.3 (CPython) |
| system | Linux 6.18.58.1-microsoft-standard-WSL2 |
| distribution | Ubuntu 24.04.5 LTS |
| architecture | x86_64 |
| shell | bash |

### External tools

| | |
|---|---|
| terraform | Terraform v1.17.2 |
| ansible-playbook | ansible-playbook [core 2.21.6] |
| virsh | 10.0.0 |
| incus | absent |
| docker | absent |
| ssh | OpenSSH_9.6p1 Ubuntu-3ubuntu13.20, OpenSSL 3.0.13 30 Jan 2024 |
| git | git version 2.43.0 |
| uv | uv 0.13.7 (x86_64-unknown-linux-gnu) |

### Catalog

| | |
|---|---|
| root | ~/.local/share/dsoxlab/catalogs/linux |
| active_section | l2 |
| active_lab | l4-ssh-key-auth-harden |
| id | linux-dsoxlab-training |
| category | linux |
| active_provider | kvm |
| declared_providers | kvm, incus, outscale |
| terraform_providers | libvirt 0.9.9 |
| declared_hosts | 3 |
| labs_discovered | 89 |
| vm_labs | 69 |
| runtime_lab_actif | vm |

### Locations

| | |
|---|---|
| xdg_state | ~/.local/state/dsoxlab |
| log | ~/.local/state/dsoxlab/dsoxlab.log |

### Last log lines


2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: virsh --connect qemu:///system metadata alma-rhcsa-2.lab https://github.com/stephrobert/dsoxlab/provenance/v1 (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: virsh --connect qemu:///system domuuid alma-rhcsa-2.lab (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: git -C ~/.local/share/dsoxlab/catalogs/linux rev-parse HEAD (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: virsh --connect qemu:///system metadata alma-rhcsa-1.lab https://github.com/stephrobert/dsoxlab/provenance/v1 (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: virsh --connect qemu:///system domuuid alma-rhcsa-1.lab (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: virsh --connect qemu:///system metadata alma-rhcsa-2.lab https://github.com/stephrobert/dsoxlab/provenance/v1 (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: virsh --connect qemu:///system domuuid alma-rhcsa-2.lab (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: virsh --connect qemu:///system metadata ubuntu-lfcs-1.lab https://github.com/stephrobert/dsoxlab/provenance/v1 (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: virsh --connect qemu:///system domuuid ubuntu-lfcs-1.lab (cwd=None)
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:41:03 DEBUG   dsoxlab.utils.shell: run: terraform -chdir=~/.local/state/dsoxlab/linux-dsoxlab-training/terraform/kvm output -json (cwd=None)
2026-11-30T18:41:04 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:43:18 INFO    dsoxlab.infra.inventory: Host alma-rhcsa-1.lab ready (attempt 5).
2026-11-30T18:43:19 INFO    dsoxlab.infra.inventory: Host alma-rhcsa-2.lab ready (attempt 1).
2026-11-30T18:43:21 INFO    dsoxlab.infra.inventory: Host ubuntu-lfcs-1.lab ready (attempt 1).
2026-11-30T18:43:21 DEBUG   dsoxlab.utils.shell: run: terraform -chdir=~/.local/state/dsoxlab/linux-dsoxlab-training/terraform/kvm output -json (cwd=None)
2026-11-30T18:43:22 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:45:01 DEBUG   dsoxlab.utils.shell: run: terraform -chdir=~/.local/state/dsoxlab/linux-dsoxlab-training/terraform/kvm output -json (cwd=None)
2026-11-30T18:45:01 DEBUG   dsoxlab.utils.shell: ok: returncode=0
2026-11-30T18:46:15 DEBUG   dsoxlab.utils.shell: run: terraform -chdir=~/.local/state/dsoxlab/linux-dsoxlab-training/terraform/kvm output -json (cwd=None)
2026-11-30T18:46:16 DEBUG   dsoxlab.utils.shell: ok: returncode=0


ℹ Paste this report into your issue. It carries no personal path, no public
address and no machine name.
Operating system

Ubuntu 24.04.5 LTS — WSL2 — Kernel 6.18.58.1-microsoft-standard-WSL2 — x86_64

Runtime involved

vm

Logs / output
user@machine:~$ cd
user@machine:~$ dsoxlab provision
ℹ Provisioning infrastructure (provider: kvm)…
  Nothing to do ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1/1 0:00:02
ℹ Direct connection enabled: ssh <machine> now works (fragment
/home/user/.ssh/config.d/linux-dsoxlab-training.conf).
✔ Provisioning complete: 3 host(s) ready.
ℹ   alma-rhcsa-1.lab → 10.10.30.11
ℹ   alma-rhcsa-2.lab → 10.10.30.12
ℹ   ubuntu-lfcs-1.lab → 10.10.30.13
user@machine:~$ for host in alma-rhcsa-1.lab alma-rhcsa-2.lab ubuntu-lfcs-1.lab; do
    echo "=== $host ==="
    ssh "$host" '
        hostname
        hostname -s
        hostname -f
        cat /etc/hostname
        cat /etc/hosts
        sudo grep -E "^(hostname|fqdn|manage_etc_hosts|preserve_hostname):" /var/lib/cloud/instance/user-data.txt
    '
done
=== alma-rhcsa-1.lab ===
Warning: Permanently added '10.10.30.11' (ED25519) to the list of known hosts.
alma-rhcsa-1.lab.lab
alma-rhcsa-1
alma-rhcsa-1.lab.lab
alma-rhcsa-1.lab.lab
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 alma-rhcsa-1.lab.lab alma-rhcsa-1.lab
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

# The following lines are desirable for IPv6 capable hosts
::1 alma-rhcsa-1.lab.lab alma-rhcsa-1.lab
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

hostname: alma-rhcsa-1.lab
fqdn: alma-rhcsa-1.lab.lab
manage_etc_hosts: true
preserve_hostname: false
=== alma-rhcsa-2.lab ===
Warning: Permanently added '10.10.30.12' (ED25519) to the list of known hosts.
alma-rhcsa-2.lab.lab
alma-rhcsa-2
alma-rhcsa-2.lab.lab
alma-rhcsa-2.lab.lab
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 alma-rhcsa-2.lab.lab alma-rhcsa-2.lab
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4

# The following lines are desirable for IPv6 capable hosts
::1 alma-rhcsa-2.lab.lab alma-rhcsa-2.lab
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

hostname: alma-rhcsa-2.lab
fqdn: alma-rhcsa-2.lab.lab
manage_etc_hosts: true
preserve_hostname: false
=== ubuntu-lfcs-1.lab ===
Warning: Permanently added '10.10.30.13' (ED25519) to the list of known hosts.
ubuntu-lfcs-1.lab
ubuntu-lfcs-1
ubuntu-lfcs-1.lab.lab
ubuntu-lfcs-1.lab
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.debian.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 ubuntu-lfcs-1.lab.lab ubuntu-lfcs-1.lab
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

hostname: ubuntu-lfcs-1.lab
fqdn: ubuntu-lfcs-1.lab.lab
manage_etc_hosts: true
preserve_hostname: false
user@machine:~$
主要言語
Python
スター
119
フォーク
5
平均マージ
5時間 56分
マージ済み PR(30日)
45

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stephrobert/dsoxlab のほかの issue

stephrobert/dsoxlab の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。