Thank you for reading this post, don't forget to subscribe!
Cobbler-это Linux система, для автоматической установки и обновления операционных систем по сети. Незаменимая вещь для системных администраторов которым по долгу службы приходится разворачивать систему сразу на нескольких десятков машин.
Установка Cobbler
Устанавливаем репозиторий epel-release
1 |
yum install epel-release -y |
Устанавливаем сам cobbler с необходимыми пакетами
1 |
yum install cobbler cobbler-web dnsmasq syslinux pykickstart xinetd httpd dhcp* debmirror pykickstart bind tftp -y |
Запускаем cobbler и другие сервисы необходимые для работы и добавляем их в автозагрузку
1 2 3 4 5 6 |
systemctl start cobblerd ; systemctl enable cobblerd systemctl start httpd ; systemctl enable httpd systemctl start xinetd ; systemctl enable xinetd systemctl start rsyncd ; systemctl enable rsyncd systemctl start dhcpd ; systemctl enable dhcpd systemctl enable tftp ; systemctl start tftp |
Если запущен selinux то отключаем его, редактируем файл /etc/selinux/config
1 |
SELINUX=disabled |
Перезагружаем сервер
1 |
shutdown –r now |
Добавляем разрешения в firewalld
1 2 3 4 5 6 7 |
firewall-cmd --add-port=80/tcp --permanent firewall-cmd --add-port=443/tcp --permanent firewall-cmd --add-service=dhcp --permanent firewall-cmd --add-port=69/tcp --permanent firewall-cmd --add-port=69/udp --permanent firewall-cmd --add-port=4011/udp --permanent firewall-cmd --reload |
подключаемся к веб интерфейсу
1 |
<strong>https</strong>://ip address/cobbler_web/ |
Вводим логин пароль cobbler/cobbler
Если вы видите эту страницу, то первую часть установки можно считать завершенной. Все дальнейшие настройки можно делать как через консоль так и через веб интерфейс.
Настройка Cobbler
Задаем пароль root. Этот пароль будет устанавливаться в новых устанавливаемых системах, если не задан в kickstart файле. Для этого генерим хэш пароля
1 |
openssl passwd -1 |
[root@cobbler ~]# openssl passwd -1
Password:
Verifying - Password:
$1$ARiIyBMV$VYePnl2guqtp3lHKqPfI10
Сохраняем оригинальный файл /etc/cobbler/settings на всякий случай.
1 |
cp /etc/cobbler/settings /etc/cobbler/settings.orig |
Редактируем settings приведя его к следующему виду
1 2 3 4 5 6 |
default_password_crypted: "$1$ARiIyBMV$VYePnl2guqtp3lHKqPfI10" manage_dhcp: 1 manage_dns: 1 pxe_just_once: 1 next_server: 192.168.1.170 server: 192.168.1.170 |
В параметр default_password_crypted прописываем сгенерированный хэш
next_server – адрес tftp сервера
server – ip cobbler сервера У нас tftp и cobber сервер на одной машине, поэтому указываем ip адрес сервера.
Правим файл: /etc/cobbler/modules.conf
приводим к виду:
1 2 3 4 5 |
<span class="p p-Indicator">[</span><span class="nv">dns</span><span class="p p-Indicator">]</span> <span class="l l-Scalar l-Scalar-Plain">module = manage_dnsmasq</span> <span class="l l-Scalar l-Scalar-Plain">[dhcp]</span> <span class="l l-Scalar l-Scalar-Plain">module = manage_dnsmasq</span> |
Редактируем файл /etc/cobbler/dhcp.template, в нем прописываем подсеть которая будет выдаваться по DHCP клиентам
192.168.1.1 - это наш gateway
Отредактируем файл /etc/cobbler/dnsmasq.template указав диапазон адресов выдаваемых PXE клиентам
Перезапускаем cobbler
1 |
systemctl restart cobblerd |
выполняем
1 |
cobbler sync |
cat /etc/dhcp/dhcpd.conf
[codesyntax lang="php"]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# ****************************************************************** # Cobbler managed dhcpd.conf file # generated from cobbler dhcp.conf template (Tue Jun 16 10:22:38 2020) # Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes # in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be # overwritten. # ****************************************************************** ddns-update-style interim; allow booting; allow bootp; ignore client-updates; set vendorclass = option vendor-class-identifier; option pxe-system-type code 93 = unsigned integer 16; subnet 192.168.1.0 netmask 255.255.255.0 { <strong>option routers 192.168.1.1;</strong> option domain-name-servers 192.168.1.1; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.1.175 192.168.1.254; default-lease-time 21600; max-lease-time 43200; next-server 192.168.1.170; class "pxeclients" { match if substring (option vendor-class-identifier, 0, 9) = "PXEClient"; if option pxe-system-type = 00:02 { filename "ia64/elilo.efi"; } else if option pxe-system-type = 00:06 { filename "grub/grub-x86.efi"; } else if option pxe-system-type = 00:07 { filename "grub/grub-x86_64.efi"; } else if option pxe-system-type = 00:09 { filename "grub/grub-x86_64.efi"; } else { filename "pxelinux.0"; } } } # group for Cobbler DHCP tag: default group { } |
[/codesyntax]
[codesyntax lang="php"]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
[root@cobbler ~]# <strong>cobbler sync</strong> task started: 2020-06-16_112654_sync task started (id=Sync, time=Tue Jun 16 11:26:54 2020) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders copying: /usr/share/syslinux/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 copying: /usr/share/syslinux/menu.c32 -> /var/lib/tftpboot/menu.c32 copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.manage_genders running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** <strong>TASK COMPLETE</strong> *** |
[/codesyntax]
Если видим TASK COMPLETE значит синхронизация прошла успешно Проверяем что все нормально
1 |
cobbler check |
Вывод показывает следующее
[codesyntax lang="php"]
1 2 3 4 5 6 7 8 9 10 |
[root@cobbler ~]# <strong>cobbler check</strong> The following are potential configuration items that you may want to fix: 1 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements. 2 : comment out 'dists' on /etc/debmirror.conf for proper debian support 3 : comment out 'arches' on /etc/debmirror.conf for proper debian support 4 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them Restart cobblerd and then run 'cobbler sync' to apply changes. |
[/codesyntax]
В общем критических замечаний нет, ну давайте исправим и эти Запускаем команду
1 |
cobbler get-loaders |
[codesyntax lang="php"]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@cobbler ~]# <strong>cobbler get-loaders</strong> task started: 2020-06-16_113030_get_loaders task started (id=Download Bootloader Content, time=Tue Jun 16 11:30:30 2020) downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi *** TASK COMPLETE *** |
[/codesyntax]
Редактируем /etc/debmirror.conf и /etc/debmirror.conf
1 2 |
sed -i "s/^@dists/#@dists/" /etc/debmirror.conf sed -i "s/^@arches/#@arches/" /etc/debmirror.conf |
Устанавливаем fence-agents
1 |
yum install fence-agents –y |
снова проверяем кобблер
1 |
cobbler check |
Теперь вывод показывает что никаких замечаний нет
[root@cobbler ~]# cobbler check
No configuration problems found. All systems go.
Подготовка установочного образа системы
Следующим шагом монтируем iso образ. Загрузим на наш сервер iso образ какой нибудь системы, например Centos 7
1 2 |
сd /tmp wget https://mirror.yandex.ru/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-2003.iso |
Монтируем iso образ в mnt
1 |
mount -t iso9660 -o loop,ro /tmp/CentOS-7-x86_64-Minimal-2003.iso /mnt |
Переходим в веб интерфейс и импортируем образ, для этого переходим на вкладку Import DVD, Заполняем поля и нажимаем Run
=============================
Или через консоль
1 |
cobbler import --arch=x86_64 --path=/mnt --name=CentOS7 |
Если получили ошибку
1 |
No signature matched in /var/www/cobbler/ks_mirror/CentOS7-x86_64 |
Удаляем директорию /var/www/cobbler/ks_mirror/CentOS7-x86_64
1 |
rm -rf /var/www/cobbler/ks_mirror/CentOS7-x86_64 |
Обнавляем сигнатуру и перезапускаем сервис.
1 2 |
cobbler signature update systemctl restart cobblerd |
Снова импортируем образ системы.
1 |
cobbler import --arch=x86_64 --path=/mnt --name=CentOS7 |
Если все успешно вы увидите следующий вывод
Смотрим смонтированные образы
1 |
cobbler distro list |
Или через веб интерфейс меню Distros
Информацию о сборке можно посмотреть командой
1 |
cobbler distro report --name=CentOS7-x86_64 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@cobbler mnt]# <strong>cobbler distro report --name=CentOS7-x86_64</strong> Name : centos7-x86_64 Architecture : x86_64 TFTP Boot Files : {} Breed : redhat Comment : Fetchable Files : {} Initrd : /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/initrd.img Kernel : /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/vmlinuz Kernel Options : {} Kernel Options (Post Install) : {} Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/centos7-x86_64'} Management Classes : [] OS Version : rhel7 Owners : ['admin'] Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Template Files : {} |
Создание kickstart файла для установки
Следующим шагом создаем Kickstart файл. Назовем его Centos7.ks. В этом файле задаем параметры для автоматической установки, такие как пароль для пользователя root, настройки сети и т.д. Директория для kickstart файлов /var/lib/cobbler/kickstarts.
1 |
vi /var/lib/cobbler/kickstarts/centos7.ks |
[codesyntax lang="php"]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
<strong>cat /var/lib/cobbler/kickstarts/centos7.ks</strong> #version=DEVEL # System authorization information auth --enableshadow --passalgo=sha512 # Use CDROM installation media url --url="http://192.168.1.170/cblr/links/centos7-x86_64/" # Use graphical install graphical # Run the Setup Agent on first boot firstboot --enable ignoredisk --only-use=sda # Keyboard layouts keyboard --vckeymap=us --xlayouts='us' # System language lang en_US.UTF-8 # Network information network --bootproto=dhcp --device=enp0s3 --noipv6 --onboot=on network --hostname=centos7_from_cobbler8 # Root password rootpw --iscrypted $1$P2uemhqj$eu1Xb.p5Vd8AyR30ZusE11 # System services services --disabled="chronyd" # System timezone timezone Asia/Bishkek --isUtc --nontp # System bootloader configuration bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" install clearpart --drives=sda --all --initlabel #part swap --asprimary --fstype="swap" --size=1024 part /boot --fstype xfs --size=500 part pv.01 --size=1 --grow volgroup vg01 pv.01 logvol / --fstype xfs --name=root --vgname=vg01 --size=2048 logvol /usr --fstype xfs --name=usr --vgname=vg01 --size=4096 logvol /var --fstype xfs --name=var --vgname=vg01 --size=4096 logvol /tmp --fstype xfs --name=tmp --vgname=vg01 --size=1024 logvol swap --fstype="swap" --name=swap --vgname=vg01 --size=2048 # Reboot after installation reboot --eject #repo --install --name=epel --baseurl="https://dl.fedoraproject.org/pub/epel/7/x86_64/" #%post #rpm --import "http://192.168.1.170/cblr/links/centos7-x86_64/RPM-GPG-KEY-CentOS-7" #rpm --import "http://192.168.1.170/cblr/links/centos7-x86_64/RPM-GPG-KEY-elrepo.org" #%end %packages @^minimal @core kexec-tools chrony sudo %end %post --log=/root/anaconda-postinstall.log #!/bin/bash yum install epel-release -y yum install vim wget htop net-tools -y yum install httpd nginx -y %end |
[/codesyntax]
Обновляем профиль
1 2 3 |
<strong>cobbler profile edit --name=CentOS7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7.ks cobbler sync</strong> |
необязательная часть (если вручную ключи импортируешь то надо)
wget https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
mv RPM-GPG-KEY-elrepo.org /var/www/cobbler/links/centos7-x86_64/
Запуск установки по сети
Включаем компьютер на который нужно установить систему, в качестве источника загрузки выбираем загрузку по сети Net boot. Если все сделано правильно, то мы увидим как наш компьютер получает ip адрес и начинает загружать по tftp ОС
отредактировать данное окно можно вот тут:
/var/lib/tftpboot/pxelinux.cfg/default
большой список тут
https://www.golinuxcloud.com/rhel-centos-8-kickstart-example-generator/