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

[经验分享] 运维自动化之批量部署(cobbler)的使用

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-6-3 08:40:01 | 显示全部楼层 |阅读模式
Cobbler的介绍1.cobbler的介绍Cobbler由python语言开发,是对PXE和Kickstart以及DHCP的封装。融合很多特性,提供了CLI和Web的管理形式。更加方便的实行网络安装,。同时,Cobbler也提供了API接口,使用其它语言也很容易做扩展。它不紧可以安装物理机,同时也支持kvm、xen虚拟化、Guest OS的安装。更多的是它还能结合Puppet等集中化管理软件,实现自动化的管理。
Cobbler 提供以下服务集成:
* PXE 服务支持
* DHCP 服务管理
* DNS 服务管理
* 电源管理
* Kickstart 服务支持
* yum 仓库管理
2.cobbler组成Cobbler 的配置结构基于一组注册的对象。每个对象表示一个与另一个实体相关联的实体(该对象指向另一个对象,或者另一个对象指向该对象)。当一个对象指向另一个对象时,它就继承了被指向对象的数据,并可覆盖或添加更多特定信息。以下对象类型的定义为:
发行版:表示一个操作系统。它承载了内核和 initrd 的信息,以及内核参数等其他数据。
配置文件:包含一个发行版、一个 kickstart 文件以及可能的存储库,还包含更多特定的内核参数等其他数据。
系统:表示要配给的机器。它包含一个配置文件或一个镜像,还包含 IP 和 MAC 地址、电源管理(地址、凭据、类型)以及更为专业的数据等信息。
存储库:保存一个 yum 或 rsync 存储库的镜像信息。
镜像:可替换一个包含不属于此类别的文件的发行版对象(例如,无法分为内核和 initrd 的对象)。
基于注册的对象以及各个对象之间的关联,Cobbler知道如何更改文件系统以反映具体配置。因为系统配置的内部是抽象的,所以您可以仅关注想要执行的操作。下面是Cobbler各对象之间的关系图,
wKiom1VtWhzw08wEAAC9aTyo-kg318.jpg
3.cobbler的工作原理
wKiom1VtWn6SufhxAAIGPum6IV4885.jpg
Server端:
·        第一步,启动Cobbler服务
·        第二步,进行Cobbler错误检查,执行cobbler check命令
·        第三步,进行配置同步,执行cobbler sync命令
·        第四步,复制相关启动文件文件到TFTP目录中
·        第五步,启动DHCP服务,提供地址分配
·        第六步,DHCP服务分配IP地址
·        第七步,TFTP传输启动文件
·        第八步,Server端接收安装信息
·        第九步,Server端发送ISO镜像与Kickstart文件
Client端:
·        第一步,客户端以PXE模式启动
·        第二步,客户端获取IP地址
·        第三步,通过TFTP服务器获取启动文件
·        第四步,进入Cobbler安装选择界面
·        第五步,客户端确定加载信息
·        第六步,根据配置信息准备安装系统
·        第七步,加载Kickstart文件
·        第八步,传输系统安装的其它文件
·        第九步,进行安装系统

Cobbler的安装配置管理1.cobbler的安装1.1 安装epel的yum源
1
2
3
4
5
[iyunv@Cobbler~]# rpm  -ivh  http://download.fedoraproject.or ... ease-6-8.noarch.rpm
Retrievinghttp://download.fedoraproject.or ... ease-6-8.noarch.rpm
warning:/var/tmp/rpm-tmp.PiRbIQ: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...               ########################################### [100%]
   1:epel-release          ########################################### [100%]



1.2 关闭防火墙和禁用selinux
1
2
3
4
5
6
7
8
9
10
11
[iyunv@Cobbler~]# service iptables stop
[iyunv@Cobbler~]# chkconfig iptables off
[iyunv@Cobbler~]# service iptables status
iptables: Firewall is notrunning.
[iyunv@Cobbler~]# chkconfig --list | grep iptables
iptables        0:off  1:off   2:off   3:off  4:off   5:off   6:off
[iyunv@Cobbler~]# getenforce
Disabled
补充:禁用selinux的方法:
setenfore 0 临时禁用
sed -i '/SELINUX=/d'/etc/selinux/config &&  echo"SELINUX=disabled">> /etc/selinux/config  永久禁用,重启生效



1.3 安装cobbler的必备软件和cobbler
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
[iyunv@Cobbler~]# yum -y install  httpd  rsync  tftp-server  xinetd  dhcp cman  pykickstart  debmirror
[iyunv@Cobbler~]# yum -y install cobbler cobbler-web

过程中可能会报错:
[iyunv@Cobbler ~]# yum -y installhttpd rsync tftp-server xinetd dhcp  cmanpykickstart debmirror
Loaded plugins: fastestmirror
Loading mirror speeds fromcached hostfile
Error: Cannot retrieve metalinkfor repository: epel. Please verify its path and try again
解决:把epel.repo中的mirrorlist注释掉,并启用baseurl
[iyunv@Cobbler~]# egrep "baseurl|mirrorlist" /etc/yum.repos.d/epel.repo
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
[iyunv@Cobbler~]#sed -i's/#baseurl/baseurl/g' /etc/yum.repos.d/epel.repo
[iyunv@Cobbler~]#sed -i ''s/mirrorlist/#mirrorlist/g/etc/yum.repos.d/epel.repo
[iyunv@Cobbler~]# egrep "baseurl|mirrorlist" /etc/yum.repos.d/epel.repo
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch



1.4  执行cobbler check,然后依次解决检查出的问题
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[iyunv@Cobbler~]# cobbler check
The following are potentialconfiguration items that you may want to fix:

1 : The 'server' field in/etc/cobbler/settings must be set to something other than localhost, orkickstarting features will not work. This should be a resolvable hostname or IP for the boot server asreachable 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 otherthan 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : some network boot-loadersare missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' todownload them, or, if you only want to handle x86/x86_64 netbooting, you mayensure that you have installed a *recent* version of the syslinux packageinstalled 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 'cobblerget-loaders' command is the easiest way to resolve these requirements.
4 : change 'disable' to 'no'in /etc/xinetd.d/rsync
5 : comment out 'dists' on/etc/debmirror.conf for proper debian support
6 : comment out 'arches' on/etc/debmirror.conf for proper debian support
7 : The default password usedby the sample templates for newly installed machines (default_password_cryptedin /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

Restart cobblerd and then run'cobbler sync' to apply changes.

解决办法:
1:在settings里面设置server 的IP
2:在settings里面设置next_server的IP
3:如果当前节点可以访问互联网,执行“cobblerget-loader”命令下载pxelinux.0,menu.c32,elilo.efi, 或yaboot文件,否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/中的pxelinux.0,menu.c32等文件至/var/lib/cobbler/loaders目录中
4:把/etc/xinetd.d/rsync中的disable的值改为no
5: 注释/etc/dedmirror.conf文件中的“@dists="sid";”一行
6: 注释/etc/dedmirror.conf文件中的“@arches="i386";”一行
7: 执行“openssl passwd -1 -salt$(openssl rand -hex 4)”生成密码,并用其替换/etc/cobbler/settings文件中default_password_crypted参数



下面开始在配置过程中解决上面的报错
2.cobbler的配置管理2.1 修改/etc/xinetd.d/下rsync和tftp中disable值为no
1
2
3
4
5
[iyunv@Cobbler~]# sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync
[iyunv@Cobbler~]# sed -i '/disable/c\\tdisable\t\t\t= no' /etc/xinetd.d/tftp  
[iyunv@Cobbler~]# grep "disable" /etc/xinetd.d/rsync /etc/xinetd.d/tftp
/etc/xinetd.d/rsync:    disable = no
/etc/xinetd.d/tftp:     disable                 = no



2.2修改/etc/cobbler/settings文件相关参数
1
2
3
4
5
6
7
8
9
[iyunv@Cobbler~]# sed -i "s/manage_dhcp: 0/manage_dhcp: 1/g" /etc/cobbler/settings
[iyunv@Cobbler~]# sed -i "s/manage_rsync: 0/manage_rsync: 1/g" /etc/cobbler/settings
[iyunv@Cobbler ~]# sed -i"s/next_server: 127.0.0.1/next_server: 192.168.255.10/g"/etc/cobbler/settings
[iyunv@Cobbler~]#  sed -i "s/server:127.0.0.1/server: 192.168.255.10/g" /etc/cobbler/settings
[iyunv@Cobbler~]# egrep "manage_dhcp|manage_rsync|server:|next_server"/etc/cobbler/settings
manage_dhcp:1    #启用cobbler对dhcp的管理
manage_rsync:1    #启用cobbler对rsync的管理
next_server:192.168.255.10  #指定next_server的地址
server:192.168.255.10              #指定cobbler的服务器的ip



2.3 /etc/dedmirror.conf文件注释掉@dists="sid";@arches="i386
1
2
3
4
5
[iyunv@Cobbler~]# sed -i "s/@dists/#@dists/g" /etc/debmirror.conf
[iyunv@Cobbler~]# sed -i "s/@arches/#@arches/g" /etc/debmirror.conf
[iyunv@Cobbler~]# egrep "@dists|@arches" /etc/debmirror.conf
#@dists="sid";
#@arches="i386";



2.4 修改/etc/cobbler/dhcp.template,配置dhcp相关参数
1
2
3
4
5
6
7
8
subnet192.168.255.0 netmask 255.255.255.0 {
     option routers             192.168.255.10;
     option domain-name-servers 192.168.255.10;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.255.100 192.168.255.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;



2.5 生成新的密码文件
1
2
3
4
5
[iyunv@Cobbler~]#  openssl passwd -1 -salt 'cobbler'"123.com"
$1$cobbler$rK3/2t1JZHrwohtqCqcmg.
[iyunv@Cobbler ~]# sed -i'/default_password_crypted/c\default_password_crypted:\"$1$cobbler$rK3/2t1JZHrwohtqCqcmg.\"' /etc/cobbler/settings
[iyunv@Cobbler~]# grep "default_password_crypted" /etc/cobbler/settings
default_password_crypted:"$1$cobbler$rK3/2t1JZHrwohtqCqcmg."



2.6 启动cobbler的各个组件,并设置开机自动启动
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[iyunv@Cobbler~]# /etc/init.d/httpd start
Startinghttpd: httpd: apr_sockaddr_info_get() failed for Cobbler
httpd:Could not reliably determine the server's fully qualified domain name, using127.0.0.1 for ServerName
                                                          [  OK  ]
[iyunv@Cobbler~]# /etc/init.d/xinetd start
Startingxinetd:                                          [  OK  ]
[iyunv@Cobbler~]# /etc/init.d/cobblerd start
Startingcobbler daemon:                                   [  OK  ]
[iyunv@Cobbler~]# /sbin/chkconfig httpd on
[iyunv@Cobbler~]# /sbin/chkconfig dhcpd on
[iyunv@Cobbler~]# /sbin/chkconfig xinetd on
[iyunv@Cobbler~]# /sbin/chkconfig cobblerd on
[iyunv@Cobbler~]# service dhcpd start
Startingdhcpd:                                           [FAILED]
dhcp启动失败,原因是没有同步cobbler的配置,现在cobbler还没接管dhcp,执行cobblerrsync之后就可以



2.7 执行cobbler get-loaders命令,在线下载pxelinux.0,menu.c32,elilo.efi,或yaboot文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@Cobbler~]# cobbler get-loaders
task started:2015-06-01_170259_get_loaders
task started (id=DownloadBootloader Content, time=Mon Jun  117:02:59 2015)
path/var/lib/cobbler/loaders/README already exists, not overwriting existingcontent, use --force if you wish to update
path/var/lib/cobbler/loaders/COPYING.elilo already exists, not overwriting existingcontent, use --force if you wish to update
path/var/lib/cobbler/loaders/COPYING.yaboot already exists, not overwritingexisting content, use --force if you wish to update
path/var/lib/cobbler/loaders/COPYING.syslinux already exists, not overwritingexisting content, use --force if you wish to update
path/var/lib/cobbler/loaders/elilo-ia64.efi already exists, not overwritingexisting content, use --force if you wish to update
path/var/lib/cobbler/loaders/yaboot already exists, not overwriting existingcontent, use --force if you wish to update
path/var/lib/cobbler/loaders/pxelinux.0 already exists, not overwriting existingcontent, use --force if you wish to update
path/var/lib/cobbler/loaders/menu.c32 already exists, not overwriting existingcontent, use --force if you wish to update
path/var/lib/cobbler/loaders/grub-x86.efi already exists, not overwriting existingcontent, use --force if you wish to update
path/var/lib/cobbler/loaders/grub-x86_64.efi already exists, not overwritingexisting content, use --force if you wish to update
*** TASK COMPLETE ***



2.8重启cobbler,并执行cobbler sync使其同步
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
[iyunv@Cobbler~]# service cobblerd restart
Stoppingcobbler daemon:                                   [  OK  ]
Startingcobbler daemon:                                   [  OK  ]
[iyunv@Cobbler~]# cobbler sync
taskstarted: 2015-06-01_170502_sync
taskstarted (id=Sync, time=Mon Jun  117:05:02 2015)
runningpre-sync triggers
cleaningtrees
removing:/var/lib/tftpboot/grub/images
copyingbootloaders
tryinghardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
tryinghardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
tryinghardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
tryinghardlink /var/lib/cobbler/loaders/grub-x86.efi ->/var/lib/tftpboot/grub/grub-x86.efi
tryinghardlink /var/lib/cobbler/loaders/grub-x86_64.efi ->/var/lib/tftpboot/grub/grub-x86_64.efi
copyingdistros to tftpboot
copyingimages
generatingPXE configuration files
generatingPXE menu structure
renderingDHCP files
generating/etc/dhcp/dhcpd.conf
renderingTFTPD files
generating/etc/xinetd.d/tftp
cleaninglink caches
renderingRsync files
runningpost-sync triggers
runningpython triggers from /var/lib/cobbler/triggers/sync/post/*
runningpython trigger cobbler.modules.sync_post_restart_services
running:dhcpd -t -q
receivedon stdout:
receivedon stderr:
running:service dhcpd restart
receivedon stdout: Starting dhcpd: [  OK  ]
receivedon stderr:
runningshell triggers from /var/lib/cobbler/triggers/sync/post/*
runningpython triggers from /var/lib/cobbler/triggers/change/*
runningpython trigger cobbler.modules.scm_track
runningshell triggers from /var/lib/cobbler/triggers/change/*
***TASK COMPLETE ***

同步完成没报错之后,现在重新启动dhcp,发现可以正常启动了
[iyunv@Cobbler~]# service dhcpd restart
Shuttingdown dhcpd:                                       [  OK  ]
Startingdhcpd:                                            [  OK  ]

最后执行cobblercheck重新检查一下,没有报错
[iyunv@Cobbler~]# cobbler check
Noconfiguration problems found.  Allsystems go.
此时cobbler已经安装配置完成,下面开始进行导入镜像等管理操作



3.Cobbler的管理和使用3.1 cobbler常用命令
    cobblercheck   #检查cobbler配置
    cobbler sync   #同步配置到dhcp/pxe和数据目录
    cobbler list   #列出所有的cobbler元素
    cobbler import   #导入安装的系统镜像
    cobbler report   #列出各元素的详细信息
    cobbler distro   #查看导入的发行版系统信息
    cobbler profile   #查看配置信息
    cobbler system   #查看添加的系统信息
    cobbler reposync   #同步yum仓库到本地

每个命令如果不熟悉参数可以使用 --help来帮助 如:
[iyunv@Cobbler ~]# cobbler--help
usage
=====
cobbler<distro|profile|system|repo|image|mgmtclass|package|file> ...
       [add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink>[options|--help]
[iyunv@Cobbler ~]# cobblerimport --help
Usage: cobbler [options]

Options:
  -h, --help            show this help message and exit
  --arch=ARCH           OS architecture being imported
  --breed=BREED         the breed being imported
  --os-version=OS_VERSION
                        the version beingimported
  --path=PATH           local path or rsync location
  --name=NAME           name, ex 'RHEL-5'
  --available-as=AVAILABLE_AS
                        tree is here, don'tmirror
  --kickstart=KICKSTART_FILE
                        assign this kickstartfile
  --rsync-flags=RSYNC_FLAGS
                        pass additional flagsto rsync

3.2 导入镜像文件,使用命令cobbler import
查看帮助信息
[iyunv@Cobbler~]# cobbler import --help
Usage:cobbler [options]

Options:
  -h, --help            show this help message and exit
  --arch=ARCH           OS architecture being imported
  --breed=BREED         the breed being imported
  --os-version=OS_VERSION   the version being imported
  --path=PATH           local path or rsync location
  --name=NAME           name, ex 'RHEL-5'
  --available-as=AVAILABLE_AS  tree is here, don't mirror
  --kickstart=KICKSTART_FILE  assign this kickstart file
  --rsync-flags=RSYNC_FLAGS  pass additional flags to rsync


现在开始导入:
挂载镜像文件到/media下
1
2
[iyunv@Cobbler~]# mount /dev/cdrom /media/
mount:block device /dev/sr0 is write-protected, mounting read-only



导入镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@Cobbler~]# cobbler import --path=/media --name=CentOS6.4 --arch=x86_64
taskstarted: 2015-06-01_172716_import
taskstarted (id=Media import, time=Mon Jun  117:27:16 2015)
Founda candidate signature: breed=redhat, version=rhel6
Founda matching signature: breed=redhat, version=rhel6
Addingdistros from path /var/www/cobbler/ks_mirror/CentOS6.4-x86_64:
creatingnew distro: CentOS6.4-x86_64
tryingsymlink: /var/www/cobbler/ks_mirror/CentOS6.4-x86_64 ->/var/www/cobbler/links/CentOS6.4-x86_64
creatingnew profile: CentOS6.4-x86_64
associatingrepos
checkingfor rsync repo(s)
checkingfor rhn repo(s)
checkingfor yum repo(s)
startingdescent into /var/www/cobbler/ks_mirror/CentOS6.4-x86_64 for CentOS6.4-x86_64
processingrepo at : /var/www/cobbler/ks_mirror/CentOS6.4-x86_64
need toprocess repo/comps: /var/www/cobbler/ks_mirror/CentOS6.4-x86_64
lookingfor /var/www/cobbler/ks_mirror/CentOS6.4-x86_64/repodata/*comps*.xml
Keepingrepodata as-is :/var/www/cobbler/ks_mirror/CentOS6.4-x86_64/repodata
***TASK COMPLETE ***




查看导入的镜像:
1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@Cobbler~]# cobbler distro list
   CentOS6.4-x86_64
[iyunv@Cobbler~]# cobbler list
distros:
   CentOS6.4-x86_64
profiles:
   CentOS6.4-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:



3.3 生成kickstart文件,并绑定到profile中
Kickstart的模版文件在/var/lib/cobbler/kickstarts中,在导入镜像的时候不指定kickstart文件,就会使用默认的模版文件,现在我们拷贝 一份,进行自定义修改
1
2
3
[iyunv@Cobbler~]# cd /var/lib/cobbler/kickstarts
[iyunv@Cobblerkickstarts]# cp sample.ks centos6.4x86_64.cfg
[iyunv@Cobbler kickstarts]# cobbler profile edit --name=CentOS6.4-x86_64--kickstart=/var/lib/cobbler/kickstarts/centos6.4x86_64.cfg



3.4修改centos6.4x86_64.cfg文件进行定制
默认的kickstart文件sampl.ks注释:
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

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5    #用户登录认证
# System bootloader configuration
bootloader --location=mbr #mbr引导
# Partition clearing information
clearpart --all --initlabel#默认清除所以分区
# Use text mode install
text    #默认以文本模式安装
# Firewall configuration
firewall --enabled #防火墙默认开启
# Run the Setup Agent on first boot
firstboot --disable      #禁用启动代理
# System keyboard
keyboard us     #默认英文键盘
# System language
lang en_US      #默认语言英文
# Use network installation
url --url=$tree    #网络安装路径
# If any cobbler repo definitions were referenced in thekickstart profile, include them here.
$yum_repo_stanza     #默认的yum仓库
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot   #安装完成后重启
#Root password
rootpw --iscrypted $default_password_crypted   #密码是我们/etc/cobbler/settings设置密码
# SELinux configuration
selinux --disabled   #默认关闭selinux
# Do not configure the X Window System
skipx  #默认没有安装图形界面
# System timezone
timezone America/New_York  #默认时区是美国/纽约
# Install OS instead of upgrade
install   #定义的是安装系统而不是升级系统
# Clear the Master Boot Record
zerombr   #默认清空所有的mbr
# Allow anaconda to partition the system as needed
autopart   #默认自动分区
#下面就是Cobbler自定执行的一些脚本,我就不解释了。
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%packages
$SNIPPET('func_install_if_enabled')
$SNIPPET('puppet_install_if_enabled')
%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('puppet_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




自定义的centos6.4x86_64.cfg文件
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
auth  --useshadow --enablemd5
bootloader--location=mbr
clearpart--all --initlabel
text
firewall--enabled
firstboot--disable
keyboardus
langen_US
url--url=$tree
$yum_repo_stanza
$SNIPPET('network_config')
reboot

rootpw--iscrypted $default_password_crypted
selinux--disabled
skipx
timezone  Asia/Shanghai
install
zerombr
autopart
part/boot --fstype="ext4" --size=200
partswap --fstype="swap" --size=4096
part /--fstype="ext4" --grow --size=1

%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
$SNIPPET('pre_anamon')

%packages
$SNIPPET('func_install_if_enabled')
$SNIPPET('puppet_install_if_enabled')
@base
@chinese-support
@development
@system-admin-tools
%post--nochroot
$SNIPPET('log_ks_post_nochroot')
%end
%post
$SNIPPET('log_ks_post')
$yum_config_stanza
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('puppet_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
$SNIPPET('post_anamon')
$SNIPPET('kickstart_done')



3.5 重启cobbler,并同步
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
[iyunv@Cobbler~]# service cobblerd restart
Stoppingcobbler daemon:                                   [  OK  ]
Startingcobbler daemon:                                   [  OK  ]
[iyunv@Cobbler~]# cobbler check
Noconfiguration problems found.  All systemsgo.
[iyunv@Cobbler~]# cobbler sync
taskstarted: 2015-06-01_175813_sync
taskstarted (id=Sync, time=Mon Jun  117:58:13 2015)
runningpre-sync triggers
cleaningtrees
removing:/var/www/cobbler/images/CentOS6.4-x86_64
removing:/var/lib/tftpboot/pxelinux.cfg/default
removing:/var/lib/tftpboot/grub/grub-x86.efi
removing:/var/lib/tftpboot/grub/efidefault
removing:/var/lib/tftpboot/grub/images
removing:/var/lib/tftpboot/grub/grub-x86_64.efi
removing:/var/lib/tftpboot/images/CentOS6.4-x86_64
removing:/var/lib/tftpboot/s390x/profile_list
copyingbootloaders
tryinghardlink /var/lib/cobbler/loaders/grub-x86.efi ->/var/lib/tftpboot/grub/grub-x86.efi
tryinghardlink /var/lib/cobbler/loaders/grub-x86_64.efi ->/var/lib/tftpboot/grub/grub-x86_64.efi
copyingdistros to tftpboot
copyingfiles for distro: CentOS6.4-x86_64
tryinghardlink /var/www/cobbler/ks_mirror/CentOS6.4-x86_64/images/pxeboot/vmlinuz-> /var/lib/tftpboot/images/CentOS6.4-x86_64/vmlinuz
tryinghardlink /var/www/cobbler/ks_mirror/CentOS6.4-x86_64/images/pxeboot/initrd.img-> /var/lib/tftpboot/images/CentOS6.4-x86_64/initrd.img
copyingimages
generatingPXE configuration files
generatingPXE menu structure
copyingfiles for distro: CentOS6.4-x86_64
tryinghardlink /var/www/cobbler/ks_mirror/CentOS6.4-x86_64/images/pxeboot/vmlinuz-> /var/www/cobbler/images/CentOS6.4-x86_64/vmlinuz
tryinghardlink /var/www/cobbler/ks_mirror/CentOS6.4-x86_64/images/pxeboot/initrd.img-> /var/www/cobbler/images/CentOS6.4-x86_64/initrd.img
Writingtemplate files for CentOS6.4-x86_64
renderingDHCP files
generating/etc/dhcp/dhcpd.conf
renderingTFTPD files
generating/etc/xinetd.d/tftp
processingboot_files for distro: CentOS6.4-x86_64
cleaninglink caches
renderingRsync files
runningpost-sync triggers
runningpython triggers from /var/lib/cobbler/triggers/sync/post/*
runningpython trigger cobbler.modules.sync_post_restart_services
running:dhcpd -t -q
receivedon stdout:
receivedon stderr:
running:service dhcpd restart
receivedon stdout: Shutting down dhcpd: [ OK  ]
Startingdhcpd: [  OK  ]

receivedon stderr:
runningshell triggers from /var/lib/cobbler/triggers/sync/post/*
runningpython triggers from /var/lib/cobbler/triggers/change/*
runningpython trigger cobbler.modules.scm_track
runningshell triggers from /var/lib/cobbler/triggers/change/*
***TASK COMPLETE ***



下面客户机就可以开机从网卡启动进行装系统了。

wKioL1VtXeaxPumFAADVMR8mAAo307.jpg
wKiom1VtXE3xIdw-AAKd0gdEflQ202.jpg
wKioL1VtXeaxVCjKAAEiKGkQ1OA089.jpg

补充:cobbler添加pxe菜单密码
1.生成hash密码
1
2
3
4
5
6
7
支持两种不同类型的密码:
sha1passmypassword

opensslpasswd -1 -salt sXiKzkus mypassword
我这里选择后者
    [iyunv@Cobblercobbler]# openssl passwd -1 -salt cobbler cobbler
$1$cobbler$M6SE55xZodWc9.vAKLJs6.




2.编辑配置文件pxedefault.template,添加如下红色部分
[iyunv@Cobblercobbler]# vim /etc/cobbler/pxe/pxedefault.template
DEFAULTmenu
PROMPT0
MENUTITLE Cobbler | http://www.cobblerd.org/
MENU MASTERPASSWD $1$cobbler$M6SE55xZodWc9.vAKLJs6.
TIMEOUT200
TOTALTIMEOUT6000
ONTIMEOUT$pxe_timeout_profile

LABELlocal
        MENU LABEL (local)
        MENU DEFAULT
        LOCALBOOT -1

$pxe_menu_items

MENUend
3.编辑pxeprofile文件,添加下面内容
[iyunv@Cobblercobbler]# vim /etc/cobbler/pxe/pxeprofile.template     
LABEL$profile_name
        MENU PASSWD
        kernel $kernel_path
        $menu_label
        $append_line
        ipappend 2
4.重新检查配置,并同步使其生效
1
2
[iyunv@Cobblercobbler]# cobbler check
[iyunv@Cobblercobbler]# cobbler sync




下次客户端装系统的时候,选择系统菜单时就需要输入密码了
3.cobbler相关目录和配置文件3.1 cobbler配置文件目录:
/etc/cobbler/settings       #cobbler主配置文件
/etc/cobbler/dhcp.template        #DHCP服务的配置模板
/etc/cobbler/tftpd.template     #tftp服务的配置模板
/etc/cobbler/rsync.template     #rsync服务的配置模板
/etc/cobbler/iso         #iso模板配置文件
/etc/cobbler/pxe         #pxe模板文件
/etc/cobbler/power  #电源的配置文件
/etc/cobbler/users.conf      #Web服务授权配置文件
/etc/cobbler/users.digest  #用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template         #DNS服务的配置模板
/etc/cobbler/modules.conf  #Cobbler模块配置文件
3.2 cobbler数据目录
/var/lib/cobbler/config     #配置文件
/var/lib/cobbler/triggers  #Cobbler命令
/var/lib/cobbler/kickstarts       #默认存放kickstart文件
/var/lib/cobbler/loaders  #存放的各种引导程序
/var/lib/dhcpd/dhcpd.leases        #dhcp租期缓存文件
/tftpboot/pxelinux.cfg/default      #pxe配置文件
/var/lib/cobbler/kickstarts_*.ks  #ks模板文件
3.3 系统镜像目录
/var/www/cobbler/ks_mirror      #导入的系统镜像列表
/var/www/cobbler/images      #导入的系统镜像启动文件
/var/www/cobbler/repo_mirror       #yum源存储目录
3.4 日志目录
/var/log/cobbler/install.log #客户端系统安装日志
/var/log/cobbler/cobbler.log #cobbler日志
4.cobbler的web端管理4.1 安装web端yuminstall cobbler-web -y
4.2 设置用户名和密码为已存在的用户cobbler重置密码
htdigest/etc/cobbler/users.digest "Cobbler" cobbler   
添加新用户
htdigest/etc/cobbler/users.digest "Cobbler" your_newname  

4.3修改配置文件,允许cobbler从web登录sed-i 's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf
4.4重启Cobbler与http/etc/init.d/cobblerdrestart  
/etc/init.d/httpdrestart
4.5访问cobbler web界面,配置管理在浏览器上输入http://cobber_ip/cobber_web打开web界面,输入刚才设置的用户名和密码,进入后台
wKiom1VtXJWQstgMAAFXnRZ8COA208.jpg
后台界面:
wKiom1VtXK6gRdPdAAHDuTQKamc941.jpg
下面开始导入镜像:
选择Import DVD,
在prefix项中要填写导入光盘的名字,只有不与先前的名字冲突,这里可以随意填。
在Arch项中选择光盘的类型,是i386、x86_64、ai64等。
在Breed项中选择系统的类型,CentOS、Debian、Ubuntu中的一种。
在Path项中填写光盘或ISO镜像包挂载的位置,路径一定要填写正确。
最后点击 run开始导入,过程很慢,可以通过日志查看导入状态
wKioL1VtXlyBfwu4AAGe2dpGnBg301.jpg
wKiom1VtXNTTpILsAAH-N7-AIkg133.jpg
查看日志中的导入状态,可以发现正在运行,第二个是之前用命令导入的,现在状态为complate完成
wKioL1VtXoey3IMXAAHmCqtqo30709.jpg


等到state状态为complate时,导入已完成
wKiom1VtXO7zIHdZAADirOoXfHQ769.jpg
查看生成的distros,若生成刚导入的系统,表示没问题,如没有生成需要查看日志,了解具体情况
wKioL1VtXoiSSGY6AAG73u9vGIo303.jpg

下面我们开始配置kickstart文件。点击kickstart  template,在右边点击创建新的kickstart文件,填写你准备好的kickstart内容即可
wKioL1VtXtvjwDh3AAMiGpUCWlU510.jpg
wKiom1VtXULglPTwAAIo3fFC5mk696.jpg
修改profile文件,让刚导入的镜像和刚创建的kickstart文件相关联,选择redhat6.4x86_64。点击edit
wKioL1VtXtzzk_dZAAJaH4z9CWk369.jpg
修改kickstart的路径,把刚才我们创建的kickstart的文件路径写进去,保存即可。
wKiom1VtXULDQezJAAKKxbfBrho523.jpg

此就是cobbler简单的web配置。


运维网声明 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-73350-1-1.html 上篇帖子: ubuntu如何安装flash插件 下篇帖子: xfs文件系统修复方法
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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