Tu prendras bien un petit preseed ?

Allay on va commencer par le commencement. Il y a quelques temps j’avais pas mal galéré pour faire un preseed complet.

C’est chose faite.


Le playbook (qui passe par la console de management) va forcer le serveur à boot sur l’ISO au prochain boot, reboot le serveur, qui va donc boot sur l’ISO d’installation… avec le preseed. Et ensuite l’installation se fait toute seule. Tranquille, pépouze.

Bon ok, tu n’as rien compris. Je pars du principe qu’on installe une Debian ici, vu que c’est ce que j’utilise pour mes serveurs.Un fichier de preseed est un fichier que tu vas charger pendant l’installation et qui va répondre à ces questions qui te font perdre un temps précieux, surtout si tu dois installer 15 ou 20 serveurs. L’installation sera lancée et se fera toute seule, sans intervention humaine (sauf si ça plante, parce que oui, des fois ça marche pas).Pour savoir comment renseigner le preseed, il vaut mieux faire déjà une installation de base, noter les réponses que l’on souhaite, puis construire le preseed avec ce qu’on veut.Pour faciliter les choses et ne pas avoir à renseigner ce preseed (qui serait une intervention humaine), l’ISO sera regénérée avec le preseed.il vous faut donc un fichier de preseed configuré avec Amour et bien entendu votre ISO.

Je vous glisse le fichier de preseed que j’ai plus ou moins utilisé.

!!! ATTENTION !!!

Le fichier de preseed doit servir de base uniquement. Vous devez l’adapter à VOTRE environnement. J’ai retiré ce qui était trop spécifique au mien.

### Localization
# Preseeding only locale sets language, country and locale.
# d-i debian-installer/locale string fr_FR.UTF-8
d-i debian-installer/locale string fr_FR.UTF-8

# Keyboard selection.
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string fr_FR.UTF-8

d-i debian-installer/language string fr
d-i debian-installer/country string FR
d-i debian-installer/locale string fr_FR.UTF-8
d-i keyboard-configuration/xkb-keymap select fr(latin9)

### Network configuration
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto

# Just in case our DHCP server is busy.
d-i netcfg/dhcp_timeout string 60

# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain

# Added by @analytically: always install the server kernel
d-i base-installer/kernel/override-image string linux-server

### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.fr.debian.org
d-i mirror/http/directory string /debian

### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true

# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string Europe/Paris

# Controls whether to use NTP to set the clock during the install
# d-i clock-setup/ntp boolean true
# d-i clock-setup/ntp-server string NTP SERVER 

### Partitioning
d-i partman-auto/disk string /dev/sda

d-i partman/early_command string [ -b /dev/sda ] && dd if=/dev/zero of=/dev/sda bs=1024 count=1024 | | true

d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-lvm/device_remove_lvm_span boolean true

#Set force UEFI to true - Attention
d-i partman-efi/non_efi_system boolean true

# The presently available methods are:
# - regular: use the usual partition types for your architecture
# - lvm: use LVM to partition the disk
# - crypto: use LVM within an encrypted partition
d-i partman-auto/method string lvm

# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true

# For LVM partitioning, you can select how much of the volume group to use
# for logical volumes.
#d-i partman-auto-lvm/guided_size string max

# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /usr, /var, and /tmp partitions
d-i partman-auto/choose_recipe select multi

# If you just want to change the default filesystem from ext3 to something
# else, you can do that without providing a full recipe.
d-i partman/default_filesystem string ext4

# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

### Base system installation
### Account setup
# Alternatively, to skip creation of a normal user account.
d-i passwd/make-user boolean true
# Skip creation of a root account (normal user account will be able to
# use sudo).
d-i passwd/root-login boolean false

# The installer will warn about weak passwords. If you are sure you know
# what you're doing and want to override it, uncomment this.
d-i user-setup/allow-password-weak boolean true

#d-i passwd/root-password password changeme
#d-i passwd/root-password-again password changeme

# Set to true if you want to encrypt the first user's home directory.
d-i user-setup/encrypt-home boolean false

# To create a normal user account.
# d-i passwd/user-fullname string USERNAME
# d-i passwd/username string USERNAME
# d-i passwd/user-password-crypted password PASSWORD
# d-i passwd/user-uid string UID

### Apt setup
d-i apt-setup/non-free boolean true
d-i apt-setup/contrib boolean true
tasksel tasksel/first multiselect standard, ssh-server

# Verbose output and no boot splash screen
d-i debian-installer/quiet boolean false
d-i debian-installer/splash boolean false

### Boot loader installation
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true

# This one makes grub-installer install to the MBR if it also finds some other
# OS, which is less safe as it might not be able to boot that other OS.
d-i grub-installer/with_other_os boolean false

# Wait for two seconds in grub
d-i grub-installer/timeout string 2

d-i grub-installer/bootdev string /dev/sda

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

Après ça vous avez une install de base normalement avec le ssh. Il suffit ensuite de lancer un second playbook pour finir l’install avec les softs et les confs que vous voulez. Je ferai sans doute un post avec un playbook de base Ansible. Si tu n’as strictement rien compris à ça (et si ça t’intéresse), je te propose un peu de lecture : 

Et si tu as des questions, comme d’habitude, n’hésite pas 😉

Partager l'article
hackorn
https://blog.hackorn.net

Un peu magique, un peu trash, un peu tout, surtout rien.

Leave a Reply