设为首页 收藏本站
查看: 578|回复: 0

[经验分享] Cobbler部署简介

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-12-2 08:37:29 | 显示全部楼层 |阅读模式
Cobbler是自动化安装的工具,由python开发。使用cobbler可以快速简单的安装部署系统。

Cobbler具有以下功能:

  • 使用一个模板来配置DHCP服务(如果启用了DHCP管理)
  • 将一个存储库(yum或rsync)建立镜像或解压缩的媒介,用来注册一个新的操作系统。
  • 在DHCP配置文件中为需要安装的机器创建一个条目,并指定参数(IP/MAC).
  • 在TFTP服务目录下创建适当的PXE文件
  • 重新启动DHCP服务以反映更改
  • 重启机器以开始安装(如果电源管理已启动)



Cobbler部署
环境准备:
cobbler1 192.168.1.10
安装所需软件包:

1
yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart



安装完成之后,在httpd的conf.d目录下会生成cobbler.web.conf和cobber.conf 两个文件。

1
2
3
4
5
6
7
8
9
[iyunv@cobbler1 ~]# ls -l /etc/httpd/conf.d/
total 36
-rw-r--r--. 1 root root 2926 Jul 18 23:30 autoindex.conf
-rw-r--r--. 1 root root 1087 Jan 24  2016 cobbler.conf
-rw-r--r--. 1 root root 1165 Jan 24  2016 cobbler_web.conf
-rw-r--r--. 1 root root  366 Jul 18 23:30 README
-rw-r--r--. 1 root root 9438 Jul 18 23:22 ssl.conf
-rw-r--r--. 1 root root 1252 Jul 18 23:22 userdir.conf
-rw-r--r--. 1 root root  824 Jul 18 23:22 welcome.conf



启动Apache和cobbler:
1
2
systemctl start  httpd
systemctl start cobblerd




执行cobbler check:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[iyunv@cobbler1 ~]# 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 : SELinux is enabled. Please review the following wiki page for details
on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian
deployments and repositories
8 : 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
9 : 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.



根具体的提示来安装配置cobbler.
1
2
3
# vim /etc/cobbler/settings
next_server: 192.168.1.10
server: 192.168.1.10



1
2
# vim /etc/xinetd.d/tftp
  disable                 = no



1
2
# cobbler get-loaders
# systemctl start rsyncd



设置密码:
1
2
# openssl passwd -1 -salt 'cobbler' 'cobbler'
$1$cobbler$M6SE55xZodWc9.vAKLJs6.



配置密码:
1
2
# vim /etc/cobbler/settings
default_password_crypted: "$1$cobbler$M6SE55xZodWc9.vAKLJs6."



重启cobbler,执行check:
1
2
# systemctl restart cobblerd
# cobbler check



使用cobbler管理DHCP:
1
2
# vim /etc/cobbler/settings
manage_dhcp: 1



修改dhcp的模板文件:
1
2
3
4
5
6
# vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers             192.168.1.2;
     option domain-name-servers 192.168.1.2;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.1.100 192.168.1.254;



重启cobbler:
1
2
# systemctl restart cobblerd
# cobbler sync



导入一个cs7镜像:
1
2
# mount /dev/cdrom  /mnt/
# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64



导入一个cs6镜像:
导入前需要先卸载镜像,然后装载新的镜像,

1
2
3
# umount  /mnt/
# mount /dev/cdrom  /mnt/
# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64




导入成功后,查看镜像信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
[iyunv@cobbler1 /]# 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
[iyunv@cobbler1 /]# cobbler profile list
   CentOS-6-x86_64
   CentOS-7-x86_64
[iyunv@cobbler1 /]# cobbler profile report
Name                           : CentOS-7-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : CentOS-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}  # 可添加内核参数
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 :
Internal proxy                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      :
Virt RAM (MB)                  : 512
Virt Type                      : kvm
Name                           : CentOS-6-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : CentOS-6-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 :
Internal proxy                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      :
Virt RAM (MB)                  : 512
Virt Type                      : kvm



镜像存放的路径为:
/var/www/cobbler/ks_mirror

自定义kickstarts  文件,并将定义的kickstarts 文件放在/var/lib/cobbler/kickstarts目录下:
1
2
# cobbler profile edit --name=CentOS-6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6-x86_64.cfg
# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg




CentOS7 kickstarts文件的内容为:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#Kickstart Config
#platform=x86, AMD64, or Intel EM64T
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
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 --ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype xfs --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=em1 --onboot=on
# Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@ base
@ core
sysstat
iptraf
ntp
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
nmap
screen
%end
%post
systemctl disable postfix.service

%yum_config_stanza
%end




CS6 kickstarts 文件内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#Kickstart Configurator for cobbler
#platform=x86, AMD64, or Intel EM64T
key --skip
#System  language
lang en_US
#System keyboard
keyboard us
#Sytem timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $default_password_crypted
#Use text mode install
text
#Install OS instead of upgrade
install
#Use NFS installation Media
url --url=$tree
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype ext4 --size 1024 --ondisk sda
part swap --size 16384 --ondisk sda
part / --fstype ext4 --size 1 --grow --ondisk sda
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=em1 --onboot=on
#Reboot after installation
reboot
#Firewall configuration
firewall --disabled
#SELinux configuration
selinux --disabled
#Do not configure XWindows
skipx
#Package install information
%packages
@ base
@ chinese-support
@ core
sysstat
iptraf
ntp
e2fsprogs-devel
keyutils-libs-devel
krb5-devel
libselinux-devel
libsepol-devel
lrzsz
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
mysql
lockdev
minicom
nmap
%post
#/bin/sed -i 's/#Protocol 2,1/Protocol 2/' /etc/ssh/sshd_config
/bin/sed  -i 's/^ca::ctrlaltdel:/#ca::ctrlaltdel:/' /etc/inittab
/sbin/chkconfig --level 3 diskdump off
/sbin/chkconfig --level 3 dc_server off
/sbin/chkconfig --level 3 nscd off
/sbin/chkconfig --level 3 netfs off
/sbin/chkconfig --level 3 psacct off
/sbin/chkconfig --level 3 mdmpd off
/sbin/chkconfig --level 3 netdump off
/sbin/chkconfig --level 3 readahead off
/sbin/chkconfig --level 3 wpa_supplicant off
/sbin/chkconfig --level 3 mdmonitor off
/sbin/chkconfig --level 3 microcode_ctl off
/sbin/chkconfig --level 3 xfs off
/sbin/chkconfig --level 3 lvm2-monitor off
/sbin/chkconfig --level 3 iptables off
/sbin/chkconfig --level 3 nfs off
/sbin/chkconfig --level 3 ipmi off
/sbin/chkconfig --level 3 autofs off
/sbin/chkconfig --level 3 iiim off
/sbin/chkconfig --level 3 cups off
/sbin/chkconfig --level 3 openibd off
/sbin/chkconfig --level 3 saslauthd off
/sbin/chkconfig --level 3 ypbind off
/sbin/chkconfig --level 3 auditd off
/sbin/chkconfig --level 3 rdisc off
/sbin/chkconfig --level 3 tog-pegasus off
/sbin/chkconfig --level 3 rpcgssd off
/sbin/chkconfig --level 3 kudzu off
/sbin/chkconfig --level 3 gpm off
/sbin/chkconfig --level 3 arptables_jf off
/sbin/chkconfig --level 3 dc_client off
/sbin/chkconfig --level 3 lm_sensors off
/sbin/chkconfig --level 3 apmd off
/sbin/chkconfig --level 3 sysstat off
/sbin/chkconfig --level 3 cpuspeed off
/sbin/chkconfig --level 3 rpcidmapd off
/sbin/chkconfig --level 3 rawdevices off
/sbin/chkconfig --level 3 rhnsd off
/sbin/chkconfig --level 3 nfslock off
/sbin/chkconfig --level 3 winbind off
/sbin/chkconfig --level 3 bluetooth off
/sbin/chkconfig --level 3 isdn off
/sbin/chkconfig --level 3 portmap off
/sbin/chkconfig --level 3 anacron off
/sbin/chkconfig --level 3 irda off
/sbin/chkconfig --level 3 NetworkManager off
/sbin/chkconfig --level 3 acpid off
/sbin/chkconfig --level 3 pcmcia off
/sbin/chkconfig --level 3 atd off
/sbin/chkconfig --level 3 sendmail off
/sbin/chkconfig --level 3 haldaemon off
/sbin/chkconfig --level 3 smartd off
/sbin/chkconfig --level 3 xinetd off
/sbin/chkconfig --level 3 netplugd off
/sbin/chkconfig --level 3 readahead_early off
/sbin/chkconfig --level 3 xinetd off
/sbin/chkconfig --level 3 ntpd on
/sbin/chkconfig --level 3 avahi-daemon off
/sbin/chkconfig --level 3 ip6tables off
/sbin/chkconfig --level 3 restorecond off
/sbin/chkconfig --level 3 postfix off



这里关闭了一些不必要的启动项。

添加内核参数,使CS7启动后网卡格式自动修改为ethx格式:
1
# cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0'



确认内核参数已经加上:
1
2
# cobbler profile report CentOS-7-x86_64|grep "Kernel Options"
Kernel Options                 : {'biosdevname': '0', 'net.ifnames': '0'}



执行sync命令,使配置生效:
1
# cobbler sync




Cobbler 自动安装
可以通过创建的虚拟机来查看Cobbler的安装过程,首先启动TFTP(如果没有安装需要安装):
1
2
# yum install xinetd -y
# systemctl start xinetd



新启动一个客户端,默认从网络启动,会自动获取IP地址,进行安装和自动设置。


Cobbler自动重装系统
如果需要从一个已经安装了的CentOS系统重新安装新的系统,可以执行下面的命令查看cobbler服务器上提供的安装镜像:
如果没有koan命令需要先yum安装:
1
2
3
4
# koan --server=192.168.1.10 --list=profiles  # 指定cobbler服务器
- looking for Cobbler at http://192.168.1.10:80/cobbler_api
CentOS-7-x86_64    #显示当前可用的系统软件版本
CentOS-6-x86_64




指定需要重装的软件版本,此处指定为CS6:
1
# koan --replace-self --server=192.168.1.10 --profile=CentOS-6-x86_64



根据提示进行reboot 即可开始安装。

使用Cobbler-Web来管理Cobbler
登录的地址为: https://192.168.1.10/cobbler_web   
默认的用户和密码都为cobbler
修改用户名和密码:
1
# htdigest  /etc/cobbler/users.digest  "Cobbler" cobbler   # “描述”  用户



输入此命令后,会提示修改密码。

修改cobbler的启动安装界面
Cobbler的启动安装界面可以有自定义的提示,通修改pxe的模板文件来实现:
1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@cobbler1 ~]# cat /etc/cobbler/pxe/pxedefault.template
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler this is test==^-^ |   #提示栏信息
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local                         #默认的启动列表
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1
$pxe_menu_items
MENU end



执行sync 使命令生效:
1
# cobbler sync



在新建的设备启动界面为:
wKioL1g_4ROT4t2FAACBU9uuRE8277.jpg




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-308423-1-1.html 上篇帖子: yum报错:This system is not registered to Red Hat Subscription Management.... 下篇帖子: namenode ha切换优化
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表