VMware - Kickstart Rocky 9¶
Fichier kickstart pour l'installation automatisee de Rocky 9 avec le builder vsphere-iso.
Principe¶
Le builder vsphere-iso utilisé boot_command pour injecter une commande au démarrage de l'installeur. Cette commande pointe vers un fichier kickstart servi par le serveur HTTP intégré de Packer (http_directory).
sequenceDiagram
participant P as Packer
participant VM as VM temporaire
participant HTTP as Serveur HTTP Packer
P->>VM: Cree la VM, attache l'ISO
P->>VM: Envoie boot_command (inst.ks=http://...)
VM->>HTTP: Telecharge ks.cfg
HTTP-->>VM: Fichier kickstart
VM->>VM: Installation automatique
VM-->>P: SSH disponible
P->>VM: Execute Ansible
P->>VM: Convertit en template Fichier kickstart¶
Créez packer-vsphere/http/ks.cfg :
# Rocky 9 Kickstart pour Packer / vSphere
# Installation minimale avec compte packer
# --- Systeme ---
text
eula --agreed
firstboot --disabled
reboot
# --- Langue et clavier ---
lang fr_FR.UTF-8
keyboard fr-latin1
timezone Europe/Paris --utc
# --- Reseau ---
network --bootproto=dhcp --device=ens192 --activate --onboot=yes
network --hostname=rocky9-template
# --- Comptes ---
rootpw --lock
user --name=packer --plaintext --password=packer --groups=wheel
# --- Partitionnement ---
zerombr
clearpart --all --initlabel
autopart --type=lvm --fstype=xfs
# --- Depot ---
url --mirrorlist="https://mirrors.rockylinux.org/mirrorlist?arch=x86_64&repo=BaseOS-9"
# --- Packages ---
%packages --ignoremissing
@^minimal-environment
openssh-server
openssh-clients
sudo
curl
python3
%end
# --- Post-installation ---
%post --erroronfail
# Sudo sans mot de passe pour packer (necessaire pour Ansible become)
echo "packer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/packer
chmod 440 /etc/sudoers.d/packer
# Activer SSH
systemctl enable sshd
# Nettoyer les caches
dnf clean all
rm -rf /var/cache/dnf
%end
Points clés¶
Interface réseau
L'interface ens192 est le nom par défaut sur vSphere avec vmxnet3. Adaptez si votre environnement utilise un autre nommage.
Mot de passe packer
Le mot de passe en clair est acceptable ici car :
- Il est utilisé uniquement pendant le build Packer
- Le template final sera recustomise au déploiement (cloud-init ou vSphere customization)
- Le rôle
nuevolia.system.hardeningdesactivera l'authentification par mot de passe SSH
Mirrorlist
Si votre environnement n'a pas d'accès Internet, remplacez la ligne url par un dépôt local :
Livrable¶
Checklist
Avant de passer à la suite, verifiez que :
- Le fichier
http/ks.cfgest créé - Le dossier
http/est référence dans le template Packer (http_directory = "http") - Le
boot_commandpointe versinst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg