yum安装cobbler
[root@localhost ~]# yum install -y net-tools
[root@localhost ~]# yum install -y httpd dhcp tftp cobbler cobbler-web
[root@localhost ~]# yum install xinetd
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
[root@localhost ~]# systemctl start cobblerd
[root@localhost ~]# systemctl enable cobblerd
[root@localhost ~]# vim /etc/cobbler/settings
....................
server: 192.168.4.15
next_server: 192.168.4.15
....................
virt_auto_boot: 1
....................
[root@localhost ~]# cobbler get-loaders
[root@localhost ~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
[root@localhost ~]# systemctl enable rsyncd
[root@localhost ~]# systemctl start rsyncd
启动xinetd
[root@localhost ~]# systemctl restart xinetd
[root@localhost ~]# systemctl enable xinetd
[root@localhost ~]# yum install pykickstart -y
设置密码、随机值123456 密码123456
[root@localhost ~]# openssl passwd -1 -salt '123456' '123456'
$1$123456$wOSEtcyiP2N/IfIl15W6Z0
更改默认密码为:
[root@localhost ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$123456$wOSEtcyiP2N/IfIl15W6Z0"
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# vim /etc/cobbler/settings
manage_dhcp: 1
第一次修改模板文件。修改模板文件,生成dhcp配置文件。大致更改的地方有
[root@localhost ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.4.0 netmask 255.255.255.0 {
option routers 192.168.4.2;
option domain-name-servers 192.168.4.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.4.100 192.168.4.254;
...................
重启cobblerd
[root@localhost ~]# systemctl restart cobblerd
[root@localhost ~]# cobbler sync
[root@localhost ~]# vim start.sh
#!/bin/bash
systemctl restart httpd
systemctl restart dhcpd
systemctl restart tftp
systemctl restart cobblerd
systemctl restart xinetd
systemctl restart rsyncd
preseed文件参考网址如下:
live、desktop的ubuntu18.04镜像不能使用cobller做为iso导入。请使用server-amd64。附带下载连接地址如下:
cobbler+ubuntu不能使用kickstart的cfg文件的格式,做为自动化菜单安装的实现文件。ubuntu操作系统使用ks.cfg文件会被强制转为preseed文件内容实现。所以,附带以下ubuntu.seed文件内容跟,参考。
CentOS7.cfg文件内容
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$cGHsDwpI$T9DXXY71ndF0Gp9F9mT4f/
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=ens33
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# Use network installation
url --url=$tree
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=4096
part / --fstype="xfs" --grow --size=1
%packages
@^minimal
@core
@development
kexec-tools
wget
vim
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%post
systemctl disable postfix.service
%end
[root@localhost ~]# mount CentOS-7-x86_64-DVD-1908.iso /mnt/
[root@localhost ~]# cobbler import --path=/mnt/ --name=Centos-7 --arch=x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS7.cfg
[root@localhost ~]# cobbler list
distros:
Centos-7-x86_64
profiles:
Centos-7-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
ubuntu17.04.seed文件内容
[root@localhost ~]# vim /var/lib/cobbler/kickstarts/ubuntu17.cfg
# Mostly based on the Ubuntu installation guide
# https://help.ubuntu.com/18.04/installation-guide/
# Debian sample
# https://www.debian.org/releases/stable/example-preseed.txt
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# Keyboard selection.
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select us
d-i keyboard-configuration/toggle select No toggling
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/variantcode string
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
#set $myhostname = $getVar('hostname',$getVar('name','cobbler')).replace("_","-")
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string $myhostname
#d-i netcfg/get_hostname string unassigned-hostname
# If non-free firmware is needed for the network or other hardware, you can
# configure the installer to always try to load it, without prompting. Or
# change to false to disable asking.
# d-i hw-detect/load_firmware boolean true
# NTP/Time Setup
d-i time/zone string Asia/Shanghai
d-i clock-setup/utc boolean true
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp.ubuntu.com
# Setup the installation source
d-i mirror/country string manual
d-i mirror/http/hostname string $http_server
d-i mirror/http/directory string $install_source_directory
d-i mirror/http/proxy string
#set $os_v = $getVar('os_version','')
#if $breed == "ubuntu" and $os_v and $os_v.lower() != 'precise'
# Required at least for ubuntu 12.10+ , so test os_v is not precise. Olders versions are not supported anymore
d-i live-installer/net-image string http://$http_server/cobbler/links/$distro_name/install/filesystem.squashfs
#end if
# Suite to install.
# d-i mirror/suite string precise
# d-i mirror/udeb/suite string precise
# Components to use for loading installer components (optional).
#d-i mirror/udeb/components multiselect main, restricted
# Disk Partitioning
# Use LVM, and wipe out anything that already exists
#d-i partman-auto/choose_recipe select boot-root
#d-i partman-auto/method string regular
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-md/device_remove_md boolean true
#d-i partman/default_filesystem string ext4
#d-i partman-partitioning/confirm_write_new_label boolean true
#d-i partman-auto/choose_recipe select finish
#d-i partman/confirm boolean true
#d-i partman/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman/alignment select cylinder
d-i partman/confirm boolean true
d-i partman-basicfilesystems/no_swap boolean false
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm_nooverwrite boolean true
d-i grub-installer/only_debian boolean true
#d-i grub-installer/bootdev string /dev/sda
#d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/expert_recipe string \
boot-root :: \
1024 1 1024 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
1 3 -1 ext4 \
$primary{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
4096 2 4096 linux-swap \
$primary{ } \
method{ swap } format{ } \
.
# 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 finish
#d-i partman/confirm boolean true
#d-i partman/confirm_nooverwrite boolean true
#d-i partman/mount_style select uuid
# 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
# root account and password
#d-i passwd/root-login boolean true
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password $default_password_crypted
d-i passwd/make-user boolean true
d-i passwd/user-fullname string ubuntu
d-i passwd/username string ubuntu
d-i passwd/user-password-crypted password $default_password_crypted
# skip creation of a normal user account.
#d-i passwd/make-user boolean false
#d-i passwd/make-user boolean true
#d-i passwd/user-fullname string ubuntu
#d-i passwd/username string ubuntu
#d-i passwd/user-password password $default_password_crypted
#d-i passwd/user-password-again password $default_password_crypted
#d-i user-setup/allow-password-weak boolean true
#d-i user-setup/encrypt-home boolean false
#d-i passwd/user-default-groups string sudo
# You can choose to install restricted and universe software, or to install
# software from the backports repository.
# d-i apt-setup/restricted boolean true
# d-i apt-setup/universe boolean true
# d-i apt-setup/backports boolean true
# Uncomment this if you don't want to use a network mirror.
# d-i apt-setup/use_mirror boolean false
# Select which update services to use; define the mirrors to be used.
# Values shown below are the normal defaults.
# d-i apt-setup/services-select multiselect security
# d-i apt-setup/security_host string security.ubuntu.com
# d-i apt-setup/security_path string /ubuntu
$SNIPPET('preseed_apt_repo_config')
# Enable deb-src lines
# d-i apt-setup/local0/source boolean true
# URL to the public key of the local repository; you must provide a key or
# apt will complain about the unauthenticated repository and so the
# sources.list line will be left commented out
# d-i apt-setup/local0/key string http://local.server/key
# By default the installer requires that repositories be authenticated
# using a known gpg key. This setting can be used to disable that
# authentication. Warning: Insecure, not recommended.
# d-i debian-installer/allow_unauthenticated boolean true
# Package selection
# Default for minimal
tasksel tasksel/first multiselect standard
# Default for server
# tasksel tasksel/first multiselect standard, web-server
# Default for gnome-desktop
# tasksel tasksel/first multiselect standard, gnome-desktop
# Individual additional packages to install
# wget is REQUIRED otherwise quite a few things won't work
# later in the build (like late-command scripts)
d-i pkgsel/include string ntp ssh wget
# Debian needs this for the installer to avoid any question for grub
# Please verify that it suit your needs as it may overwrite any usb stick
#if $breed == "debian"
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/bootdev string default
#end if
# Use the following option to add additional boot parameters for the
# installed system (if supported by the bootloader installer).
# Note: options passed to the installer will be added automatically.
d-i debian-installer/add-kernel-opts string $kernel_options_post
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
## Figure out if we're kickstarting a system or a profile
#if $getVar('system_name','') != ''
#set $what = "system"
#else
#set $what = "profile"
#end if
# This first command is run as early as possible, just after preseeding is read.
# d-i preseed/early_command string [command]
d-i preseed/early_command string wget -O- \
http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_early_default | \
/bin/sh -s
#d-i preseed/early_command string hostnamectl set-hostname ubuntu | /bin/sh -s
# This command is run immediately before the partitioner starts. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
# d-i partman/early_command \
# string debconf-set partman-auto/disk "\$(list-devices disk | head -n1)"
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
# d-i preseed/late_command string [command]
d-i preseed/late_command string wget -O- \
http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_late_default | \
chroot /target /bin/sh -s
#d-i preseed/late_command string hostnamectl set-hostname ubuntu | /bin/sh -s
[root@localhost ~]# cobbler list
distros:
Ubuntu-17-x86_64
profiles:
Ubuntu-17-x86_64
systems:
repos:
Ubuntu-17-x86_64
images:
mgmtclasses:
packages:
files:
[root@localhost ~]# mount ubuntu-17.04-server-amd64.iso /mnt/
[root@localhost ~]# cobbler import --path=/mnt/ --name=Ubuntu-17.04 --arch=x86_64 --kickstart=/var/lib/cobbler/kickstarts/ubuntu17.04.seed
ubuntu18.04 seed文件内容
因为镜像文件中不存在ntp,取消了默认安装程序中安装ntp程序,不取消ntp安装,自动化安装会卡住窗口无法进行下去
[root@localhost kickstarts]# vim ubuntu18.seed
# Mostly based on the Ubuntu installation guide
# https://help.ubuntu.com/18.04/installation-guide/
# Debian sample
# https://www.debian.org/releases/stable/example-preseed.txt
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# Keyboard selection.
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/xkb-keymap select us
d-i keyboard-configuration/toggle select No toggling
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/variantcode string
# netcfg will choose an interface that has link if possible. This makes it
# skip displaying a list if there is more than one interface.
#set $myhostname = $getVar('hostname',$getVar('name','cobbler')).replace("_","-")
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string $myhostname
#d-i netcfg/get_hostname string unassigned-hostname
# If non-free firmware is needed for the network or other hardware, you can
# configure the installer to always try to load it, without prompting. Or
# change to false to disable asking.
# d-i hw-detect/load_firmware boolean true
# NTP/Time Setup
d-i time/zone string Asia/Shanghai
d-i clock-setup/utc boolean true
#d-i clock-setup/ntp boolean true
d-i clock-setup/ntp boolean false
#d-i clock-setup/ntp-server string ntp.ubuntu.com
# Setup the installation source
d-i mirror/country string manual
d-i mirror/http/hostname string $http_server
d-i mirror/http/directory string $install_source_directory
d-i mirror/http/proxy string
#set $os_v = $getVar('os_version','')
#if $breed == "ubuntu" and $os_v and $os_v.lower() != 'precise'
# Required at least for ubuntu 12.10+ , so test os_v is not precise. Olders versions are not supported anymore
d-i live-installer/net-image string http://$http_server/cobbler/links/$distro_name/install/filesystem.squashfs
#end if
# Suite to install.
# d-i mirror/suite string precise
# d-i mirror/udeb/suite string precise
# Components to use for loading installer components (optional).
#d-i mirror/udeb/components multiselect main, restricted
# Disk Partitioning
# Use LVM, and wipe out anything that already exists
#d-i partman-auto/choose_recipe select boot-root
#d-i partman-auto/method string regular
#d-i partman-lvm/device_remove_lvm boolean true
#d-i partman-md/device_remove_md boolean true
#d-i partman/default_filesystem string ext4
#d-i partman-partitioning/confirm_write_new_label boolean true
#d-i partman-auto/choose_recipe select finish
#d-i partman/confirm boolean true
#d-i partman/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman/alignment select cylinder
d-i partman/confirm boolean true
d-i partman-basicfilesystems/no_swap boolean false
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm_nooverwrite boolean true
d-i grub-installer/only_debian boolean true
#d-i grub-installer/bootdev string /dev/sda
#d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/expert_recipe string \
boot-root :: \
1024 1 1024 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
1 3 -1 ext4 \
$primary{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
4096 2 4096 linux-swap \
$primary{ } \
method{ swap } format{ } \
.
# 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 finish
#d-i partman/confirm boolean true
#d-i partman/confirm_nooverwrite boolean true
#d-i partman/mount_style select uuid
# 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
# root account and password
#d-i passwd/root-login boolean true
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password $default_password_crypted
d-i passwd/make-user boolean true
d-i passwd/user-fullname string ubuntu
d-i passwd/username string ubuntu
d-i passwd/user-password-crypted password $default_password_crypted
# skip creation of a normal user account.
#d-i passwd/make-user boolean false
#d-i passwd/make-user boolean true
#d-i passwd/user-fullname string ubuntu
#d-i passwd/username string ubuntu
#d-i passwd/user-password password $default_password_crypted
#d-i passwd/user-password-again password $default_password_crypted
#d-i user-setup/allow-password-weak boolean true
#d-i user-setup/encrypt-home boolean false
#d-i passwd/user-default-groups string sudo
# You can choose to install restricted and universe software, or to install
# software from the backports repository.
#d-i apt-setup/restricted boolean true
#d-i apt-setup/universe boolean true
#d-i apt-setup/backports boolean false
# Uncomment this if you don't want to use a network mirror.
# d-i apt-setup/use_mirror boolean false
# Select which update services to use; define the mirrors to be used.
# Values shown below are the normal defaults.
# d-i apt-setup/services-select multiselect security
#d-i apt-setup/services-select multiselect none
# d-i apt-setup/security_host string security.ubuntu.com
# d-i apt-setup/security_path string /ubuntu
$SNIPPET('preseed_apt_repo_config')
# Enable deb-src lines
# d-i apt-setup/local0/source boolean true
# URL to the public key of the local repository; you must provide a key or
# apt will complain about the unauthenticated repository and so the
# sources.list line will be left commented out
# d-i apt-setup/local0/key string http://local.server/key
# By default the installer requires that repositories be authenticated
# using a known gpg key. This setting can be used to disable that
# authentication. Warning: Insecure, not recommended.
# d-i debian-installer/allow_unauthenticated boolean true
# Package selection
# Default for minimal
tasksel tasksel/first multiselect standard
# Default for server
# tasksel tasksel/first multiselect standard, web-server
# Default for gnome-desktop
# tasksel tasksel/first multiselect standard, gnome-desktop
# Individual additional packages to install
# wget is REQUIRED otherwise quite a few things won't work
# later in the build (like late-command scripts)
#d-i pkgsel/include string ntp ssh wget
d-i pkgsel/include string ssh wget
#d-i pkgsel/include string openssh-server wget
# Debian needs this for the installer to avoid any question for grub
# Please verify that it suit your needs as it may overwrite any usb stick
#if $breed == "debian"
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/bootdev string default
#end if
# Use the following option to add additional boot parameters for the
# installed system (if supported by the bootloader installer).
# Note: options passed to the installer will be added automatically.
d-i debian-installer/add-kernel-opts string $kernel_options_post
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
## Figure out if we're kickstarting a system or a profile
#if $getVar('system_name','') != ''
#set $what = "system"
#else
#set $what = "profile"
#end if
# This first command is run as early as possible, just after preseeding is read.
# d-i preseed/early_command string [command]
d-i preseed/early_command string wget -O- \
http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_early_default | \
/bin/sh -s
#d-i preseed/early_command string hostnamectl set-hostname ubuntu | /bin/sh -s
# This command is run immediately before the partitioner starts. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
# d-i partman/early_command \
# string debconf-set partman-auto/disk "\$(list-devices disk | head -n1)"
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
# d-i preseed/late_command string [command]
d-i preseed/late_command string wget -O- \
http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_late_default | \
chroot /target /bin/sh -s
#d-i preseed/late_command string hostnamectl set-hostname ubuntu | /bin/sh -s
上传iso镜像,挂载/mnt下,导入文件内容到cobbler中
[root@localhost ~]# mount ubuntu-18.04.5-server-amd64.iso /mnt/
[root@localhost ~]# cobbler import --path=/mnt/ --name=Ubuntu-18.04.3 --arch=x86_64 --kickstart=/var/lib/cobbler/kickstarts/ubuntu18.seed
查看cobbler的相关信息,发现ubuntu18.04导入是两个Ubuntu-18.04.3-x86_64、Ubuntu-18.04.3-hwe-x86_64
[root@localhost ~]# cobbler list
distros:
Ubuntu-18.04.3-hwe-x86_64
Ubuntu-18.04.3-x86_64
profiles:
Ubuntu-18.04.3-hwe-x86_64
Ubuntu-18.04.3-x86_64
systems:
repos:
Ubuntu-18.04.3-hwe-x86_64
Ubuntu-18.04.3-x86_64
images:
mgmtclasses:
packages:
files:
查看镜像相关的seed或cfg自动化引导安装文件
[root@localhost kickstarts]# cobbler profile report
Name : Ubuntu-17-x86_64
..........
Kickstart : /var/lib/cobbler/kickstarts/ubuntu.seed
..........
Name : Ubuntu-18.04.3-x86_64
..........
Kickstart : /var/lib/cobbler/kickstarts/ubuntu18.seed
..........
Name : Centos-7-x86_64
..........
Kickstart : /var/lib/cobbler/kickstarts/CentOS7.cfg
..........
Name : Ubuntu-18.04.3-hwe-x86_64
..........
Kickstart : /var/lib/cobbler/kickstarts/ubuntu18.seed
..........
以下有此两个信息检查信息提示,不必在意
The following are potential configuration items that you may want to fix:
1 : One or more repos need to be processed by cobbler reposync for the first time before kickstarting against them: Ubuntu-18.04.3-x86_64, Ubuntu-18.04.3-hwe-x86_64
2 : 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.