利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统

系统: CentOS 7.5
ip: 10.0.0.11

    由于公司项目最近需要给新的服务器安装系统,所以需要使用Cobbler对服务器进行自动化的安装操作系统操作,Cobbler笔者在两年前已经有接触过,由于再次工作需要所以总结成文档分享给大家!

 

目录
一、 Cobbler介绍    3
1.1使用Cobbler装机注意事项    4
1.2 系统环境准备    4
1.3 配置阿里云的yum源和阿里云的epel源    4
二、安装配置cobbler    4
2.1 安装Cobbler    4
2.2 启动配置Cobbler及相关组件    5
问题1: ip修改为cobber本机ip    6
问题2: next-server修改为tftp-server    7
问题3: 修改tftp配置文件    7
问题4: 准备bootloader    7
问题5: 启动rsyncd    7
问题6: 非Debain系统可以忽略,可忽略    7
问题7: 为系统设置复杂密码    7
问题8: 非Debain系统可以忽略,可忽略    7
2.3 磁盘挂挂载并导入Cobbler镜像    9
三、 Cobbler的命令行管理    15
3.1 查看命令帮助    15
3.2 导入镜像定义distro    16
3.3 自定义ks.cfg    17
3.4 安装CentOS 7系统    21
3.5设置Cobbler默认启动项    22
四、Cobbler设置自定义yum源    23
4.1添加OpenStack最新版的repo源去Cobbler    23
4.2关联添加的repo去指定的profile    23
4.3同步新添加的repo源去Cobbler    23
4.4在系统ks文件中加入以下内容    24
4.5定时同步Cobbler repo源    25
五、使用cobbler-web管理cobbler    25
5.1 使用authn_configfile模块认证cobbler_web用户    25
5.1.1 Django高版本导致Cobbler Web和API无法正常工作处理    25
问题: 访问http://10.0.0.11/cobbler_web提示没有权限    27
5.2. Cobbler Web镜像管理    28
5.3 管理kickstart文件    28
5.4 指定kickstart文件    30
5.5 配置同步    31
六、使用Cobbler API自动化安装系统    31
6.1使用API命令自动化安装系统    31
6.2使用Python+Cobbler实现自动化安装系统(使用在自动化运维平台使用)    34
七、附录 ks.cfg文件(供参考)    35
7.1 CentOS-7-x86_64.cfg    35
7.2 CentOS-6-x86_64.cfg    37

一、 Cobbler介绍

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

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

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

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

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第1张图片

Cobbler工作模式

1.1使用Cobbler装机注意事项

①Cobbler自动装机服务器要给一个与其它业务系统网络不同的VLAN,防止服务器异常使用网卡启动后对服务器进行误重装系统操作,导致出现事故问题。

②防止Cobbler对服务器多次安装需要设置相应设置只对服务器进行一次安装操作系统操作,pxe_just_once要在cobber的setting配置文件里面设置为1。

1.2 系统环境准备

[root@node1 ~]# setenforce 0

Disabled

[root@node1 ~]# systemctl stop firewalld

[root@node1 ~]# systemctl disable firewalld

 

1.3 配置阿里云的yum源和阿里云的epel源

[root@node1 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

[root@node1 ~]# rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm

二、安装配置cobbler

2.1 安装Cobbler

[root@node1 ~]# yum -y install dhcp tftp tftp-server  cobbler xinetd cobbler-web pykickstart httpd

[root@node1 ~]# rpm -ql cobbler  # 查看安装的文件,下面列出部分。

/etc/cobbler                  # 配置文件目录

/etc/cobbler/settings         # cobbler主配置文件,这个文件是YAML格式,Cobblerpython写的程序。

/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模块配置文件

/var/lib/cobbler              # Cobbler数据目录

/var/lib/cobbler/config       # 配置文件

/var/lib/cobbler/kickstarts   # 默认存放kickstart文件

/var/lib/cobbler/loaders      # 存放的各种引导程序

/var/www/cobbler              # 系统安装镜像目录

/var/www/cobbler/ks_mirror    # 导入的系统镜像列表

/var/www/cobbler/images       # 导入的系统镜像启动文件

/var/www/cobbler/repo_mirror  # yum源存储目录

/var/log/cobbler              # 日志目录

/var/log/cobbler/install.log  # 客户端系统安装日志

/var/log/cobbler/cobbler.log  # cobbler日志

2.2 启动配置Cobbler及相关组件

 [root@node1 ~]# systemctl start httpd      #启动apache服务

[root@node1 ~]# systemctl enable httpd.service #开机自启动apache服务

[root@node1 ~]# systemctl start cobblerd.service #启动cobblerd服务

[root@node1 ~]# systemctl enable cobblerd.service #开机自启动 cobblerd服务

[root@node1 ~]# systemctl start xinetd   #启动xinetd服务

[root@node1 ~]# systemctl enable xinetd  #开机自动东xinetd服务

 

 [root@node1 cobbler]# cobbler check   #检查cobbler环境

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 t         han node1, or kickstarting features will not work.  This should be a resolva         ble hostname or IP for the boot server as reachable by all machines that will us         e it.

2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings m         ust be set to something other than 127.0.0.1, and should match the IP of the boo         t server on the PXE network.

3 : change 'disable' to 'no' in /etc/xinetd.d/tftp

4 : 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 t         his directory, should you want to support all architectures, should include pxel         inux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is th         e easiest way to resolve these requirements.

5 : enable and start rsyncd.service with systemctl

6 : debmirror package is not installed, it will be required to manage debian dep         loyments and repositories

7 : The default password used by the sample templates for newly installed machin         es (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 m         anagement features. install cman or fence-agents to use them

 

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

 

 

逐个解决以上问题:

[root@node1 ~]#  cp /etc/cobbler/settings{,.ori}  # 备份cobbler配置文件

 

 

问题1: ip修改为cobber本机ip

sed -i 's/server: 127.0.0.1/server: 10.0.0.11/' /etc/cobbler/settings

 

问题2: next-server修改为tftp-server

sed -i 's/next_server: 127.0.0.1/next_server: 10.0.0.11/' /etc/cobbler/settings

 

问题3: 修改tftp配置文件

[root@node1 ~]#  cp /etc/xinetd.d/tftp{,.ori}  # 备份tftp配置文件

sed -i '14c   disable                 = no' /etc/xinetd.d/tftp    

 

问题4: 准备bootloader

[root@node1 cobbler]# cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/cobbler/loaders/

 

cobbler get-loaders

 

问题5: 启动rsyncd

 [root@node1 cobbler]# systemctl start rsyncd   #启动rsync服务

[root@node1 cobbler]# systemctl enable rsyncd   #开机自启动rsync服务

 

问题6: 非Debain系统可以忽略,可忽略

 

问题7: 为系统设置复杂密码

[root@node1 cobbler]# openssl passwd -1 -salt 'qiang' '123456'

$1$qiang$/kP7YwV0DnGOHvTr2HXV1.

 

sed -i 's#$1$mF86/UHC$WvcIcX2t6crBz2onWxyac.#$1$qiang$/kP7YwV0DnGOHvTr2HXV1.#g' /etc/cobbler/settings

 

问题8: 非Debain系统可以忽略,可忽略

 

sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings

 

#防止系统被多次安装

sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings

 

#修改cobbler修改dhcp配置文件选项设置

sed -i 's/ manage_dhcp: 0/ manage_dhcp: 1/' /etc/cobbler/settings

 

 

systemctl restart cobblerd    #重启cobbler服务

[root@node1 ~]# cobbler sync  #同步cobbler

task started: 2019-08-04_041916_sync

task started (id=Sync, time=Sun Aug  4 04:19:16 2019)

running pre-sync triggers

cleaning trees

removing: /var/lib/tftpboot/grub/images

copying bootloaders

trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0

trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32

trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk

copying distros to tftpboot

copying images

generating PXE configuration files

generating PXE menu structure

rendering DHCP files

generating /etc/dhcp/dhcpd.conf

rendering TFTPD files

generating /etc/xinetd.d/tftp

cleaning link caches

running post-sync triggers

running python triggers from /var/lib/cobbler/triggers/sync/post/*

running python trigger cobbler.modules.sync_post_restart_services

running: dhcpd -t -q

received on stdout:

received on stderr:

running: service dhcpd restart

received on stdout:

received on stderr: Redirecting to /bin/systemctl restart dhcpd.service

 

running shell triggers from /var/lib/cobbler/triggers/sync/post/*

running python triggers from /var/lib/cobbler/triggers/change/*

running python trigger cobbler.modules.manage_genders

running python trigger cobbler.modules.scm_track

running shell triggers from /var/lib/cobbler/triggers/change/*

*** TASK COMPLETE ***

 

[root@node1 ~]# systemctl restart xinetd

 

[root@node1 ~]# cobbler check

The following are potential configuration items that you may want to fix:

 

1 : debmirror package is not installed, it will be required to manage debian deployments and repositories

2 : 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.

 

 [root@node1 dhcp]# cp /etc/cobbler/dhcp.template{,.ori}

[root@node1 dhcp]# vim /etc/cobbler/dhcp.template  

subnet 10.0.0.0 netmask 255.255.255.0 {    #子网和掩码

     option routers             10.0.0.2;     #网关地址   

     option domain-name-servers qiang.com;  #Cobbler主机名

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        10.0.0.200 10.0.0.250;

     default-lease-time         21600;

     max-lease-time             43200;

     next-server                $next_server;

 

 

[root@node1 dhcp]# systemctl start dhcpd.service

[root@node1 dhcp]# systemctl enable dhcpd.service

 

2.3 磁盘挂挂载并导入Cobbler镜像

 

导入centos光盘镜像后执行挂载操作,首先可将系统镜像挂载去CDROM

[root@node1 ~]# mount /dev/cdrom /mnt

 

 [root@node1 ~]# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64  #导入系统文件到cobbler

task started: 2019-08-04_043223_import

task started (id=Media import, time=Sun Aug  4 04:32:23 2019)

Found a candidate signature: breed=redhat, version=rhel6

Found a candidate signature: breed=redhat, version=rhel7

Found a matching signature: breed=redhat, version=rhel7

Adding distros from path /var/www/cobbler/ks_mirror/CentOS-7-x86_64:

creating new distro: CentOS-7-x86_64

trying symlink: /var/www/cobbler/ks_mirror/CentOS-7-x86_64 -> /var/www/cobbler/links/CentOS-7-x86_64

creating new profile: CentOS-7-x86_64

associating repos

checking for rsync repo(s)

checking for rhn repo(s)

checking for yum repo(s)

starting descent into /var/www/cobbler/ks_mirror/CentOS-7-x86_64 for CentOS-7-x86_64

processing repo at : /var/www/cobbler/ks_mirror/CentOS-7-x86_64

need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-7-x86_64

looking for /var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata/*comps*.xml

Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-7-x86_64/repodata

*** TASK COMPLETE ***

[root@node1 ks_mirror]# pwd

/var/www/cobbler/ks_mirror    #存放镜像文件的路径

[root@node1 ks_mirror]# ls

CentOS-7-x86_64  config

[root@node1 ~]# umount /mnt/

[root@node1 ~]# mount /dev/cdrom /mnt

[root@node1 ~]# cobbler import --path=/mnt/ --name=CentOS-6-x86_64 --arch=x86_64

 

[root@node1 ~]# cobbler profile list

   CentOS-6-x86_64

   CentOS-7-x86_64

 

[root@node1 ~]# 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          : <>

Name Servers                   : []

Name Servers Search Path       : []

Owners                         : ['admin']

Parent Profile                 :

Internal proxy                 :

Red Hat Management Key         : <>

Red Hat Management Server      : <>

Repos                          : []

Server Override                : <>

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          : <>

Name Servers                   : []

Name Servers Search Path       : []

Owners                         : ['admin']

Parent Profile                 :

Internal proxy                 :

Red Hat Management Key         : <>

Red Hat Management Server      : <>

Repos                          : []

Server Override                : <>

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

 

上存ks文件到  /var/lib/cobbler/kickstarts

 

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

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

 

[root@node1 kickstarts]# cobbler profile rename --name=CentOS-7-X86_64 --newname=Redhat7-x86_64 #修改profile名称

 

[root@node1 kickstarts]# cobbler profile edit --name=CentOS-7-x86_64 --kopts='net.ifnames=0 biosdevname=0' #设置centos7装机网卡为eth0

[root@node1 kickstarts]# 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                 : {'biosdevname': '0', 'net.ifnames': '0'}

Kernel Options (Post Install)  : {}

Kickstart                      : /var/lib/cobbler/kickstarts/CentOS-7-X86_64.cfg

Kickstart Metadata             : {}

Management Classes             : []

Management Parameters          : <>

Name Servers                   : []

Name Servers Search Path       : []

Owners                         : ['admin']

Parent Profile                 :

Internal proxy                 :

Red Hat Management Key         : <>

Red Hat Management Server      : <>

Repos                          : []

Server Override                : <>

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/CentOS-6-X86_64.cfg

Kickstart Metadata             : {}

Management Classes             : []

Management Parameters          : <>

Name Servers                   : []

Name Servers Search Path       : []

Owners                         : ['admin']

Parent Profile                 :

Internal proxy                 :

Red Hat Management Key         : <>

Red Hat Management Server      : <>

Repos                          : []

Server Override                : <>

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

 

[root@node1 kickstarts]# cobbler sync

task started: 2019-08-04_062653_sync

task started (id=Sync, time=Sun Aug  4 06:26:53 2019)

running pre-sync triggers

cleaning trees

removing: /var/www/cobbler/images/CentOS-7-x86_64

removing: /var/www/cobbler/images/CentOS-6-x86_64

removing: /var/lib/tftpboot/pxelinux.cfg/default

removing: /var/lib/tftpboot/grub/images

removing: /var/lib/tftpboot/grub/grub-x86.efi

removing: /var/lib/tftpboot/grub/grub-x86_64.efi

removing: /var/lib/tftpboot/grub/efidefault

removing: /var/lib/tftpboot/images/CentOS-7-x86_64

removing: /var/lib/tftpboot/images/CentOS-6-x86_64

removing: /var/lib/tftpboot/s390x/profile_list

copying bootloaders

trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi

trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi

copying distros to tftpboot

copying files for distro: CentOS-7-x86_64

trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-7-x86_64/vmlinuz

trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-7-x86_64/initrd.img

copying files for distro: CentOS-6-x86_64

trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-6-x86_64/vmlinuz

trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-6-x86_64/initrd.img

copying images

generating PXE configuration files

generating PXE menu structure

copying files for distro: CentOS-7-x86_64

trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-7-x86_64/vmlinuz

trying hardlink /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-7-x86_64/initrd.img

Writing template files for CentOS-7-x86_64

copying files for distro: CentOS-6-x86_64

trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-6-x86_64/vmlinuz

trying hardlink /var/www/cobbler/ks_mirror/CentOS-6-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-6-x86_64/initrd.img

Writing template files for CentOS-6-x86_64

rendering DHCP files

generating /etc/dhcp/dhcpd.conf

rendering TFTPD files

generating /etc/xinetd.d/tftp

processing boot_files for distro: CentOS-7-x86_64

processing boot_files for distro: CentOS-6-x86_64

cleaning link caches

running post-sync triggers

running python triggers from /var/lib/cobbler/triggers/sync/post/*

running python trigger cobbler.modules.sync_post_restart_services

running: dhcpd -t -q

received on stdout:

received on stderr:

running: service dhcpd restart

received on stdout:

received on stderr: Redirecting to /bin/systemctl restart dhcpd.service

 

running shell triggers from /var/lib/cobbler/triggers/sync/post/*

running python triggers from /var/lib/cobbler/triggers/change/*

running python trigger cobbler.modules.manage_genders

running python trigger cobbler.modules.scm_track

running shell triggers from /var/lib/cobbler/triggers/change/*

*** TASK COMPLETE ***

[root@node1 ~]# systemctl restart xinetd

然后即可进行系统安装

cobbler的运行依赖于dhcptftprsyncdns服务。其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler自带的tftp功能提供;rsyncrsync程序包提供;dns可由bind提供,也可由dnsmasq提供。

cobbler可自行管理这些服务中的部分甚至是全部,但需要配置/etc/cobbler/settings文件中的“manage_dhcp”“manage_tftpd”“manage_rsync”“manage_dns”分别进行定义。另外,由于每种服务都有着不同的实现方式,如若需要进行自定义,需要通过修改/etc/cobbler/modules.conf配置文件中各服务的模块参数的值来实现。

三、 Cobbler的命令行管理

3.1 查看命令帮助

[root@node1 ~]# cobbler

usage

=====

cobbler ...

        [add|edit|copy|getks*|list|remove|rename|report] [options|--help]

cobbler [options|--help]

 

[root@node1 ~]# cobbler import --help  #导入镜像定义distro

Usage: cobbler import [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

 

cobbler check    核对当前设置是否有问题

cobbler list     列出所有的cobbler元素

cobbler report   列出元素的详细信息

cobbler sync     同步配置到数据目录,更改配置最好都要执行下

cobbler reposync 同步yum仓库

cobbler distro   查看导入的发行版系统信息

cobbler system   查看添加的系统信息

cobbler profile  查看配置信息

3.2 导入镜像定义distro

挂载系统镜像

[root@node1 ~]# mkdir /media/cdrom

[root@node1 ~]# mount -r /dev/cdrom /media/cdrom

从光盘导入文件定义distro

[root@node1 ~]# cobbler import --name="CentOS-7-x86_64" --path=/media/cdrom

# --path 镜像路径

# --name 为安装源定义一个名字,distro名字

# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64

# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7-x86_64,如果重复,系统会提示导入失败。

 

注意: import自动为导入的distro自动生成一个同名的profile, 并同时提供了一个最小化安装的kickstart文件,可以实现自动化安装,但可能并不符合需求

 

 [root@node1 ~]# cobbler distro list   #列出当前的distro

   CentOS-7-x86_64

 

# 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-7-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间。

[root@node1 ~]# cd /var/www/cobbler/ks_mirror/

[root@node1 ks_mirror]# ls

CentOS-7-x86_64  config

[root@node1 ks_mirror]# ls CentOS-7-x86_64/

CentOS_BuildTag  GPL       LiveOS    RPM-GPG-KEY-CentOS-7

EFI              images    Packages  RPM-GPG-KEY-CentOS-Testing-7

EULA             isolinux  repodata  TRANS.TBL

 

 [root@node1 ~]# cobbler profile list  #列出当前的profile

   CentOS-7-x86_64

3.3 自定义ks.cfg

[root@node1 ks_mirror]# cd /var/lib/cobbler/kickstarts/ #Cobblerks.cfg文件存放位置

 

[root@node1 kickstarts]# ls

default.ks    install_profiles  sample_autoyast.xml  sample_esxi4.ks  sample_old.seed

esxi4-ks.cfg  legacy.ks         sample_end.ks(默认使用的ks文件)        sample_esxi5.ks  sample.seed

esxi5-ks.cfg  pxerescue.ks      sample_esx4.ks       sample.ks

 

 [root@node1 kickstarts]# vim centos7.cfg #使用pxekickstart文件,并修改

 

url --url="http://10.0.0.11/cobbler/ks_mirror/CentOS-7-x86_64/"

 

注意: 自定义的ks文件和模版的ks文件稍有不同, 某些变量无法从配置文件中获取, url --url=$tree,

rootpw --iscrypted $default_password_crypted

 

[root@node1 kickstarts]# cat centos7.cfg

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Install OS instead of upgrade

install

# Keyboard layouts

# old format: keyboard us

# new format:

keyboard --vckeymap=us --xlayouts='us'

# Root password

rootpw --iscrypted $1$hgfvQffN$tXNj5mQldgQt4ziW1QhNF0

# Use network installation

url --url="http://10.0.0.11/cobbler/ks_mirror/CentOS-7-x86_64/"

# System language

lang en_US

# Firewall configuration

firewall --disabled

# System authorization information

auth  --useshadow  --passalgo=sha512

# Use graphical install

graphical

# Run the Setup Agent on first boot

firstboot --enable

# SELinux configuration

selinux --disabled

# Do not configure the X Window System

skipx

 

# System services

services --disabled="chronyd"

ignoredisk --only-use=sda

# Network information

network  --bootproto=dhcp --device=eno16777984

# Reboot after installation

reboot

# System timezone

timezone Asia/Shanghai --ntpservers=3.centos.pool.ntp.org,0.centos.pool.ntp.org,2.centos.pool.ntp.org,1.centos.pool.ntp.org

# System bootloader configuration

bootloader --location=mbr --boot-drive=sda

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel

# Disk partitioning information

part /boot --asprimary --fstype="xfs" --size=1000

part swap --fstype="swap" --size=8000

part / --fstype="xfs" --grow --size=1

 

%packages

@^minimal

@core

 

%end

 

# 查看指定的profile设置

[root@node1 kickstarts]# cobbler profile report --name=CentOS-7-x86_64 #查看指定的profile设置

 

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   默认ks文件

Kickstart Metadata             : {}

Management Classes             : []

Management Parameters          : <>

Name Servers                   : []

Name Servers Search Path       : []

Owners                         : ['admin']

Parent Profile                 :

Internal proxy                 :

Red Hat Management Key         : <>

Red Hat Management Server      : <>

Repos                          : []

Server Override                : <>

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

 

 

 [root@node1 kickstarts]# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg #编辑profile,修改关联的ks文件

 

 

[root@node1 kickstarts]# cobbler profile report --name=CentOS-7-x86_64             

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/centos7.cfg

Kickstart Metadata             : {}

Management Classes             : []

Management Parameters          : <>

Name Servers                   : []

Name Servers Search Path       : []

Owners                         : ['admin']

Parent Profile                 :

Internal proxy                 :

Red Hat Management Key         : <>

Red Hat Management Server      : <>

Repos                          : []

Server Override                : <>

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

 

# 每次修改配置后都要进行cobbler同步操作!

[root@node1 kickstarts]# cobbler sync

 

3.4 安装CentOS 7系统

新建一台虚拟机,启动

local 本地硬盘启动

CentOS-6-x86_64 : profile名字

CentOS-7-x86_64 : profile名字

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第2张图片

选择需要操作的系统即可进行安装,我们这里选择CentOS7~的选项,后面会介绍如何设定默认选项,从而免去人工的选择操作。

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第3张图片

3.5设置Cobbler默认启动项

[root@node1 ~]#cp /var/lib/tftpboot/pxelinux.cfg/default{,.ori}

[root@node1 ~]# vim /var/lib/tftpboot/pxelinux.cfg/default

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第4张图片

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第5张图片

[root@node1 ~]# cobbler sync  #进行cobbler同步操作

 

然后需要安装的系统即可不用选择即可自动安装。

 

 

四、Cobbler设置自定义yum源

需要注意cobbler的设置文件是否设置为yum_post_install_mirror: 1

4.1添加OpenStack最新版的repo源去Cobbler

 

[root@node1 ~]# cobbler repo add --name=openstack-stein --mirror=https://mirrors.aliyun.com/centos/7.6.1810/cloud/x86_64/openstack-stein/ --breed=yum  #添加openstack最新版的yum

 

4.2关联添加的repo去指定的profile

[root@node1 ~]#  cobbler profile edit --name=CentOS-7-x86_64 --repos=openstack-stein

 

4.3同步新添加的repo源去Cobbler

[root@node1 ~]# cobbler reposync

 

task started: 2019-08-04_092422_reposync

task started (id=Reposync, time=Sun Aug  4 09:24:22 2019)

hello, reposync

run, reposync, run!

creating: /var/www/cobbler/repo_mirror/openstack-stein/config.repo

creating: /var/www/cobbler/repo_mirror/openstack-stein/.origin/openstack-stein.repo

running: /usr/bin/reposync -l -n -d --config=/var/www/cobbler/repo_mirror/openstack-stein/.origin/openstack-stein.repo --repoid=openstack-stein --download_path=/var/www/cobbler/repo_mirror -a x86_64

2.9 kB     00:00    

 

received on stderr:

running: createrepo  -c cache -s sha /var/www/cobbler/repo_mirror/openstack-stein

received on stdout: Spawning worker 0 with 390 pkgs

Spawning worker 1 with 390 pkgs

Spawning worker 2 with 390 pkgs

Spawning worker 3 with 390 pkgs

Workers Finished

Saving Primary metadata

Saving file lists metadata

Saving other metadata

Generating sqlite DBs

Sqlite DBs complete

 

received on stderr:

running: chown -R root:apache /var/www/cobbler/repo_mirror/openstack-stein

received on stdout:

received on stderr:

running: chmod -R 755 /var/www/cobbler/repo_mirror/openstack-stein

received on stdout:

received on stderr:

*** TASK COMPLETE ***

 

然后我们可以去查看源

[root@node1 ~]# ll /var/www/cobbler/repo_mirror

total 124

drwxr-xr-x 5 root apache 98304 Aug  4 09:24 openstack-stein

4.4在系统ks文件中加入以下内容

%post

# Start yum configuration

$yum_config_stanza

# End yum configuration

 

4.5定时同步Cobbler repo源

 

echo “1 3 * * * /usr/bin/cobbler reposync --tries=3 --no-fail” >> /var/spool/cron/root

 

五、使用cobbler-web管理cobbler

5.1 使用authn_configfile模块认证cobbler_web用户

 

[root@node1 cobbler]#  sed -i 's/module = authn_configfile/module = authn_configfile/g' /etc/cobbler/modules.conf

创建认证文件

[root@node1 cobbler]# htdigest /etc/cobbler/users.digest "Cobbler" qiang  #修改qiang用户的密码

Adding password for qiang in realm Cobbler.

New password:

Re-type new password:

输入密码: 123456

账号: qiang

 

[root@node1 cobbler]# systemctl restart cobblerd.service

[root@node1 cobbler]# systemctl restart httpd

 

登陆Cobbler Web:

https://10.0.0.11/cobbler_web

5.1.1 Django高版本导致Cobbler Web和API无法正常工作处理

                           问题截图

处理方法:

[root@cobbler ~]# rpm -qa | grep "python2-django"

python2-django-1.11.21-2.el7.noarch

[root@cobbler ~]# rpm -e --nodeps python2-django-1.11.21-2.el7.noarch

[root@cobbler ~]# yum install python2-pip -y

[root@cobbler ~]# pip install --upgrade pip

[root@cobbler ~]# pip install Django==1.9.13

 

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第6张图片


利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第7张图片
导入镜像定义distro

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第8张图片
备注: Prefix 即 name

问题: 访问http://10.0.0.11/cobbler_web提示没有权限

Forbidden

 

You don't have permission to access /cobbler_web on this server.

分析日志

[Sun Jun 04 01:26:31.669590 2017] [ssl:error] [pid 5536] [client 172.16.0.10:52276] AH02219: access to /usr/share/cobbler/web/cobbler.wsgi failed, reason: SSL connection required

解决方法:

使用https地址访问: https://10.0.0.11/cobbler_web

在浏览器上添加例外

5.2. Cobbler Web镜像管理

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第9张图片


 

5.3 管理kickstart文件

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第10张图片

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第11张图片

5.4 指定kickstart文件

 

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第12张图片

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第13张图片

5.5 配置同步

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第14张图片

 

六、使用Cobbler API自动化安装系统

6.1使用API命令自动化安装系统

cobbler system add --name=qiang.com --mac=00:0C:29:B3:B5:9E --profile=CentOS-7-x86_64 \

--ip-address=10.0.0.168 --subnet=255.255.255.0 --gateway=10.0.0.2 --interface=eth0 \

--static=1 --hostname=qiang --name-servers="8.8.8.8" \

--kickstart=/var/lib/cobbler/kickstarts/CentOS-7-X86_64.cfg

 

[root@node1 pxelinux.cfg]# cobbler system list

   qiang

[root@node1 pxelinux.cfg]# cobbler sync

 

[root@node1 pxelinux.cfg]# cat /etc/dhcp/dhcpd.conf |tail -13  #可以看到我们刚才API命令已经录入系统

# group for Cobbler DHCP tag: default

group {

    host generic1 {

        hardware ethernet 00:0C:29:B3:B5:9E;

        fixed-address 10.0.0.168;

        option host-name "qiang.com";

        option subnet-mask 255.255.255.0;

        option routers 10.0.0.2;

        filename "/pxelinux.0";

        next-server 10.0.0.11;

    }

}

那台所属的虚拟机开机后,即可实现自动化安装系统!

利用Cobbler给新的服务器自动安装CentOs6和CentOs7系统_第15张图片

cobbler服务器上查看下日志,后面客户机请求的时候会有dhcp请求信息(不是本次试验的重点,但是可以帮你理解dhcp请求的过程)

 

dhcp请求的4个步骤

dhcp  discover

dhcp  offer

dhcp  request

dhcp  ack

 

 

[root@node1 ~]# > /var/log/messages

[root@node1 ~]# tail -500f /var/log/messages

Aug  6 15:03:35 localhost dhcpd: DHCPDISCOVER from 00:0c:29:79:1b:05 via eth0

Aug  6 15:03:35 localhost dhcpd: DHCPOFFER on 10.0.0.168 to 00:0c:29:79:1b:05 via eth0

Aug  6 15:03:35 localhost dhcpd: Dynamic and static leases present for 10.0.0.168.

Aug  6 15:03:35 localhost dhcpd: Remove host declaration generic1 or remove 10.0.0.168

Aug  6 15:03:35 localhost dhcpd: from the dynamic address pool for 10.0.0.0/24

Aug  6 15:03:35 localhost dhcpd: DHCPREQUEST for 10.0.0.168 (10.0.0.11) from 00:0c:29:79:1b:05 via eth0

Aug  6 15:03:35 localhost dhcpd: DHCPACK on 10.0.0.168 to 00:0c:29:79:1b:05 via eth0

Aug  6 15:03:54 localhost dhcpd: Dynamic and static leases present for 10.0.0.168.

Aug  6 15:03:54 localhost dhcpd: Remove host declaration generic1 or remove 10.0.0.168

Aug  6 15:03:54 localhost dhcpd: from the dynamic address pool for 10.0.0.0/24

Aug  6 15:03:54 localhost dhcpd: DHCPREQUEST for 10.0.0.168 from 00:0c:29:79:1b:05 via eth0

Aug  6 15:03:54 localhost dhcpd: DHCPACK on 10.0.0.168 to 00:0c:29:79:1b:05 via eth0

Aug  6 15:15:38 localhost dhcpd: DHCPDISCOVER from 00:50:56:29:65:3c via eth0

Aug  6 15:15:39 localhost dhcpd: DHCPOFFER on 10.0.0.101 to 00:50:56:29:65:3c via eth0

Aug  6 15:15:40 localhost dhcpd: DHCPREQUEST for 10.0.0.101 (10.0.0.11) from 00:50:56:29:65:3c via eth0

Aug  6 15:15:40 localhost dhcpd: DHCPACK on 10.0.0.101 to 00:50:56:29:65:3c via eth0

Aug  6 15:15:40 localhost in.tftpd[15628]: RRQ from 10.0.0.101 filename pxelinux.0

Aug  6 15:15:40 localhost in.tftpd[15628]: Error code 0: TFTP Aborted

Aug  6 15:15:40 localhost in.tftpd[15629]: RRQ from 10.0.0.101 filename pxelinux.0

Aug  6 15:15:40 localhost in.tftpd[15629]: Client 10.0.0.101 finished pxelinux.0

Aug  6 15:15:40 localhost in.tftpd[15630]: RRQ from 10.0.0.101 filename pxelinux.cfg/564d1aef-b2dd-56b0-4d7f-813299791b05

Aug  6 15:15:40 localhost in.tftpd[15630]: Client 10.0.0.101 File not found pxelinux.cfg/564d1aef-b2dd-56b0-4d7f-813299791b05

Aug  6 15:15:40 localhost in.tftpd[15631]: RRQ from 10.0.0.101 filename pxelinux.cfg/01-00-50-56-29-65-3c

Aug  6 15:15:40 localhost in.tftpd[15631]: Client 10.0.0.101 File not found pxelinux.cfg/01-00-50-56-29-65-3c

Aug  6 15:15:40 localhost in.tftpd[15632]: RRQ from 10.0.0.101 filename pxelinux.cfg/0A000065

Aug  6 15:15:40 localhost in.tftpd[15632]: Client 10.0.0.101 File not found pxelinux.cfg/0A000065

Aug  6 15:15:40 localhost in.tftpd[15633]: RRQ from 10.0.0.101 filename pxelinux.cfg/0A00006

Aug  6 15:15:40 localhost in.tftpd[15633]: Client 10.0.0.101 File not found pxelinux.cfg/0A00006

Aug  6 15:15:40 localhost in.tftpd[15634]: RRQ from 10.0.0.101 filename pxelinux.cfg/0A0000

Aug  6 15:15:40 localhost in.tftpd[15634]: Client 10.0.0.101 File not found pxelinux.cfg/0A0000

Aug  6 15:15:40 localhost in.tftpd[15635]: RRQ from 10.0.0.101 filename pxelinux.cfg/0A000

Aug  6 15:15:40 localhost in.tftpd[15635]: Client 10.0.0.101 File not found pxelinux.cfg/0A000

Aug  6 15:15:40 localhost in.tftpd[15636]: RRQ from 10.0.0.101 filename pxelinux.cfg/0A00

Aug  6 15:15:40 localhost in.tftpd[15636]: Client 10.0.0.101 File not found pxelinux.cfg/0A00

Aug  6 15:15:40 localhost in.tftpd[15637]: RRQ from 10.0.0.101 filename pxelinux.cfg/0A0

Aug  6 15:15:40 localhost in.tftpd[15637]: Client 10.0.0.101 File not found pxelinux.cfg/0A0

Aug  6 15:15:40 localhost in.tftpd[15638]: RRQ from 10.0.0.101 filename pxelinux.cfg/0A

Aug  6 15:15:40 localhost in.tftpd[15638]: Client 10.0.0.101 File not found pxelinux.cfg/0A

Aug  6 15:15:40 localhost in.tftpd[15639]: RRQ from 10.0.0.101 filename pxelinux.cfg/0

Aug  6 15:15:40 localhost in.tftpd[15639]: Client 10.0.0.101 File not found pxelinux.cfg/0

Aug  6 15:15:40 localhost in.tftpd[15640]: RRQ from 10.0.0.101 filename pxelinux.cfg/default

Aug  6 15:15:40 localhost in.tftpd[15640]: Client 10.0.0.101 finished pxelinux.cfg/default

Aug  6 15:15:40 localhost in.tftpd[15641]: RRQ from 10.0.0.101 filename menu

Aug  6 15:15:40 localhost in.tftpd[15641]: Client 10.0.0.101 File not found menu

Aug  6 15:15:40 localhost in.tftpd[15642]: RRQ from 10.0.0.101 filename menu.cbt

Aug  6 15:15:40 localhost in.tftpd[15642]: Client 10.0.0.101 File not found menu.cbt

Aug  6 15:15:40 localhost in.tftpd[15643]: RRQ from 10.0.0.101 filename menu.0

Aug  6 15:15:40 localhost in.tftpd[15643]: Client 10.0.0.101 File not found menu.0

Aug  6 15:15:40 localhost in.tftpd[15644]: RRQ from 10.0.0.101 filename menu.com

Aug  6 15:15:40 localhost in.tftpd[15644]: Client 10.0.0.101 File not found menu.com

Aug  6 15:15:40 localhost in.tftpd[15645]: RRQ from 10.0.0.101 filename menu.c32

Aug  6 15:15:40 localhost in.tftpd[15645]: Client 10.0.0.101 finished menu.c32

Aug  6 15:15:40 localhost in.tftpd[15646]: RRQ from 10.0.0.101 filename pxelinux.cfg/default

Aug  6 15:15:40 localhost in.tftpd[15646]: Client 10.0.0.101 finished pxelinux.cfg/default

6.2使用Python+Cobbler实现自动化安装系统(使用在自动化运维平台使用)

[root@node1 ~]# vim cobbler_system_api.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import xmlrpclib
class CobblerAPI(object):
    def __init__(self,url,user,password):
        self.cobbler_user= user
        self.cobbler_pass = password
        self.cobbler_url = url
    def add_system(self,hostname,ip_add,mac_add,profile):
        '''
        Add Cobbler System Infomation
        '''
        ret = {
            "result": API Add Is Successful,
            "comment": [],
        }
        #get token
        remote = xmlrpclib.Server(self.cobbler_url)
        token = remote.login(self.cobbler_user,self.cobbler_pass)
        #add system
        system_id = remote.new_system(token)
        remote.modify_system(system_id,"name",hostname,token)
        remote.modify_system(system_id,"hostname",hostname,token)
        remote.modify_system(system_id,'modify_interface', {
            "macaddress-eth0" : mac_add,
            "ipaddress-eth0" : ip_add,
            "dnsname-eth0" : hostname,
        }, token)
        remote.modify_system(system_id,"profile",profile,token)
        remote.save_system(system_id, token)
        try:
            remote.sync(token)
        except Exception as e:
            ret['result'] = API Add Is Failure
            ret['comment'].append(str(e))
        return ret
def main():
    cobbler = CobblerAPI("http://10.0.0.11/cobbler_api","cobbler","123456")
    ret = cobbler.add_system(hostname='cobbler-api-test',ip_add='10.0.0.169',mac_add='00:50:56:21:89:E0',profile='CentOS-7-x86_64')
    print ret
if __name__ == '__main__':
    main()

执行脚本后
[root@localhost ~]# python cobbler_system_api.py

{'comment': [], 'result': API Add Is Successful }

 

七、附录 ks.cfg文件(供参考)

7.1 CentOS-7-x86_64.cfg

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

[root@ kickstarts]# cat CentOS-7-x86_64.cfg

#Kickstart Configurator for cobbler by CentOS7

#platform=x86, AMD64, or Intel EM64T

#System  language

lang en_US

#System keyboard

keyboard us

#Sytem timezone

timezone Asia/Shanghai

#Root password

rootpw --iscrypted $1$password$7ZK8mMeLGXxbNPeJEFJOU0  #这里设置为123456

#Use text mode install

text

#Install OS instead of upgrade

install

#Use NFS installation Media

url --url="http://10.0.0.11/cobbler/ks_mirror/CentOS-7-x86_64/"

#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

%end

 

7.2 CentOS-6-x86_64.cfg

[root@localhost kickstarts]# cat CentOS-6-x86_64.cfg 

#Kickstart Configurator for cobbler by CentOS6

#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 $1$password$7ZK8mMeLGXxbNPeJEFJOU0

#Use text mode install

text

#Install OS instead of upgrade

install

#Use NFS installation Media

url --url="http://10.0.0.11/cobbler/ks_mirror/CentOS-6-x86_64/"

#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

你可能感兴趣的:(Cobber)