//导入redhat8镜像
[root@localhost ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@localhost ~]# cobbler import --path=/mnt --name=rhel-8 --arch=x86_64
task started: 2020-07-29_191136_import
task started (id=Media import, time=Wed Jul 29 19:11:36 2020)
Found a candidate signature: breed=redhat, version=rhel8
Found a matching signature: breed=redhat, version=rhel8
Adding distros from path /var/www/cobbler/ks_mirror/rhel-8-x86_64:
creating new distro: rhel-8-x86_64
trying symlink: /var/www/cobbler/ks_mirror/rhel-8-x86_64 -> /var/www/cobbler/links/rhel-8-x86_64
creating new profile: rhel-8-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/rhel-8-x86_64 for rhel-8-x86_64
processing repo at : /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream
looking for /var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-8-x86_64/AppStream/repodata
processing repo at : /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS
need to process repo/comps: /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS
looking for /var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/rhel-8-x86_64/BaseOS/repodata
*** TASK COMPLETE ***
//查看cobbler镜像列表
[root@localhost ~]# cobbler list
distros:
rhel-7-x86_64
rhel-8-x86_64
profiles:
rhel-7-x86_64
rhel-8-x86_64
systems:
vm1
repos:
images:
mgmtclasses:
packages:
files:
//创建kickstarts自动安装脚本
[root@localhost ~]# cat /var/lib/cobbler/kickstarts/rhel-8-x86_64.ks
#version=RHEL8
ignoredisk --only-use=nvme0n1
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
# Use graphical install
graphical
# Use CDROM installation media
cdrom
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
network --bootproto=dhcp --device=ens160 --ipv6=auto --activate
network --hostname=localhost.localdomain
url --url=http://192.168.20.99/cobbler/ks_mirror/rhel-8-x86_64
# Root password
rootpw --iscrypted $6\$FlnlCjygygnZgk9m\$NrSrRGx7/VPjgZuYyZBg6DYhkvD6xIQhbdHznGbfXRcwjHhaQpNEMCQW52BiSXXvCcSKr6r8dWJnljDQ6jG09/
# Run the Setup Agent on first boot
firstboot --enable
# Do not configure the X Window System
skipx
# System services
services --enabled="chronyd"
# System timezone
timezone America/New_York --isUtc
%packages
@^minimal-environment
kexec-tools
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
//检查ks文件语法是否有误
[root@localhost ~]# cobbler validateks
task started: 2020-07-29_202402_validateks
task started (id=Kickstart Validation, time=Wed Jul 29 20:24:02 2020)
----------------------------
osversion: rhel7
checking url: http://192.168.20.99/cblr/svc/op/ks/profile/rhel-7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.20.99/cblr/svc/op/ks/profile/rhel-7-x86_64"
received on stdout:
received on stderr:
Potential templating errors:
Unknown variable found at line 16, column 39: '$atY8eUtZX3RoH6sNo0MWYEKVts0qq3jCUXw'
----------------------------
osversion: rhel8
checking url: http://192.168.20.99/cblr/svc/op/ks/profile/rhel-8-x86_64
running: /usr/bin/ksvalidator -v "rhel8" "http://192.168.20.99/cblr/svc/op/ks/profile/rhel-8-x86_64"
received on stdout: rhel8版本不被pykickstart支持
received on stderr:
*** potential errors detected in kickstarts ***
!!! TASK FAILED !!!
//查看当前cobbler有哪些配置文件
[root@localhost ~]# cobbler profile list
rhel-7-x86_64
rhel-8-x86_64
//修改profile,将我们新建的ks文件设为默认的kickstarts安装文件
[root@localhost ~]# cobbler profile edit --name rhel-8-x86_64 --kickstart=/var/lib/cobbler/kickstarts/rhel-8-x86_64.ks
//配置网卡名称为传统网卡名称eth0
[root@localhost ~]# cobbler profile edit --name rhel-8-x86_64 --kopts='net.ifname=0 biosdevname=0'
//同步cobbler
[root@localhost ~]# cobbler sync
task started: 2020-07-29_202821_sync
task started (id=Sync, time=Wed Jul 29 20:28:21 2020)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/rhel-7-x86_64
removing: /var/www/cobbler/images/rhel-8-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/images/rhel-7-x86_64
removing: /var/lib/tftpboot/images/rhel-8-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: rhel-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-7-x86_64/initrd.img
copying files for distro: rhel-8-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/rhel-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/rhel-8-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: rhel-7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-7-x86_64/initrd.img
Writing template files for rhel-7-x86_64
copying files for distro: rhel-8-x86_64
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/rhel-8-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/rhel-8-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/rhel-8-x86_64/initrd.img
Writing template files for rhel-8-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: rhel-7-x86_64
processing boot_files for distro: rhel-8-x86_64
cleaning link caches
running: find /var/lib/tftpboot/images/.link_cache -maxdepth 1 -type f -links 1 -exec rm -f '{}' ';'
received on stdout:
received on stderr:
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 dhcpd restart
received on stdout:
received on stderr: Redirecting to /bin/systemctl restart dhcpd.service
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 ***
//为避免发生未知问题,先把服务端所有服务重启
[root@localhost ~]# systemctl restart httpd cobblerd xinetd
也可以修改安装的配置文件安装
[root@localhost ~]# find / -name *vm* | grep cobbler
/var/lib/cobbler/config/systems.d/vm2.json
//修改IP和mac地址和选择配置文件
cat /var/lib/cobbler/config/systems.d/vm2.json
{"comment": "", "status": "production", "kickstart": "/var/lib/cobbler/kickstarts/rhel-8-x86_64.ks", "name_servers_search": [], "ks_meta": {}, "kernel_options_post": {}, "image": "", "redhat_management_key": "<<inherit>>", "virt_path": "<<inherit>>", "power_user": "", "kernel_options": {"biosdevname": "0", "net.ifnames": "0"}, "ctime": 1596088455.541079, "name_servers": ["114.114.114.114"], "mtime": 1596088554.386794, "enable_gpxe": false, "template_files": {}, "gateway": "192.168.20.2", "uid": "MTU5NjA4ODQ1NS41NDI0NDE1NjYuMjI0MTU", "virt_auto_boot": 0, "power_type": "ipmitool", "virt_cpus": "<<inherit>>", "mgmt_parameters": "<<inherit>>", "boot_files": {}, "hostname": "vm2", "repos_enabled": false, "mgmt_classes": [], "power_pass": "", "netboot_enabled": true, "ipv6_autoconfiguration": false, "profile": "rhel-8-x86_64", "virt_type": "xenpv", "interfaces": {"eth0": {"ipv6_address": "", "interface_type": "", "static": true, "cnames": [], "bridge_opts": "", "management": false, "interface_master": "", "mac_address": "00:50:56:3F:21:C6", "ipv6_prefix": "", "virt_bridge": "xenbr0", "netmask": "255.255.255.0", "bonding_opts": "", "ip_address": "192.168.20.138", "dhcp_tag": "", "ipv6_mtu": "", "static_routes": [], "ipv6_static_routes": [], "if_gateway": "", "dns_name": "", "mtu": "", "connected_mode": false, "ipv6_secondaries": [], "ipv6_default_gateway": ""}}, "power_address": "", "proxy": "<<inherit>>", "fetchable_files": {}, "virt_file_size": "<<inherit>>", "ldap_enabled": false, "monit_enabled": false, "ipv6_default_device": "", "virt_pxe_boot": 0, "virt_disk_driver": "<<inherit>>", "owners": "<<inherit>>", "name": "vm2", "virt_ram": "<<inherit>>", "power_id": "", "server": "<<inherit>>", "redhat_management_server": "<<inherit>>", "depth": 2, "ldap_type": "authconfig", "template_remote_kickstarts": 0}