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

[经验分享] cobbler系统自动化实验配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-7-7 08:50:32 | 显示全部楼层 |阅读模式
一、安装
1.1 配置环境准备
前提:cobbler 由epel 源提供,故此需要事先配置指向epel 的yum 源方可进行类似下
面的安装过程。
Epel 源
1
2
3
4
[epel]
name=fedora epel
baseurl=https://dl.fedoraproject.org/pub/epel/6/x86_64/
gpgcheck=0



开发环境
1
2
3
# yum install cobbler cobbler-web pykickstart debmirror
# service httpd start
# service cobblerd start



执行“cobbler check 命令检查存的问题,而后逐一按提示解决之。常见的问题如下所示:
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 m essage 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
5 : comment 'dists' on /etc/debmirror.conf for proper debian support
6 : comment 'arches' on /etc/debmirror.conf for proper debian support
7 : 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
8 : 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.
解决方案
如上各问题的解决方法如下所示:
1、修改/etc/cobbler/settings 文件中的server 参数的值为提供cobbler 服务的主机相应的IP 地址或主机名,如172.16.100.15;
2、修改/etc/cobbler/settings 文件中的next_server 参数的值为提供PXE 服务的主机相应的IP 地址,如172.16.100.16;
3、如果当前节点可以访问互联网,执行“cobbler get-loaders”命令即可;否则,需要安装syslinux 程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件/var/lib/cobbler/loaders/目录中;
4、执行“chkconfig rsync on”命令即可;
5、注释/etc/debmirror.conf 文件中的“@dists="sid";”一行;
6、注释/etc/debmirror.conf 文件中的“@arches="i386";”一行;
7、执行“openssl passwd -1 -salt $(openssl rand -hex 4)”生成密码,并用其替换/etc/cobbler/settings 文件中default_password_crypted 参数的值;
8、执行“yum install cman fence-agents”命令安装相应的程序包即可;接着重启cobblerd,而后执行“cobbler sync”同步新的配置至cobbler。
二、配置及启动cobbler 所依赖的各服务
cobbler 的运行依赖于dhcp、tftp、rsync 及dns 服务。其中dhcp 可由dhcpd(isc)提供,也可由dnsmasq 提供;tftp 可由tftp-server 程序包提供,也可由cobbler 自带的tftp 功能提供;rsync 由rsync 程序包提供;dns 可由bind 提供,也可由dnsmasq 提供。cobbler 可自行管理这些服务中的部分甚至是全部,但需要配置/etc/cobbler/settings 文件中的“manage_dhcp”、“manage_tftpd”、“manage_rsync”和“manage_dns”分别进行定义。另外,由于每种服务都有着不同的实现方式,如若需要进行自定义,需要通过/etc/cobbler/modules.conf 配置文件中各服务的模块参数的值来实现。
本文采用了独立管理的方式,即不通过cobbler 来管理这些服务。
2.1 配置dhcp 服务
定义好所需的“subnet”及其它参数或选项,而后启动dhcpd 守护进程即可。本示例中所用的dhcpd 的配置如下所示:
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
option domain-name "linuxedu.top";
option domain-name-servers 192.168.1.120,192.168.1.0;

default-lease-time 43200;
max-lease-time 86400;

# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;


subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.120 192.168.1.140;
        option routers 192.168.1.114;
}
        next-server 192.168.1.114;
        filename="pxelinux.0";
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.



接着使用“service dhcpd start”启动服务即可
2.2 配置tftp 服务
1
2
chkconfig tftp on
service xinetd restart



三、配置cobbler
Cobbler 组件架构图
wKioL1d8i3PT7A1AAAIHTF_TuIg511.jpg
3.1 管理distro
使cobbler 变得可用的第一步为定义distro,其可以通过为其指定外部的安装引导内核及ramdisk 文件的方式实现。而如果已经有完整的系统安装树(如CentOS6 的安装镜像)则推荐使用import 直接导入的方式进行。
例如,对于已经挂载至/media/cdrom 目录的CentOS 6.5 x86_64 的安装镜像,则可以使用类似如下命令进行导入
1
cobbler import --name=centos-6.8.jason-x86_64 --path=/media/cdrom



可以使用cobbler distro list列出所有的distro.

1
2
[iyunv@node ~]# cobbler distro list
   centos-6.8.jason-x86_64



如果有kickstart 文件,也可以使用“--kickstart=/path/to/kickstart_file”进行导入,因此import 会自动为导入的distro 生成一个profile
3.2 管理profile
cobbler 使用profile 来为特定的需求类别提供所需要安装配置,即在distro 的基础上通过提供kickstart 文件来生成一个特定的系统安装配置。distro 的profile 可以出现在PXE的引导菜单中作为安装的选择之一。
因此,如果需要为前面创建的centos-6.8.jason-x86_64这个distro 提供一个可引导安装条目,其用到kickstart 文件为centos6.8.cfg,则可通过如下命令实现。
1
2
# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.8.
jason-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.8.cfg



注意此处的distro 必须与上面的cobbler distro list 结果名称保持一致
可使用“cobbler profile list”查看已经创建的profile。
1
2
3
[iyunv@node ~]# cobbler profile list
   centos-6.8-x86_64-basic
   centos-6.8.jason-x86_64



四、使用cobbler_web
4.1 配置cobbler_web 的认证功能
cobbler_web 支持多种认证方式,如authn_configfile、authn_ldap 或authn_pam 等,默认为authn_denyall,即拒绝所有用户登录。下面说明两种能认证用户登录cobbler_web 的方式。
4.1.1 使用authn_pam 模块认证cobbler_web 用户
首先修改modules 中[authentication]段的module 参数的值为authn_pam。文件路径为
/etc/cobbler/modules.conf
1
2
[authentication]
module=authn_pam



接着添加系统用户,用户名和密码按需设定即可,例如下面的命令所示
1
2
# useradd cobbleradmin
# echo 'cobblerpasswd' | passwd --stdin cobbleradmin



而后将cblradmin 用户添加至cobbler_web 的admin 组中。修改/etc/cobbler/users.conf
文件,将cblradmin 用户名添加为admin 参数的值即可,如下所示
1
2
[admins]
admin="cobbleradmin"



最后重启cobblerd 服务,通过http://YOUR_COBBLERD_IP/cobbler_web 访问即可
wKioL1d8jwjBIwzWAAAX05wVlXw620.jpg
4.1.2 使用authn_configfile 模块认证cobbler_web 用户首先修改modules.conf 中[authentication]段的module 参数的值为authn_configfile。
接着创建其认证文件/etc/cobbler/users.digest,并添加所需的用户即可。需要注意的是,添加第一个用户时,需要为htdigest 命令使用“-c”选项,后续添加其他用户时不能再使用;另外,cobbler_web 的realm 只能为Cobbler。如下所示。
1
# htdigest -c /etc/cobbler/users.digest Cobbler cblradmin



最后重启cobblerd 服务,通过http://YOUR_COBBLERD_IP/cobbler_web 访问即可。
新建一个虚拟机,验证一下是否能正常自动化安装部署
wKioL1d8j3GATih0AABsAyzYmPU385.jpg
开启虚拟机看是都能够正常进行,选择第二个菜单项
wKiom1d8j5vDZF2jAAAxP2Bw1JY308.jpg
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
[iyunv@node ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:41341               0.0.0.0:*                   LISTEN      1379/rpc.statd      
tcp        0      0 127.0.0.1:25151             0.0.0.0:*                   LISTEN      3804/python2        
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1357/rpcbind        
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1607/sshd           
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1435/cupsd         
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1686/master         
tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN      1933/sshd           
tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN      39452/sshd         
tcp        0      0 :::873                      :::*                        LISTEN      3378/xinetd         
tcp        0      0 :::40909                    :::*                        LISTEN      1379/rpc.statd      
tcp        0      0 :::111                      :::*                        LISTEN      1357/rpcbind        
tcp        0      0 :::80                       :::*                        LISTEN      2179/httpd         
tcp        0      0 :::22                       :::*                        LISTEN      1607/sshd           
tcp        0      0 ::1:631                     :::*                        LISTEN      1435/cupsd         
tcp        0      0 ::1:25                      :::*                        LISTEN      1686/master         
tcp        0      0 ::1:6010                    :::*                        LISTEN      1933/sshd           
tcp        0      0 ::1:6011                    :::*                        LISTEN      39452/sshd         
tcp        0      0 :::443                      :::*                        LISTEN      2179/httpd         
udp        0      0 0.0.0.0:51041               0.0.0.0:*                               1379/rpc.statd      
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1357/rpcbind        
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1435/cupsd         
udp        0      0 0.0.0.0:684                 0.0.0.0:*                               1357/rpcbind        
udp        0      0 0.0.0.0:67                  0.0.0.0:*                               3306/dhcpd         
udp        0      0 127.0.0.1:708               0.0.0.0:*                               1379/rpc.statd      
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               1215/dhclient      
udp        0      0 0.0.0.0:69                  0.0.0.0:*                               3378/xinetd         
udp        0      0 :::111                      :::*                                    1357/rpcbind        
udp        0      0 :::684                      :::*                                    1357/rpcbind        
udp        0      0 :::56142                    :::*                                    1379/rpc.statd




亲测 全自动安装,大神勿喷,请多指教


运维网声明 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-240489-1-1.html 上篇帖子: Radhat linux 6.3根分区在线扩容 下篇帖子: Linux下更改系统时区及时间
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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