Ubuntu18.04.5LTS安装cobbler2.8部署Ubuntu系统
1、 安装cobbler依赖包
root@cobbler:~# apt install -y make git python-yaml python-cheetah python-netaddr python-simplejson libapache2-mod-wsgi python-django atftpd debmirror apache2 python-urlgrabber fence-agents isc-dhcp-server
2、 下载cobbler git包
root@cobbler:~# git clone git://github.com/cobbler/cobbler.git
Cloning into ‘cobbler’…
remote: Enumerating objects: 48194, done.
remote: Counting objects: 100% (427/427), done.
remote: Compressing objects: 100% (273/273), done.
remote: Total 48194 (delta 210), reused 309 (delta 150), pack-reused 47767
Receiving objects: 100% (48194/48194), 23.07 MiB | 2.96 MiB/s, done.
Resolving deltas: 100% (32702/32702), done.
3、 编译安装cobbler2.8
root@cobbler:~/cobbler# git checkout release28
Already on ‘release28’
Your branch is up to date with ‘origin/release28’.
root@cobbler:~/cobbler# make install
rm -rf build rpm-build
rm -f ~
rm -f cobbler/.pyc
rm -rf dist
rm -rf buildiso
rm -f MANIFEST
rm -f README
rm -f koan/.pyc
rm -f config/version
rm -f docs/.1.gz
rm -f .tmp
rm -f .log
python setup.py build -f
running build
……
4、编译安装web管理端
root@cobbler:~/cobbler# make webtest
rm -rf //usr/share/cobbler
make savestate
make[1]: Entering directory ‘/root/cobbler’
python setup.py -v savestate —root /; \
running savestate
backing up the current configuration to /tmp/cobblersettings/devinstall
copying //var/lib/cobbler/config/ to /tmp/cobbler_settings/devinstall/config/
copying //etc/apache2/conf-available/cobbler_web.conf to /tmp/cobbler_settings/devinstall/cobbler_web.conf
copying //etc/apache2/conf-available/cobbler.conf to /tmp/cobbler_settings/devinstall/cobbler.conf
copying //etc/cobbler/modules.conf to /tmp/cobbler_settings/devinstall/modules.conf
copying //etc/cobbler/settings to /tmp/cobbler_settings/devinstall/settings
copying //etc/cobbler/users.conf to /tmp/cobbler_settings/devinstall/users.conf
copying //etc/cobbler/users.digest to /tmp/cobbler_settings/devinstall/users.digest
copying //etc/cobbler/dhcp.template to /tmp/cobbler_settings/devinstall/dhcp.template
copying //etc/cobbler/rsync.template to /tmp/cobbler_settings/devinstall/rsync.template
make[1]: Leaving directory ‘/root/cobbler’
make install
make[1]: Entering directory ‘/root/cobbler’
rm -rf build rpm-build
rm -f ~
rm -f cobbler/.pyc
rm -rf dist
rm -rf buildiso
rm -f MANIFEST
rm -f README
rm -f koan/.pyc
rm -f config/version
rm -f docs/.1.gz
rm -f .tmp
rm -f .log
python setup.py build -f
……
5、启动服务
●cobblerd.service - Cobbler Helper Daemon
Loaded: loaded (/etc/systemd/system/cobblerd.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2021-05-17 17:00:34 CST; 5s ago
Process: 57140 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=1/FAILURE)
Main PID: 57139 (cobblerd)
Tasks: 1 (limit: 2288)
CGroup: /system.slice/cobblerd.service
└─57139 /usr/bin/python /usr/bin/cobblerd -F
May 17 17:00:34 cobbler systemd[1]: Starting Cobbler Helper Daemon…
May 17 17:00:34 cobbler touch[57140]: /usr/bin/touch: cannot touch ‘/usr/share/cobbler/web/cobbler.wsgi’: No such file or directory
May 17 17:00:34 cobbler systemd[1]: Started Cobbler Helper Daemon.
root@cobbler:~/cobbler# mkdir /usr/share/cobbler/web -p
root@cobbler:~/cobbler# systemctl restart cobblerd.service
root@cobbler:~/cobbler# systemctl status cobblerd.service
●cobblerd.service - Cobbler Helper Daemon
Loaded: loaded (/etc/systemd/system/cobblerd.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2021-05-17 17:01:03 CST; 2s ago
Process: 57187 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=0/SUCCESS)
Main PID: 57186 (cobblerd)
Tasks: 1 (limit: 2288)
CGroup: /system.slice/cobblerd.service
└─57186 /usr/bin/python /usr/bin/cobblerd -F
May 17 17:01:03 cobbler systemd[1]: Starting Cobbler Helper Daemon…
May 17 17:01:03 cobbler systemd[1]: Started Cobbler Helper Daemon.
root@cobbler:~/cobbler#
6、修改/etc/cobbler/setting
root@cobbler:~# openssl passwd -1
Password:
Verifying - Password:
$1$eLIIED51$9sZ3upAlSe49lL9xx4qZm1
root@cobbler:~# cat /etc/cobbler/settings |grep default_password
default_password_crypted:“$1$eLIIED51$9sZ3upAlSe49lL9xx4qZm1”
root@cobbler:~# cat /etc/cobbler/settings |grep server|grep -v ‘^#’
build_reporting_smtp_server: “localhost”
default_name_servers: []
ldap_server: “ldap.example.com”
_next_server: 192.168.20.100
redhatmanagement_server: “xmlrpc.rhn.redhat.com”
_server: 192.168.20.100
root@cobbler:~# cat /etc/cobbler/settings |grep -v ‘^#’|grep dhcp
manage_dhcp: 1
restart_dhcp: 1
alwayswrite_dhcp_entries: 0
7、修改/usr/local/share/cobbler/web/settings.py
root@cobbler:~# grep -n SECRET_KEY /usr/local/share/cobbler/web/settings.py
38:SECRET_KEY = ‘’
root@cobbler:~# openssl rand -base64 32
Hvb4K48jVWMJuLkaUeIaWXRXGJLONhECpzSsvULVn7I=
root@cobbler:~# grep -n SECRET_KEY /usr/local/share/cobbler/web/settings.py
38:SECRET_KEY = ‘Hvb4K48jVWMJuLkaUeIaWXRXGJLONhECpzSsvULVn7I=’
root@cobbler:~# ln -s /usr/local/lib/python2.7/dist-packages/cobbler /usr/lib/python2.7/dist-packages/
_
8、修改/etc/cobbler/dhcp.templates
subnet 192.168.20.0 netmask 255.255.255.0 {
option routers 192.168.20.100;
option domain-name-servers 192.168.20.100;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.20.110 192.168.20.190;
9、配置apache2
root@cobbler:/etc/apache2/conf-enabled# ln -s ../conf-available/cobbler.conf cobbler.conf
root@cobbler:/etc/apache2/conf-enabled# ln -s ../conf-available/cobbler_web.conf cobbler_web.conf
root@cobbler:/etc/apache2/conf-enabled# ll
total 8
drwxr-xr-x 2 root root 4096 May 18 10:37 ./
drwxr-xr-x 8 root root 4096 May 18 10:34 ../
lrwxrwxrwx 1 root root 30 May 17 15:59 charset.conf -> ../conf-available/charset.conf
lrwxrwxrwx 1 root root 30 May 18 10:37 cobbler.conf -> ../conf-available/cobbler.conf
lrwxrwxrwx 1 root root 34 May 18 10:37 cobbler_web.conf -> ../conf-available/cobbler_web.conf
lrwxrwxrwx 1 root root 44 May 17 15:59 localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root 46 May 17 15:59 other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root 31 May 17 15:59 security.conf -> ../conf-available/security.conf
lrwxrwxrwx 1 root root 36 May 17 15:59 serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf
root@cobbler:/etc/apache2/conf-enabled# systemctl restart apache2
10、运行cobbler check
root@cobbler:/etc/apache2/conf-enabled# cobbler check
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.
Restart cobblerd and then run ‘cobbler sync’ to apply changes.
root@cobbler:/etc/apache2/conf-enabled# cobbler get-loaders
task started: 2021-05-18_103953_get_loaders
task started (id=Download Bootloader Content, time=Tue May 18 10:39:53 2021)
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
root@cobbler:/etc/apache2/conf-enabled#
root@cobbler:/etc/apache2/conf-enabled#
root@cobbler:/etc/apache2/conf-enabled# cobbler check
No configuration problems found. All systems go.
11、导入镜像
root@cobbler:/etc/cobbler# mount -o loop /home/john/ubuntu-18.04.5-server-amd64.iso /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
root@cobbler:/etc/cobbler# df -h
Filesystem Size Used Avail Use% Mounted on
udev 954M 0 954M 0% /dev
tmpfs 198M 1.2M 196M 1% /run
/dev/mapper/cobbler—vg-root 49G 7.5G 39G 17% /
tmpfs 986M 0 986M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 986M 0 986M 0% /sys/fs/cgroup
tmpfs 198M 0 198M 0% /run/user/1000
/dev/loop0 951M 951M 0 100% /mnt
root@cobbler:/etc/cobbler# cobbler import —name=ubuntu-18.04.5-server-amd64 —path=/mnt —arch=x86_64 —kickstart=/var/lib/cobbler/kickstarts/ubuntu18.04lts.seed
12、运行cobbler sync
root@cobbler:/etc/cobbler# cobbler sync
task started: 2021-05-18_111627_sync
task started (id=Sync, time=Tue May 18 11:16:27 2021)
running pre-sync triggers
cleaning trees
removing: /srv/www/cobbler/images/ubuntu-18.04.5-server-hwe-x86_64
removing: /srv/www/cobbler/images/ubuntu-18.04.5-server-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/images/ubuntu-18.04.5-server-hwe-x86_64
removing: /var/lib/tftpboot/images/ubuntu-18.04.5-server-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying files for distro: ubuntu-18.04.5-server-x86_64
trying hardlink /srv/www/cobbler/ks_mirror/ubuntu-18.04.5-server-amd64-x86_64/install/netboot/ubuntu-installer/amd64/linux -> /var/lib/tftpboot/images/ubuntu-18.04.5-server-x86_64/linux
trying hardlink /srv/www/cobbler/ks_mirror/ubuntu-18.04.5-server-amd64-x86_64/install/netboot/ubuntu-installer/amd64/initrd.gz -> /var/lib/tftpboot/images/ubuntu-18.04.5-server-x86_64/initrd.gz
copying files for distro: ubuntu-18.04.5-server-hwe-x86_64
trying hardlink /srv/www/cobbler/ks_mirror/ubuntu-18.04.5-server-amd64-x86_64/install/hwe-netboot/ubuntu-installer/amd64/linux -> /var/lib/tftpboot/images/ubuntu-18.04.5-server-hwe-x86_64/linux
trying hardlink /srv/www/cobbler/ks_mirror/ubuntu-18.04.5-server-amd64-x86_64/install/hwe-netboot/ubuntu-installer/amd64/initrd.gz -> /var/lib/tftpboot/images/ubuntu-18.04.5-server-hwe-x86_64/initrd.gz
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: ubuntu-18.04.5-server-x86_64
trying hardlink /srv/www/cobbler/ks_mirror/ubuntu-18.04.5-server-amd64-x86_64/install/netboot/ubuntu-installer/amd64/linux -> /srv/www/cobbler/images/ubuntu-18.04.5-server-x86_64/linux
trying hardlink /srv/www/cobbler/ks_mirror/ubuntu-18.04.5-server-amd64-x86_64/install/netboot/ubuntu-installer/amd64/initrd.gz -> /srv/www/cobbler/images/ubuntu-18.04.5-server-x86_64/initrd.gz
Writing template files for ubuntu-18.04.5-server-x86_64
copying files for distro: ubuntu-18.04.5-server-hwe-x86_64
trying hardlink /srv/www/cobbler/ks_mirror/ubuntu-18.04.5-server-amd64-x86_64/install/hwe-netboot/ubuntu-installer/amd64/linux -> /srv/www/cobbler/images/ubuntu-18.04.5-server-hwe-x86_64/linux
trying hardlink /srv/www/cobbler/ks_mirror/ubuntu-18.04.5-server-amd64-x86_64/install/hwe-netboot/ubuntu-installer/amd64/initrd.gz -> /srv/www/cobbler/images/ubuntu-18.04.5-server-hwe-x86_64/initrd.gz
Writing template files for ubuntu-18.04.5-server-hwe-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: ubuntu-18.04.5-server-x86_64
processing boot_files for distro: ubuntu-18.04.5-server-hwe-x86_64
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: dhcpd -t -q
received on stdout:
received on stderr:
running: service isc-dhcp-server restart
received on stdout:
received on stderr:
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/
TASK COMPLETE
————————————————————————————————————————————————
###Preseed for Ubuntu18.04.5LTS
d-i auto-install/enable boolean true
d-i debconf/priority select critical
### Net Image
d-i live-installer/net-image string http://$http_server/cobbler/links/$distro_name/install/filesystem.squashfs
###Language
d-i debian-installer/locale string en_US.UTF-8
d-i localechooser/languagelist select en
d-i localechooser/shortlist/en select US
d-i localechooser/continentlist select Asia
d-i localechooser/countrylist/Asia select China
d-i netcfg/get_hostname string $myhostname
d-i netcfg/choose_interface select auto
### 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
###Users
d-i passwd/root-login boolean true
d-i passwd/make-user boolean false
d-i passwd/root-password-crypted password $default_password_crypted
d-i user-setup/allow-password-weak boolean true
###partion
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select boot-root
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto-lvm/new_vg_name string vg00
d-i partman-auto-lvm/new_vg_name_exists string
d-i partman-lvm/vgcreate string vg00
d-i partman-auto/expert_recipe string \
boot-root :: \
4096 4096 4096 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
100 1000 -1 ext4 \
$defaultignore{ } \
$primary{ } \
method{ lvm } \
device{ /dev/sda } \
vg_name{ vg00 } \
. \
4096 2 102400 ext4 \
method{ format } format{ } $lvmok{ } \
in_vg{ vg00 } \
lv_name{ lv01 } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
. \
4096 4096 300% linux-swap \
method{ swap } format{ } \
.
d-i partman/default_filesystem string ext4
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
### EFI
d-i partman-efi/non_efi_system boolean true
### Grub
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
### Clock and time zone setup
d-i time/zone string Asia/Shanghai
d-i clock-setup/utc boolean true
d-i time/zone string Etc/UTC
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string 10.201.240.101
### Package
tasksel tasksel/first multiselect openssh-server
d-i pkgsel/upgrade select none
d-i pkgsel/update-policy select none
### Post Install
d-i preseed/late_command string \
sed -i ‘/PermitRootLogin / s/ .*/ yes/‘ /target/etc/ssh/sshd_config; \
wget http://$http_server/trusty-sources.list -O /target/etc/apt/sources.list; \
wget http://$http_server/cblr/svc/op/nopxe/system/$system_name -O /dev/null
finish-install finish-install/keep-consoles boolean false
d-i finish-install/reboot_in_progress note