Cobbler无人值守安装

说在最前面的话
在看Cobbler之前请大家先看一下Kickstart无人值守安装,了解一下Cobbler的实现原理。但是Cobbler是独立的,不需要先安装Kickstart然后再安装Cobbler,这是写给不了解Kickstart的人看的。

1. Cobbler介绍

Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。

Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。

Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。

Cobbler内置了一个轻量级配置管理系统,但它也支持和其它配置管理系统集成,如Puppet,暂时不支持SaltStack。

Cobbler官网

1.1 Cobbler集成的服务

  • PXE服务支持
  • DHCP服务管理
  • DNS服务管理(可选bind,dnsmasq)
  • 电源管理
  • Kickstart服务支持
  • YUM仓库管理
  • TFTP(PXE启动时需要)
  • Apache(提供kickstart的安装源,并提供定制化的kickstart配置)

1.2 系统环境准备

  1. [root@linux-node1 ~]# cat /etc/redhat-release
  2. CentOS release 6.7 (Final)
  3. [root@linux-node1 ~]# uname -r
  4. 2.6.32-573.el6.x86_64
  5. [root@linux-node1 ~]# getenforce
  6. Disabled
  7. [root@linux-node1 ~]# /etc/init.d/iptables status
  8. iptables: Firewall is not running.
  9. [root@linux-node1 ~]# ifconfig eth0|awk -F "[ :]+" 'NR==2 {print $4}'
  10. 10.0.0.7
  11. [root@linux-node1 ~]# hostname
  12. linux-node1.example.com
  13. # 配置阿里云的epel源
  14. [root@linux-node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

注意:

  • 虚拟机网卡采用NAT模式,不要使用桥接模式,因为稍后我们会搭建DHCP服务器,在同一局域网多个DHCP服务会有冲突。
  • VMware的NAT模式的dhcp服务也关闭,避免干扰。

2. Cobbler安装配置

2.1 安装Cobbler

  1. [root@linux-node1 ~]# yum -y install cobbler cobbler-web dhcp tftp-server pykickstart httpd
  2. [root@linux-node1 ~]# rpm -ql cobbler # 查看安装的文件,下面列出部分。
  3. /etc/cobbler # 配置文件目录
  4. /etc/cobbler/settings # cobbler主配置文件,这个文件是YAML格式,Cobbler是python写的程序。
  5. /etc/cobbler/dhcp.template # DHCP服务的配置模板
  6. /etc/cobbler/tftpd.template # tftp服务的配置模板
  7. /etc/cobbler/rsync.template # rsync服务的配置模板
  8. /etc/cobbler/iso # iso模板配置文件目录
  9. /etc/cobbler/pxe # pxe模板文件目录
  10. /etc/cobbler/power # 电源的配置文件目录
  11. /etc/cobbler/users.conf # Web服务授权配置文件
  12. /etc/cobbler/users.digest # 用于web访问的用户名密码配置文件
  13. /etc/cobbler/dnsmasq.template # DNS服务的配置模板
  14. /etc/cobbler/modules.conf # Cobbler模块配置文件
  15. /var/lib/cobbler # Cobbler数据目录
  16. /var/lib/cobbler/config # 配置文件
  17. /var/lib/cobbler/kickstarts # 默认存放kickstart文件
  18. /var/lib/cobbler/loaders # 存放的各种引导程序
  19. /var/www/cobbler # 系统安装镜像目录
  20. /var/www/cobbler/ks_mirror # 导入的系统镜像列表
  21. /var/www/cobbler/images # 导入的系统镜像启动文件
  22. /var/www/cobbler/repo_mirror # yum源存储目录
  23. /var/log/cobbler # 日志目录
  24. /var/log/cobbler/install.log # 客户端系统安装日志
  25. /var/log/cobbler/cobbler.log # cobbler日志

2.2 配置Cobbler

  1. [root@linux-node1 ~]# /etc/init.d/httpd restart
  2. 停止 httpd: [失败]
  3. 正在启动 httpd: [确定]
  4. [root@linux-node1 ~]# /etc/init.d/cobblerd start
  5. Starting cobbler daemon: [确定]
  6. [root@linux-node1 ~]# cobbler check # 检查Cobbler的配置,如果看不到下面的结果,再次执行/etc/init.d/cobblerd restart
  7. The following are potential configuration items that you may want to fix:
  8. 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.
  9. 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.
  10. 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.
  11. 4 : change 'disable' to 'no' in /etc/xinetd.d/rsync
  12. 5 : debmirror package is not installed, it will be required to manage debian deployments and repositories
  13. 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
  14. 7 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
  15. Restart cobblerd and then run 'cobbler sync' to apply changes.
  16. # 看着上面的结果,一个一个解决。
  17. # 第1、2、6个问题,顺便修改其他功能
  18. [root@linux-node1 ~]# cp /etc/cobbler/settings{,.ori} # 备份
  19. # server,Cobbler服务器的IP。
  20. sed -i 's/server: 127.0.0.1/server: 10.0.0.7/' /etc/cobbler/settings
  21. # next_server,如果用Cobbler管理DHCP,修改本项,作用不解释,看kickstart。
  22. sed -i 's/next_server: 127.0.0.1/next_server: 10.0.0.7/' /etc/cobbler/settings
  23. # 用Cobbler管理DHCP
  24. sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings
  25. # 防止循环装系统,适用于服务器第一启动项是PXE启动。
  26. sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
  27. # 设置新装系统的默认root密码123456。下面的命令来源于提示6。random-phrase-here为干扰码,可以自行设定。
  28. [root@linux-node1 ~]# openssl passwd -1 -salt 'oldboy' '123456'
  29. $1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1
  30. [root@linux-node1 ~]# vim /etc/cobbler/settings
  31. default_password_crypted: "$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1"
  32. # 第3个问题
  33. [root@linux-node1 ~]# cobbler get-loaders # 会自动从官网下载
  34. [root@linux-node1 ~]# cd /var/lib/cobbler/loaders/ # 下载的内容
  35. [root@linux-node1 loaders]# ls
  36. COPYING.elilo COPYING.yaboot grub-x86_64.efi menu.c32 README
  37. COPYING.syslinux elilo-ia64.efi grub-x86.efi pxelinux.0 yaboot
  38. # 第4个问题
  39. [root@linux-node1 ~]# vim /etc/xinetd.d/rsync
  40. disable = no
  41. [root@linux-node1 ~]# /etc/init.d/xinetd restart
  42. 停止 xinetd: [确定]
  43. 正在启动 xinetd: [确定]
  44. [root@linux-node1 ~]# /etc/init.d/cobblerd restart
  45. Stopping cobbler daemon: [确定]
  46. Starting cobbler daemon: [确定]
  47. [root@linux-node1 ~]# cobbler check
  48. The following are potential configuration items that you may want to fix:
  49. 1 : debmirror package is not installed, it will be required to manage debian deployments and repositories # 和debian系统相关,不需要
  50. 2 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them # fence设备相关,不需要
  51. Restart cobblerd and then run 'cobbler sync' to apply changes.

2.3 配置DHCP

  1. # 修改cobbler的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。
  2. [root@linux-node1 ~]# vim /etc/cobbler/dhcp.template
  3. # 仅列出修改过的字段
  4. ……
  5. subnet 10.0.0.0 netmask 255.255.255.0 {
  6. option routers 10.0.0.2;
  7. option domain-name-servers 10.0.0.2;
  8. option subnet-mask 255.255.255.0;
  9. range dynamic-bootp 10.0.0.100 10.0.0.200;
  10. ……

2.4 同步cobbler配置

  1. # 同步最新cobbler配置,它会根据配置自动修改dhcp等服务。
  2. [root@linux-node1 ~]# cobbler sync # 同步所有配置,可以仔细看一下sync做了什么。
  3. task started: 2015-12-03_204822_sync
  4. task started (id=Sync, time=Thu Dec 3 20:48:22 2015)
  5. running pre-sync triggers
  6. cleaning trees
  7. removing: /var/lib/tftpboot/pxelinux.cfg/default
  8. removing: /var/lib/tftpboot/grub/images
  9. copying bootloaders
  10. trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
  11. copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
  12. trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
  13. trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
  14. trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
  15. trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
  16. trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
  17. copying distros to tftpboot
  18. copying images
  19. generating PXE configuration files
  20. generating PXE menu structure
  21. rendering DHCP files
  22. generating /etc/dhcp/dhcpd.conf
  23. rendering TFTPD files
  24. generating /etc/xinetd.d/tftp
  25. cleaning link caches
  26. running post-sync triggers
  27. running python triggers from /var/lib/cobbler/triggers/sync/post/*
  28. running python trigger cobbler.modules.sync_post_restart_services
  29. running: dhcpd -t -q
  30. received on stdout:
  31. received on stderr:
  32. running: service dhcpd restart
  33. received on stdout: 关闭 dhcpd:[确定]
  34. 正在启动 dhcpd:[确定]
  35. received on stderr:
  36. running shell triggers from /var/lib/cobbler/triggers/sync/post/*
  37. running python triggers from /var/lib/cobbler/triggers/change/*
  38. running python trigger cobbler.modules.scm_track
  39. running shell triggers from /var/lib/cobbler/triggers/change/*
  40. *** TASK COMPLETE ***
  41. # 再看一下dhcp的配置文件。
  42. [root@linux-node1 ~]# less /etc/dhcp/dhcpd.conf
  43. # ******************************************************************
  44. # Cobbler managed dhcpd.conf file
  45. # generated from cobbler dhcp.conf template (Thu Dec 3 12:48:23 2015)
  46. # Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
  47. # in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
  48. # overwritten.
  49. # ******************************************************************
  50. ddns-update-style interim;
  51. …………

2.5 开机启动

  1. # 启动相关服务并设置开机启动(可选) 与第二种方法二选一
  2. chkconfig httpd on
  3. chkconfig xinetd on
  4. chkconfig cobblerd on
  5. chkconfig dhcpd on
  6. /etc/init.d/httpd restart
  7. /etc/init.d/xinetd restart
  8. /etc/init.d/cobblerd restart
  9. /etc/init.d/dhcpd restart
  10. # 编写Cobbler相关服务启动脚本(可选)
  11. cat >>/etc/init.d/cobbler<<EOF
  12. #!/bin/bash
  13. # chkconfig: 345 80 90
  14. # description:cobbler
  15. case \$1 in
  16. start)
  17. /etc/init.d/httpd start
  18. /etc/init.d/xinetd start
  19. /etc/init.d/dhcpd start
  20. /etc/init.d/cobblerd start
  21. ;;
  22. stop)
  23. /etc/init.d/httpd stop
  24. /etc/init.d/xinetd stop
  25. /etc/init.d/dhcpd stop
  26. /etc/init.d/cobblerd stop
  27. ;;
  28. restart)
  29. /etc/init.d/httpd restart
  30. /etc/init.d/xinetd restart
  31. /etc/init.d/dhcpd restart
  32. /etc/init.d/cobblerd restart
  33. ;;
  34. status)
  35. /etc/init.d/httpd status
  36. /etc/init.d/xinetd status
  37. /etc/init.d/dhcpd status
  38. /etc/init.d/cobblerd status
  39. ;;
  40. sync)
  41. cobbler sync
  42. ;;
  43. *)
  44. echo "Input error,please in put 'start|stop|restart|status|sync'!"
  45. exit 2
  46. ;;
  47. esac
  48. EOF
  49. # chmod +x /etc/init.d/cobbler
  50. # chkconfig cobbler on

3. Cobbler的命令行管理

3.1 查看命令帮助

  1. [root@linux-node1 ~]# cobbler
  2. usage
  3. =====
  4. cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...
  5. [add|edit|copy|getks*|list|remove|rename|report] [options|--help]
  6. cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
  7. [root@linux-node1 ~]# cobbler import --help # 导入镜像
  8. Usage: cobbler [options]
  9. Options:
  10. -h, --help show this help message and exit
  11. --arch=ARCH OS architecture being imported
  12. --breed=BREED the breed being imported
  13. --os-version=OS_VERSION
  14. the version being imported
  15. --path=PATH local path or rsync location
  16. --name=NAME name, ex 'RHEL-5'
  17. --available-as=AVAILABLE_AS
  18. tree is here, don't mirror
  19. --kickstart=KICKSTART_FILE
  20. assign this kickstart file
  21. --rsync-flags=RSYNC_FLAGS
  22. pass additional flags to rsync
  23. cobbler check 核对当前设置是否有问题
  24. cobbler list 列出所有的cobbler元素
  25. cobbler report 列出元素的详细信息
  26. cobbler sync 同步配置到数据目录,更改配置最好都要执行下
  27. cobbler reposync 同步yum仓库
  28. cobbler distro 查看导入的发行版系统信息
  29. cobbler system 查看添加的系统信息
  30. cobbler profile 查看配置信息

3.2 导入镜像

  1. [root@linux-node1 ~]# mount /dev/cdrom /mnt/ # 挂载CentOS7的系统镜像。
  2. # 导入系统镜像
  3. [root@linux-node1 ~]# cobbler import --path=/mnt/ --name=CentOS-7.1-x86_64 --arch=x86_64
  4. # --path 镜像路径
  5. # --name 为安装源定义一个名字
  6. # --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
  7. # 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.1-x86_64,如果重复,系统会提示导入失败。
  8. [root@linux-node1 ~]# cobbler distro list # 查看镜像列表
  9. CentOS-7.1-x86_64
  10. # 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-7.1-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间。
  11. [root@linux-node1 ~]# cd /var/www/cobbler/ks_mirror/
  12. [root@linux-node1 ks_mirror]# ls
  13. CentOS-7.1-x86_64 config
  14. [root@linux-node1 ks_mirror]# ls CentOS-7.1-x86_64/
  15. CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
  16. EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
  17. EULA isolinux repodata TRANS.TBL

3.3 指定ks.cfg文件及调整内核参数

  1. # Cobbler的ks.cfg文件存放位置
  2. [root@linux-node1 ks_mirror]# cd /var/lib/cobbler/kickstarts/
  3. [root@linux-node1 kickstarts]# ls # 自带很多
  4. default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample_old.seed
  5. esxi4-ks.cfg legacy.ks sample_end.ks(默认使用的ks文件) sample_esxi5.ks sample.seed
  6. esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample.ks
  7. [root@linux-node1 kickstarts]# rz # 上传准备好的ks文件
  8. rz waiting to receive.
  9. Starting zmodem transfer. Press Ctrl+C to cancel.
  10. Transferring Cobbler-CentOS-7.1-x86_64.cfg...
  11. 100% 1 KB 1 KB/sec 00:00:01 0 Errors
  12. [root@linux-node1 kickstarts]# mv Cobbler-CentOS-7.1-x86_64.cfg CentOS-7.1-x86_64.cfg
  13. # 在第一次导入系统镜像后,Cobbler会给镜像指定一个默认的kickstart自动安装文件在/var/lib/cobbler/kickstarts下的sample_end.ks。
  14. [root@linux-node1 ~]# cobbler list
  15. distros:
  16. CentOS-7.1-x86_64
  17. profiles:
  18. CentOS-7.1-x86_64
  19. systems:
  20. repos:
  21. images:
  22. mgmtclasses:
  23. packages:
  24. files:
  25. # 查看安装镜像文件信息
  26. [root@linux-node1 ~]# cobbler distro report --name=CentOS-7.1-x86_64
  27. Name : CentOS-7.1-x86_64
  28. Architecture : x86_64
  29. TFTP Boot Files : {}
  30. Breed : redhat
  31. Comment :
  32. Fetchable Files : {}
  33. Initrd : /var/www/cobbler/ks_mirror/CentOS-7.1-x86_64/images/pxeboot/initrd.img
  34. Kernel : /var/www/cobbler/ks_mirror/CentOS-7.1-x86_64/images/pxeboot/vmlinuz
  35. Kernel Options : {}
  36. Kernel Options (Post Install) : {}
  37. Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-7.1-x86_64'}
  38. Management Classes : []
  39. OS Version : rhel7
  40. Owners : ['admin']
  41. Red Hat Management Key : <<inherit>>
  42. Red Hat Management Server : <<inherit>>
  43. Template Files : {}
  44. # 查看所有的profile设置
  45. [root@linux-node1 ~]# cobbler profile report
  46. # 查看指定的profile设置
  47. [root@linux-node1 ~]# cobbler profile report --name=CentOS-7.1-x86_64
  48. Name : CentOS-7.1-x86_64
  49. TFTP Boot Files : {}
  50. Comment :
  51. DHCP Tag : default
  52. Distribution : CentOS-7.1-x86_64
  53. Enable gPXE? : 0
  54. Enable PXE Menu? : 1
  55. Fetchable Files : {}
  56. Kernel Options : {}
  57. Kernel Options (Post Install) : {}
  58. Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks -->默认ks文件
  59. Kickstart Metadata : {}
  60. Management Classes : []
  61. Management Parameters : <<inherit>>
  62. Name Servers : []
  63. Name Servers Search Path : []
  64. Owners : ['admin']
  65. Parent Profile :
  66. Internal proxy :
  67. Red Hat Management Key : <<inherit>>
  68. Red Hat Management Server : <<inherit>>
  69. Repos : []
  70. Server Override : <<inherit>>
  71. Template Files : {}
  72. Virt Auto Boot : 1
  73. Virt Bridge : xenbr0
  74. Virt CPUs : 1
  75. Virt Disk Driver Type : raw
  76. Virt File Size(GB) : 5
  77. Virt Path :
  78. Virt RAM (MB) : 512
  79. Virt Type : kvm
  80. # 编辑profile,修改关联的ks文件
  81. [root@linux-node1 ~]# cobbler profile edit --name=CentOS-7.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg
  82. # 修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno16777736这种形式,但是为了运维标准化,我们需要将它变成我们常用的eth0,因此使用下面的参数。但要注意是CentOS7才需要下面的步骤,CentOS6不需要。
  83. [root@linux-node1 ~]# cobbler profile edit --name=CentOS-7.1-x86_64 --kopts='net.ifnames=0 biosdevname=0'
  84. [root@linux-node1 ~]# cobbler profile report CentOS-7.1-x86_64
  85. Name : CentOS-7.1-x86_64
  86. TFTP Boot Files : {}
  87. Comment :
  88. DHCP Tag : default
  89. Distribution : CentOS-7.1-x86_64
  90. Enable gPXE? : 0
  91. Enable PXE Menu? : 1
  92. Fetchable Files : {}
  93. Kernel Options : {'biosdevname': '0', 'net.ifnames': '0'}
  94. Kernel Options (Post Install) : {}
  95. Kickstart : /var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg
  96. Kickstart Metadata : {}
  97. Management Classes : []
  98. Management Parameters : <<inherit>>
  99. Name Servers : []
  100. Name Servers Search Path : []
  101. Owners : ['admin']
  102. Parent Profile :
  103. Internal proxy :
  104. Red Hat Management Key : <<inherit>>
  105. Red Hat Management Server : <<inherit>>
  106. Repos : []
  107. Server Override : <<inherit>>
  108. Template Files : {}
  109. Virt Auto Boot : 1
  110. Virt Bridge : xenbr0
  111. Virt CPUs : 1
  112. Virt Disk Driver Type : raw
  113. Virt File Size(GB) : 5
  114. Virt Path :
  115. Virt RAM (MB) : 512
  116. Virt Type : kvm
  117. # 每次修改完都要同步一次
  118. [root@linux-node1 ~]# cobbler sync

3.4 安装系统

可以很愉快的告诉你到这里就可以安装系统了!

新建一台虚拟机,不解释,开机就可以看到下面的图片了!

** 有没有发现不美观的地方?**

网址不是我的!改!

  1. #修改Cobbler提示
  2. [root@linux-node1 ~]# vim /etc/cobbler/pxe/pxedefault.template
  3. MENU TITLE Cobbler | http://www.zyops.com
  4. [root@linux-node1 ~]# cobbler sync # 修改配置都要同步

OK,现在好看多了。选择第二项就可以继续装机了。你可以让系统飞着,然后接着看下文!!

4. ks.cfg文件简析

文件大部分参数含义见kickstart文章,此处只讲一些不同的地方。同时可以参考模板文件。

  1. [root@linux-node1 kickstarts]# cat CentOS-7.1-x86_64.cfg
  2. # Cobbler for Kickstart Configurator for CentOS 7.1 by yao zhang
  3. install
  4. url --url=$tree # 这些$开头的变量都是调用配置文件里的值。
  5. text
  6. lang en_US.UTF-8
  7. keyboard us
  8. zerombr
  9. bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
  10. # Network information
  11. $SNIPPET('network_config')
  12. timezone --utc Asia/Shanghai
  13. authconfig --enableshadow --passalgo=sha512
  14. rootpw --iscrypted $default_password_crypted
  15. clearpart --all --initlabel
  16. part /boot --fstype xfs --size 1024 # CentOS7系统磁盘默认格式xfs
  17. part swap --size 1024
  18. part / --fstype xfs --size 1 --grow
  19. firstboot --disable
  20. selinux --disabled
  21. firewall --disabled
  22. logging --level=info
  23. reboot
  24. %pre
  25. $SNIPPET('log_ks_pre')
  26. $SNIPPET('kickstart_start')
  27. $SNIPPET('pre_install_network_config')
  28. # Enable installation monitoring
  29. $SNIPPET('pre_anamon')
  30. %end
  31. %packages
  32. @base
  33. @compat-libraries
  34. @debugging
  35. @development
  36. tree
  37. nmap
  38. sysstat
  39. lrzsz
  40. dos2unix
  41. telnet
  42. iptraf
  43. ncurses-devel
  44. openssl-devel
  45. zlib-devel
  46. OpenIPMI-tools
  47. screen
  48. %end
  49. %post
  50. systemctl disable postfix.service
  51. %end

5. 定制化安装

可能从学习kickstart开始就有人想怎样能够指定某台服务器使用指定ks文件,kickstart实现这功能可能比较复杂,但是Cobbler就很简单了。

区分一台服务器的最简单的方法就是物理MAC地址。

物理服务器的MAC地址在服务器上的标签上写了。

虚拟机的MAC查看

  1. cobbler system add --name=oldboy --mac=00:0C:29:7F:2F:A1 --profile=CentOS-7.1-x86_64 --ip-address=10.0.0.111 --subnet=255.255.255.0 --gateway=10.0.0.2 --interface=eth0 --static=1 --hostname=oldboy.example.com --name-servers="114.114.114.114 8.8.8.8"
  2. # --name 自定义,但不能重复
  3. # 查看定义的列表
  4. [root@linux-node1 ~]# cobbler system list
  5. oldboy
  6. [root@linux-node1 ~]# cobbler sync

再次开机安装就不再询问选择了,直接安装。

6. Cobbler的Web管理界面的安装与配置

已经安装cobbler-web软件。

访问网址:http://10.0.0.7/cobbler_webhttps://10.0.0.7/cobbler_web

默认用户名:cobbler
默认密码 :cobbler

  1. /etc/cobbler/users.conf # Web服务授权配置文件
  2. /etc/cobbler/users.digest # 用于web访问的用户名密码配置文件
  3. [root@linux-node1 ~]# cat /etc/cobbler/users.digest
  4. cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3
  5. # 设置Cobbler web用户登陆密码
  6. # 在Cobbler组添加cobbler用户,提示输入2遍密码确认
  7. [root@linux-node1 ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
  8. Changing password for user cobbler in realm Cobbler
  9. New password: 123456
  10. Re-type new password:123456
  11. [root@linux-node1 ~]# cobbler sync
  12. [root@linux-node1 ~]# /etc/init.d/httpd restart
  13. 停止 httpd: [确定]
  14. 正在启动 httpd: [确定]
  15. [root@linux-node1 ~]# /etc/init.d/cobblerd restart
  16. Stopping cobbler daemon: [确定]
  17. Starting cobbler daemon: [确定]

以后就需要用123456这个密码登录了。

接下来的操作就是点点鼠标了。

原文链接:Cobbler无人值守安装 – 运维之道

29
如无特殊说明,文章均为本站原创,转载请注明出处

该文章由 发布

这货来去如风,什么鬼都没留下!!!
发表我的评论

Hi,请填写昵称和邮箱!

取消评论
代码 贴图 加粗 链接 删除线 签到
(8)条精彩评论:
  1. 悠久之翼
    赞一个。
    悠久之翼2016-02-11 16:02 回复
  2. 小小志
    能出一个cobbler安装ubuntu 14.04的文章不
    小小志2016-02-14 14:57 回复
  3. 弓长善慈
    谢谢您。终于做成功了。O(∩_∩)O~~。 :grin:
    弓长善慈2016-04-14 12:06 回复
  4. 999
    :eek: :eek: :eek: :eek: :eek: 失败是成功他妈 加油
    9992016-10-21 10:58 回复
  5. <a href='http://blog.oldboyedu.com/autoinstall-cobbler/#commentform' rel='external nofollow' class='url'>redhat</a>
    :eek: :eek: :eek: :eek: :eek: :eek: :eek: 写的真棒!11
    redhat2016-10-31 22:14 回复
  6. <a href='http://www.zmzblog.com' rel='external nofollow' class='url'>朴实的追梦者</a>
    希望老男孩教育越来越好!
    朴实的追梦者2016-12-21 10:07 回复
  7. 俺不吃
    总是提示 file /etc/xinetd.d/rsync does not exist咋办
    俺不吃2017-01-23 11:24 回复
    • 老男孩
      这是cobbler的bug,不影响使用
      老男孩2017-04-17 15:04 回复