Installation/Cobbler

De TartareFR
Aller à la navigation Aller à la recherche

Introduction

Cobbler[1] est un serveur d'installation qui permet d'installer facilement et automatiquement des systèmes d'exploitations, virtualisés ou non via PXE.

Sur CentOS 7, les principales différences par rapport à une installation sur CentOS 6 sont:

  • Pas de paquet <package>debmirror</package> officiellement disponible
  • Disparition du daemon rsync
  • Remplacement des commandes <app>iptables</app> par <app>firewalld</app>

Installation

Modification du service DHCP

Si le serveur DHCPd n'est pas la même machine que le serveur cobbler, il faut déclarer le serveur Cobbler sur le serveur DHCPd:

Fichier <path>/etc/dhcp/dhcpd.conf</path>

...
 allow booting;
 allow bootp;
 filename "pxelinux.0";
 next-server 192.168.0.205;
...

On redémarre le service DHCPd

service dhcpd restart

Installation de cobbler

Sur un serveur fraichement installé en CentOS 7:

  • Mise en place du nom d'hôte
    hostnamectl set-hostname cobbler.home.net
  • Redémarrage du serveur
  • Installation du dépôt EPEL
    rpm -Uvh http://mirror.ibcp.fr/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
  • Installation des paquets
    yum -y install cobbler pykickstart tftp
  • Activation du service tftpd (xinetd)
    sed -i -e '/disable/ s/yes/no/' /etc/xinetd.d/tftp
  • Démarrage et activation des services concernés: httpd, xinetd et cobblerd
    for service in xinetd httpd cobblerd ; do systemctl start $service ; systemctl enable $service ; done

Configuration

Firewall

  • Open for HTTP
    firewall-cmd --permanent --add-service=http
  • Open for HTTPS
    firewall-cmd --permanent --add-service=https
  • Open for TFTP
    firewall-cmd --permanent --add-service=tftp
  • Open for Cobbler
    firewall-cmd --permanent --add-port=25151/tcp
  • Open for TFTP
    firewall-cmd --permanent --add-port=69/tcp
  • Reload firewall
    firewall-cmd --reload

SELinux

Au niveau configuration, on va dans un premier temps s'occuper de SELinux[2].

setsebool -P httpd_can_network_connect true
setsebool -P cobbler_can_network_connect true
semanage fcontext -a -t public_content_t "/var/lib/tftpboot/.*"
restorecon -Rv /var/lib/tftpboot

Cobbler

Puis dans le fichier de configuration <path>/etc/cobbler/settings</path>, on va:

  • Définir un mot de passe crypté qui sera le mot de passe root pour les machines installées en PXE
  • Modifier l'adresse IP du serveur cobbler.

On commence donc par créer le mot de passe crypté à l'aide d'openssl.

openssl passwd -1

On peut donc maintenant éditer le fichier de configuration du serveur cobbler: Fichier <path>/etc/cobbler/settings</path>

default_password_crypted: <mot-de-passe-crypté>
next_server: 192.168.0.205
server: 192.168.0.205

On va maintenant télécharger les boot-loaders

cobbler get-loaders

Redémarrage du cobbler

systemctl restart cobblerd

Synchronisation

cobbler sync

Et vérification

cobbler check
No configuration problems found.  All systems go.

Cobbler est maintenant correctement configuré.

Ajout de distributions

  • On monte l'image ISO du DVD
    mount -t iso9660 -o loop,ro /downloads/CentOS-5.5-x86_64-core.iso /mnt/
  • On l'importe dans cobbler
    cobbler import --path=/mnt --name=CentOS-5-x86_64
Important.png
Validation des modifications
On applique les changements en relançant le daemon et en lançant la synchronisation
systemctl restart cobbler && cobbler sync

Suppression de distributions

Pour supprimer une distribution:

  • On supprime le(s) profile(s) qui nécessite la distribution
    cobbler profile remove --name=CentOS-6-x86_64
  • On supprime la distribution
    cobbler distro remove --name=CentOS-6-x86_64
Important.png
Validation des modifications
On applique les changements en relançant le daemon et en lançant la synchronisation
systemctl restart cobbler && cobbler sync

Francisation

Modification des fichiers kickstart par défaut.

Pour toutes les distributions (boot PXE rescue)

Modification du fichier <path>/var/lib/cobbler/kickstarts/pxerescue.ks</path>

lang fr_FR
keyboard "fr-latin9"

Spécifiquement pour les distribution Debian/Ubuntu

Modification du fichier <path>/var/lib/cobbler/kickstarts/sample.seed</path>

d-i debian-installer/locale string fr_FR
d-i keyboard-configuration/layoutcode string fr-latin9
d-i time/zone string Europe/Paris

Modification du fichier <path>/var/lib/cobbler/kickstarts/sample_old.seed</path>

d-i     console-keymaps-at/keymap       select  fr-latin9
tzsetup-udeb    time/zone       select  Europe/Paris

Spécifiquement pour les distribution Redhat/Centos/Fedora

Modification du fichier <path>/var/lib/cobbler/kickstarts/sample.ks</path>, du fichier <path>/var/lib/cobbler/kickstarts/sample_end.ks</path> et du fichier <path>/var/lib/cobbler/kickstarts/legacy.ks</path>

keyboard fr-latin9
lang fr_FR
timezone --utc Europe/Paris
Important.png
Validation des modifications
On applique les changements en relançant le daemon et en lançant la synchronisation
systemctl restart cobbler && cobbler sync

Editer la taille des partitions avec les snippets

Par défaut, cobbler utilise tout l'espace du disque dur qu'il assigne à la partition /, on peut vouloir définir les partitions en fonction de la taille du disque. Pour cela, nous allons utiliser les snippets kickstart de cobbler. Les snippets (ou extraits) de kickstart sont un moyen de réutiliser les blocs de code commun entre les fichiers kickstart.

Donc pour pouvoir définir la taille d'une ou plusieurs partitions systèmes on procède ainsi:

On créé un snippet: fichier <path>/var/lib/cobbler/snippets/partition_config</path>

part /boot --fstype=ext4 --size=200 
part pv.01 --size=1024 --grow 
part swap --size=1024   --maxsize=2048 
volgroup vg0 pv.01 
logvol / --vgname=vg0 --name=lv0 --size=1024 --maxsize=3072 --grow
logvol /var --vgname=vg0 --name=lv1 --size=512 --maxsize=1024 --grow

Dans tous les fichiers kickstart (smaple*.ks), on remplace la ligne

autopart

par

$SNIPPET('partition_config')
Important.png
Validation des modifications
On applique les changements en relançant le daemon et en lançant la synchronisation
systemctl restart cobbler && cobbler sync

Interface Web

On va maintenant installer l'interface web permettant l'administration de cobbler puis la configurer:

yum install cobbler-web

Il faut s'assurer que le fichier <path>/etc/cobbler/modules.conf</path> contienne bien les lignes suivantes:

[authentication]
module = authn_configfile

[authorization]
module = authz_allowall

On créer le fichier de mot de passe <path>/etc/cobbler/users.digest</path> en mettant le login à cobbler et le mot de passe à cobbler

htdigest -c /etc/cobbler/users.digest "Cobbler" cobbler

On redémarre les services cobbler et apache

systemctl restart cobblerd
systemctl restart httpd

On peut maintenant se rendre sur l'interface avec un navigateur avec l'URL https://<cobbler_addr>/cobbler_web

Warning.png
URL cobbler_web
Dans sa nouvelle version, cobbler_web rend obligatoire le protocole https.

Trucs et astuces

Obtenir la liste des profiles

cobbler profile list
   CentOS-5-i386
   CentOS-5-x86_64
   CentOS-5-xen-i386
   CentOS-5-xen-x86_64
   CentOS-6-i386
   CentOS-6-x86_64
   CentOS-7-x86_64

Obtenir la liste des distributions

cobbler distro list
   CentOS-5-i386
   CentOS-5-x86_64
   CentOS-5-xen-i386
   CentOS-5-xen-x86_64
   CentOS-6-i386
   CentOS-6-x86_64
   CentOS-7-x86_64

Obtenir la configuration d'une distribution

cobbler distro report --name=CentOS-7-x86_64
Name                           : CentOS-7-x86_64
Architecture                   : x86_64
TFTP Boot Files                : {}
Breed                          : redhat
Comment                        : 
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7-x86_64'}
Management Classes             : []
OS Version                     : rhel7
Owners                         : ['admin']
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Template Files                 : {}

Valider les fichiers kickstart

cobbler validateks
task started: 2014-10-30_100015_validateks
task started (id=Kickstart Validation, time=Thu Oct 30 10:00:15 2014)
----------------------------
osversion: rhel5
checking url: http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-5-i386
running: /usr/bin/ksvalidator -v "rhel5" "http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-5-i386"
received on stdout: 
received on stderr: 
----------------------------
osversion: rhel6
checking url: http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-6-i386
running: /usr/bin/ksvalidator -v "rhel6" "http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-6-i386"
received on stdout: 
received on stderr: 
----------------------------
osversion: rhel5
checking url: http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-5-xen-i386
running: /usr/bin/ksvalidator -v "rhel5" "http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-5-xen-i386"
received on stdout: 
received on stderr: 
----------------------------
osversion: rhel5
checking url: http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-5-x86_64
running: /usr/bin/ksvalidator -v "rhel5" "http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-5-x86_64"
received on stdout: 
received on stderr: 
----------------------------
osversion: rhel5
checking url: http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-5-xen-x86_64
running: /usr/bin/ksvalidator -v "rhel5" "http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-5-xen-x86_64"
received on stdout: 
received on stderr: 
----------------------------
osversion: rhel6
checking url: http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-6-x86_64
running: /usr/bin/ksvalidator -v "rhel6" "http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-6-x86_64"
received on stdout: 
received on stderr: 
----------------------------
osversion: rhel7
checking url: http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.0.205/cblr/svc/op/ks/profile/CentOS-7-x86_64"
received on stdout: 
received on stderr: 
*** all kickstarts seem to be ok ***
*** TASK COMPLETE ***

Obtenir le fichier kickstart d'une distribution

cobbler profile getks --name=CentOS-7-x86_64

Trucs et astuces concernant Koan

Modifier les valeurs par défaut d'un profil concernant:

  • la taille du disque virtuel
    cobbler profile edit --name=CentOS-7-x86_64 --virt-file-size=8
  • le nom de l'interface du bridge
    cobbler profile edit --name=CentOS-7-x86_64 --virt-bridge=virbr0
  • la RAM allouée
    cobbler profile edit --name=CentOS-7-x86_64 --virt-ram=1024
  • le nombre de CPU
    cobbler profile edit --name=CentOS-7-x86_64 --virt-cpus=2

Koan

Il faut modifier la configuration de cobbler: fichier /etc/cobbler/settings

default_virt_bridge: virbr0
default_virt_file_size: 8
default_virt_ram: 1024
default_virt_type: qemu

Koan permet l'installation de machine virtuelle. Koan signifie: kickstart over a network, on l'utilise donc sur un serveur de virtualisation afin de nous installer des machines virtuelles via cobbler.

koan --virt --profile=CentOS-6-x86_64 --server=192.168.0.205 --virt-name=test --virt-type=kvm \
 --qemu-net-type=virtio --qemu-disk-type=virtio --virt-bridge=virbr0

Références