Actualiser template/template.sh
Correction d'une erreur sur le chemin de l'image cloud-init ainsi qu'ajout d'informations lors du déroulement du script
This commit is contained in:
parent
141594193c
commit
f829afd2df
@ -1,5 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
GREEN="32"
|
||||
LIGHTCYAN="96"
|
||||
BOLDGREEN="\e[1;${GREEN}m"
|
||||
BOLDLIGHTCYAN="\e[1;${LIGHTCYAN}m"
|
||||
ENDCOLOR="\e[0m"
|
||||
|
||||
template_id=$1
|
||||
template_name=$2
|
||||
cloudinit_img=$3
|
||||
@ -12,27 +18,38 @@ ci_password="changeme"
|
||||
ci_network="dhcp"
|
||||
|
||||
# Création de la VM
|
||||
echo -e "\n${BOLDGREEN}Création de la MV${ENDCOLOR}" && sleep 2
|
||||
qm create $template_id --memory 2048 --core 2 --name $template_name --net0 virtio,bridge=vmbr0 --agent 1
|
||||
|
||||
# Import disque cloud-init
|
||||
qm importdisk $template_id $cloudinit_img/jammy-server-cloudimg-amd64.img Datastore
|
||||
echo -e "\n${BOLDGREEN}Import image Cloud-INIT${ENDCOLOR}" && sleep 2
|
||||
qm importdisk $template_id $cloudinit_img Datastore
|
||||
|
||||
# Création disque de stockage
|
||||
echo -e "\n${BOLDGREEN}Création du disque de stockage${ENDCOLOR}" && sleep 2
|
||||
qm set $template_id --scsihw virtio-scsi-pci --scsi0 Datastore:$template_id/vm-$template_id-disk-0.raw
|
||||
|
||||
# Activation cloud-init
|
||||
echo -e "\n${BOLDGREEN}Activation de Cloud-INIT${ENDCOLOR}" && sleep 2
|
||||
qm set $template_id --ide2 $storage:cloudinit
|
||||
|
||||
# Mise en place du boot sur cloud-init
|
||||
echo -e "\n${BOLDGREEN}Choix du boot${ENDCOLOR}" && sleep 2
|
||||
qm set $template_id --boot c --bootdisk scsi0
|
||||
|
||||
# Mise en place serial vga obligatoire pour cloud-init
|
||||
echo -e "\n${BOLDGREEN}Mise en place du serial vga obligatoire${ENDCOLOR}" && sleep 2
|
||||
qm set $template_id --serial0 socket --vga serial0
|
||||
|
||||
# Paramètres cloud-init
|
||||
echo -e "\n${BOLDGREEN}Initialisation paramètres Cloud-INIT${ENDCOLOR}" && sleep 2
|
||||
qm set $template_id -ciuser $ci_username
|
||||
qm set $template_id -cipassword $ci_password
|
||||
qm set $template_id --ipconfig0 ip=$ci_network
|
||||
|
||||
# Création template
|
||||
echo -e "\n${BOLDGREEN}Transformation de la VM en template${ENDCOLOR}" && sleep 2
|
||||
qm template $template_id
|
||||
|
||||
# Fin du script
|
||||
echo -e "\n${BOLDLIGHTCYAN}Template ${2} terminé${ENDCOLOR}\n"
|
Loading…
x
Reference in New Issue
Block a user