Déployer et enrichir CentOS 8

Avec la sortie de CentOS 8, j’ai eu le besoin de déployer facilement la distribution et de construire des paquets personnels pour l’enrichir. Le déploiement sera fait via un cobbler existant et la construction de RPM avec un système Koji déjà opérationnel.

Cobbler

Il y a peu de chances que votre cobbler connaisse déjà CentOS 8, on va donc les présenter…

On télécharge l’ISO DVD et on le monte afin de rendre le contenu accessible à notre cobbler

sudo mount -o ro CentOS-8-x86_64-1905-dvd1.iso /mnt/centos

On met à jour la liste des signatures

cobbler signature update

On vérifie que la nouvelle distribution est présente

cobbler signature report --name=redhat | grep rhel8
        rhel8

On importe le DVD

cobbler import --path=/mnt/centos --name=CentOS-8-x86_64

On déclare notre second profil, l’installation du mode graphique

cobbler profile add --name=CentOS-8-x86_64-Desktop --distro=CentOS-8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/sample_end.ks --virt-file-size=12 --virt-ram=2048
cobbler profile edit --name CentOS-8-x86_64-Desktop --ksmeta="type=desktop"

On synchronise

cobbler sync

On vérifie le fichier quickstart associé à notre nouvelle distribution

cobbler profile getks --name=CentOS-8-x86_64
tip

Si vous utilisez mon image docker, qui a été créé pour l’article Dockerisation du service cobbler (Dockerisation du service cobbler), il y a quelques modifications à apporter pour pour CentOS 8

  • L’import se fait avec la commande
    cobbler import --path=/mnt --name=CentOS-8-x86_64
  • On modifie le snippet de partitionnement afin de créer par défaut un partition /boot de 1Go (/var/lib/cobbler/snippets/partition_config).
    En effet si la distribution est CentOS 6, la partition /boot fera 200Mo, pour CentOS 7 elle fera 500Mo, mais il n’y avait rien de prévu pour les autres cas.

    diff --git a/snippets/partition_config b/snippets/partition_config
    index 964c122..07b8918 100644
    --- a/snippets/partition_config
    +++ b/snippets/partition_config
    @@ -8,6 +8,8 @@ clearpart --all
     part /boot --size=200 --recommended --asprimary
     #else if $el_version == "rhel7"
     part /boot --size=500 --recommended --asprimary
    +#else
    +part /boot --size=1024 --recommended --asprimary
     #end if
     part pv.01 --size=1024 --grow
     volgroup vg0 pv.01
    
  • On modifie le Dockerfile afin qu’il modifie le fichier /var/lib/cobbler/snippets/func_install_if_enabled
    diff --git a/Dockerfile b/Dockerfile
    index b533575..f410a4a 100644
    --- a/Dockerfile
    +++ b/Dockerfile
    @@ -67,7 +67,7 @@ RUN for kickstart in sample sample_end legacy ; \
         done
     
     # Install vim-enhanced by default and desktop packages if profile have el_type set to desktop (ksmeta)
    -RUN echo -e "@core\n\nvim-enhanced\n#set \$el_type = \$getVar('type', 'minimal')\n#if \$el_type == 'desktop'\n@base\n@network-tools\n@x11\n@graphical-admin-tools\n#set \$el_version = \$getVar('os_version', None)\n#if \$el_version == 'rhel6'\n@desktop-platform\n@basic-desktop\n#else if \$el_version == 'rhel7'\n@gnome-desktop\n#end if\n#end if\nkernel" >> /var/lib/cobbler/snippets/func_install_if_enabled
    +RUN echo -e "@core\nvim-enhanced\n#set \$el_type = \$getVar('type', 'minimal')\n#if \$el_type == 'desktop'\n@base\n@network-tools\n@graphical-admin-tools\n#set \$el_version = \$getVar('os_version', None)\n#if \$el_version == 'rhel6'\n@x11\n@desktop-platform\n@basic-desktop\n#else if \$el_version == 'rhel7'\n@x11\n@gnome-desktop\n#else if \\$el_version == 'rhel8'\n@graphical-server-environment\n#end if\n#end if\nkernel" >> /var/lib/cobbler/snippets/func_install_if_enabled
     
     COPY first-sync.sh /usr/local/bin/first-sync.sh
     COPY entrypoint.sh /entrypoint.sh
    
    

Koji

Ajout des étiquettes

koji add-tag centos-8
koji add-tag --parent centos-8 --arches 'x86_64' centos-8-build

Définition des groupes

koji add-group centos-8-build build
koji add-group centos-8-build srpm-build

Ajout des dépôts externe

koji add-external-repo -t centos-8-build -p 10 centos-8-external-baseos http://mirrors.ircam.fr/pub/CentOS/8/BaseOS/\$arch/os
koji add-external-repo -t centos-8-build -p 11 centos-8-external-appstream http://mirrors.ircam.fr/pub/CentOS/8/AppStream/\$arch/os
koji add-external-repo -t centos-8-build -p 15 centos-8-external-powertools http://mirrors.ircam.fr/pub/CentOS/8/PowerTools/\$arch/os
koji add-external-repo -t centos-8-build -p 20 centos-8-external-extra http://mirrors.ircam.fr/pub/CentOS/8/extras/\$arch/os
koji add-external-repo -t centos-8-build -p 15 centos-8-external-epel http://mirrors.ircam.fr/pub/fedora/epel/8/Everything/\$arch

Ajout de la cible

koji add-target centos-8 centos-8-build

Ajout de paquets à nos groupes

  • build
    koji add-group-pkg centos-8-build build bash bash bzip2 coreutils cpio diffutils \
    findutils gawk gcc grep sed gcc-c++ gzip info patch redhat-rpm-config \
    rpm-build shadow-utils tar unzip util-linux which make \
    redhat-release centos-release xz
  • srpm-build
    koji add-group-pkg centos-8-build srpm-build bash \
    redhat-release centos-release make redhat-rpm-config rpm-build shadow-utils

On force la régénération du dépôt

koji regen-repo centos-8-build

On n’a plus qu’à ajouter nos paquets et laisser la magie opérer

koji add-pkg --owner tartare centos-8 pkbs-release

Posted

in

, ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *