1. 程式人生 > >cobbler自動化部署

cobbler自動化部署

none don ipv p地址 定義 print ssl flags loader

一、下載cobbler及其所需要的軟件

# yum install httpd cobbler xinetd tftp-server dhcp syslinux -y

syslinux: 提供pxelinux.0這個文件 ,pxelinux.0引導文件引導vmlinux和initrd兩個啟動文件

yum安裝cobbler需要使用下面兩個源,大家可以復制下面的代碼到自己的yum倉庫保存即可

[epel]
name=epel
enabled=1
gpgcheck=0
baseurl=https://mirrors.aliyun.com/epel/7/x86_64/


[centos]
name=centos base

enabled=1
gpgcheck=0
baseurl=http://mirrors.163.com/centos/7/os/x86_64/

第二步:配置DHCP服務

# vim /etc/dhcp/dhcpd.conf

subnet 192.168.182.0 netmask 255.255.255.0 {
range 192.168.182.150 192.168.182.155;
default-lease-time 600;
max-lease-time 7200;
filename "pxelinux.0";
}


# systemctl restart dhcpd

第三步、配置tftp

#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 #yes改為no
per_source = 11
cps = 100 2
flags = IPv4
}

# systemctl restart xinetd

四、啟動Apache

# systemctl restart httpd

五、啟動cobbler

# systemctl restart cobblerd

六、檢查cobbler配置

# cobbler check

常見錯誤及修改方式

 The following are potential configuration items that you may want to fix:
  1: The ‘server‘ field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
  2: For PXE to be functional, the ‘next_server‘ field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
  3: 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.
  4: enable and start rsyncd.service with systemctl
  5: debmirror package is not installed, it will be required to manage debian deployments and repositories
  6: The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to ‘cobbler‘ and should be changed, try: "openssl passwd -1 -salt ‘random-phrase-here‘ ‘your-password-here‘" to generate new one
  7: 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.

根據如上反饋,需要一一進行修改才能繼續進行

修改配置文件/etc/cobbler/settings

問題一:

  cobbler文件默認是127.0.0.1本地回環地址,需要更改為提供cobbler服務的ip地址 192.168.182.128,在384行

  384 server: 192.168.182.128

問題二:

  netx_server也是默認本地127.0.0.1回環地址,需要修改為提供cobbler服務的ip地址 192.163.182,128,在272行出

  272 next_server: 192.168.182.128

問題三:

可以忽略

問題四:

啟動rsync即可

  # systemctl restart rsyncd

  # systemctl enable rsyncd

問題五:

可以忽略

問題六:

創建密碼

  # openssl passwd -1 -salt "123" "123456"

  $1$123$7mft0jKnzzvAdU4t0unTG1

並把新生成的加密數據填寫進/etc/cobbler/settings

  101 default_password_crypted: "$1$123$7mft0jKnzzvAdU4t0unTG1"

問題七:

可以忽略

以上問題解決之後,需要同步和重啟

# systemctl restart cobblerd

#cobbler check

# cobbler sync

七、掛載光盤並進行數據導入

# mount /dev/cdrom /mnt # cobbler import --path=/mnt --name="centos7.5" # cobbler distro list # cobbler profile list

八、配置kickstar文件

# cp anaconda-ks.cfg /var/lib/cobbler/kickstarts/ks.cfg # vim /var/lib/cobbler/kickstarts/ks.cfg

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url=http://192.168.182.128/cobbler/ks_mirror/centos7.5/ #這裏需要更改為repodata所在的http地址
# 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=ens33 --ipv6=auto --no-activate
network --hostname=localhost.localdomain

# Root password
rootpw --iscrypted $6rootpw --iscrypted $6$7zu1wIUDgBGEFV1Y$KsLVeaGmyN92.QHr1fqKdTqPu8PDmd8K9V/s3Ru8NxE53NZz4gQKsmP6K0udcXVvDtponekICYUw

BD7tYZJqU/

# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel

%packages
@^minimal
@core

%end

%addon com_redhat_kdump --disable --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

九、自定義profile

# cobbler profile add --distro=centos7.5-x86_64 --name=centos7.5_ken --kickstart=/var/lib/cobbler/kickstarts/ks.cfg

# cobbler sync

十、查看profile

# cobbler profile list

十一、刪除不包含ks文件的profile

# cobbler profile remove --name=centos7.5-x86_64

# cobbler profile list

cobbler自動化部署