cobbler installation and configuration

1. System environment
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)
[root@localhost ~]# uname -r
2.6.32-696.23.1.el6.x86_64
[root@localhost ~ ]# getenforce must close SELINUX
Disabled
[root@localhost ~]# /etc/init.d/iptables status Close firewall
iptables: Firewall is not running.
[root@CentOS6 ~]# ifconfig eth0|awk -F "[ :]+ " 'NR==2 {print $4}'
192.168.252.130
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http:/ /mirrors.aliyun.com/repo/epel-6.repo

2.安装Cobbler
[root@localhost ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd

[root@localhost ~]# rpm -ql cobbler # View the installed files, the sections are listed below.
/etc/cobbler # Configuration file directory
/etc/cobbler/settings # Cobbler main configuration file, this file is in YAML format, Cobbler is a program written in python.
/etc/cobbler/dhcp.template # Configuration template of DHCP service
/etc/cobbler/tftpd.template # Configuration template of tftp service
/etc/cobbler/rsync.template # Configuration template of rsync service
/etc/cobbler/iso # iso Template configuration file directory
/etc/cobbler/pxe # pxe template file directory
/etc/cobbler/power # Power configuration file directory
/etc/cobbler/users.conf # Web service authorization configuration file
/etc/cobbler/users.digest # Username and password configuration file for web access
/etc/cobbler/dnsmasq.template # DNS service configuration template
/etc/cobbler/modules.conf # Cobbler module configuration file
/var/lib/cobbler # Cobbler data directory
/var/ lib/cobbler/config # Configuration file
/var/lib/cobbler/kickstarts # Kickstart file is stored by default
/var/lib/cobbler/loaders # Stored various boot programs
/var/www/cobbler # System installation mirror directory
/var/www/cobbler/ks_mirror # Imported system mirror list
/var/www/cobbler/images # Import The system mirror startup file
/var/www/cobbler/repo_mirror # yum source storage directory
/var/log/cobbler # log directory
/var/log/cobbler/install.log # client system installation log
/var/log/cobbler/ cobbler.log # cobbler log

1.3 Configuring Cobbler

[root@localhost ~]# cobbler check

cp /etc/cobbler/settings{,.ori}                                                                                       #备份
sed -i 's/server: 127.0.0.1/server: 192.168.252.130/' /etc/cobbler/settings                                               #服务端IP
sed -i 's/next_server: 127.0.0.1/next_server: 192.168.252.130/' /etc/cobbler/settings                                     #服务端IP
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings                                                         #dhcp只获取一次
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings                                                     #cobbler只执行一遍
sed -ri "/default_password_crypted/s#(.*: ).*#\1\"`openssl passwd -1 -salt 'admin' '123456'`\"#" /etc/cobbler/settings  #设置密码为123456
sed -i 's#yes#no#' /etc/xinetd.d/rsync                                 #xinet 管理rsync
sed -i 's#yes#no#' /etc/xinetd.d/tftp                                  #xinet 管理tftp
cobbler get-loaders                                                    #下载
sed -i 's#192.168.1#192.168.252#g;22d;23d' /etc/cobbler/dhcp.template  # 修改dhcp配置文件
cobbler sync                                                          #写入磁盘
/etc/init.d/xinetd restart                                            #启动三个必须启动的服务。详情请看kickstart
/etc/init.d/cobblerd restart
/etc/init.d/httpd restart
cobbler sync       #    同步

挂载光盘:
[root@localhost ~]# mount /dev/cdrom /mnt/

制作镜像导入到 cobbler
[root@localhost ~]# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64
--path= 路径
--name=名称
--arch=系统位数32 or 64

导入的位置
[root@localhost ks_mirror]# pwd
/var/www/cobbler/ks_mirror
[root@localhost ks_mirror]# ls
CentOS-7-x86_64  config

查看 cobbler命令
        [root@localhost /]# cobbler profile
        usage
        =====
        cobbler profile add
        cobbler profile copy
        cobbler profile dumpvars
        cobbler profile edit
        cobbler profile find
        cobbler profile getks
        cobbler profile list
        cobbler profile remove
        cobbler profile rename
        cobbler profile report

查看镜像
[root@localhost /]# cobbler profile list
CentOS-6-x86_64

查看系统详细信息
[root@localhost /]# cobbler profile report

kickstarts文件放在/var/lib/cobbler/kickstarts下面

[root@localhost ~]# cd /var/lib/cobbler/kickstarts/
[root@localhost kickstarts]# rz -

自定义kickstarts文件 
我们使用cobbler profile report命令看到Kickstart默认在/var/lib/cobbler/kickstarts/sample_end.ks 
我们直接使用命令进行修改,我们修改6的kickstarts

 [root@localhost /]# cobbler profile edit --name=CentOS-6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6-x86_64.cfg

同步配置
[root@localhost /]# cobbler sync

CentOS-6.8-x86_64.cfg 配置文件
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
$SNIPPET('network_config')
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=123456
rootpw  --iscrypted $123456
clearpart --all --initlabel
part /boot --fstype=ext4 --asprimary --size=200
part swap --size=1024
part / --fstype=ext4 --grow --asprimary --size=200
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot

%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end

%packages
@base
@compat-libraries
@debugging
@development
tree
nmap
sysstat
lrzsz
dos2unix
telnet
%end

%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end

%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324604328&siteId=291194637