cobbler 批量自动化安装

 

-- httpd dhcp tftp cobbler cobbler-web pykickstart 安装

Centos7镜像阿里云网址:http://mirrors.aliyun.com/epel/

 

[[email protected] ~]# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm

[[email protected] ~]# yum -y install httpd dhcp tftp cobbler cobbler-web pykickstart  xinetd

[[email protected] ~]# systemctl start cobblerd.service xinetd.service httpd.service

[[email protected] ~]# systemctl enable cobblerd.service xinetd.service httpd.service

[[email protected] conf.d]# cobbler check

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

 

1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.

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

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

5 : enable and start rsyncd.service with systemctl

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

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.

--cobbler 主要目录和配置文件

/var/www/cobbler/ks_mirror   系统镜像存放位置

/var/www/cobbler/repo_mirror 安装包自定义仓库存放位置

/var/lib/cobbler  默认kickstart文件、启动相关文件、配置脚本等

/etc/cobbler 常用配置文件

--cobbler 修改配置

--1

[[email protected] ~]# vim /etc/cobbler/settings

next_server: 192.168.10.10

server: 192.168.10.10

 

 

--2

[[email protected] ~]# vim /etc/xinetd.d/tftp   //修改    disable         = yes (把disable 改成no)

no          = yes

 

--3

[[email protected] ~]# systemctl start  rsyncd

[[email protected] ~]# systemctl enable rsyncd

[[email protected] ~]# cobbler get-loaders

 

--4

[[email protected] ~]# openssl passwd -1 -salt 'cobler' 'cobler'

$1$cobler$XJnisBweZJlhL651HxAM00

[[email protected] ~]# vim /etc/cobbler/settings

default_password_crypted: "$1$cobler$XJnisBweZJlhL651HxAM00."

[[email protected] ~]# systemctl restart cobblerd.service

 

[[email protected] ~]# cobbler check

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

 

1 : enable and start rsyncd.service with systemctl

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

 

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

 

--cobbler dhcp设置

[[email protected] ~]# vim /etc/cobbler/settings

manage_dhcp: 1

[[email protected] ~]# vim /etc/cobbler/dhcp.template

subnet 192.168.10.0 netmask 255.255.255.0 {

     option routers             192.168.10.2;

     option domain-name-servers 192.168.10.2;

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        192.168.10.100 192.168.10.254;

[[email protected] ~]# systemctl restart cobblerd.service

[[email protected] ~]# cobbler sync

 

--cobbler 导入镜像、编辑镜像配置

[[email protected] ~]# mount /dev/cdrom /mnt

[[email protected] ~]# cobbler import --path=/mnt/ --name=Centos7.6 --arch=x86_64

[[email protected] ~]# ls /var/www/cobbler/ks_mirror/

Centos7.6-x86_64  config

[[email protected] ~]# cobbler profile        //显示常用命令

[[email protected] ~]# cobbler profile list     //显示已导入的系统

   Centos7.6-x86_64

[[email protected] ~]# cobbler profile report   //显示cobbler相关配置

[[email protected]~]# cobbler profile edit --name=Centos7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg  //修改kiskstart文件指向自定义文件

[[email protected] kickstarts]# cobbler profile edit --name=Centos7.6-x86_64 --kopts='net.ifnames=0 biosdevname=0'

[[email protected] kickstarts]# cobbler sync

[[email protected] ~]# systemctl restart xinetd.service

 

--kickstarts 文件

#Kickstart Configurator for cobbler by by L.cf

#platform=x86, AMD64, or Intel

#System language

lang en_US

#System keyboard

keyboard us

#System timezone

timezone Asia/Shanghai

#Root password

rootpw --iscrypted $default_password_crypted

#Use text mode install

text

#Install OS instead of upgrade

install

#Use NFS installation Media

url --url=$tree

#System bootloader configuration

bootloader --location=mbr

#Clear the Master Boot Record

zerombr

#Partition clearing informtion

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=eml --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

openssl-devel

zlib-devel

tree

nmap

bash-completion

%end

 

%post

systemctl disable postfix.service

%end

 

 

 

--cobbler 安装

[[email protected] kickstarts]# tail -f /var/log/messages

 

--cobbler 重装系统

//的要重装的主机上执行下面命令

[[email protected] tmp]# yum -y install koan-2.8.5-0.1.el7.noarch.rpm

[[email protected] tmp]# koan --server=192.168.10.10 --list=profiles

- looking for Cobbler at http://192.168.10.10:80/cobbler_api

Centos7.6-x86_64

[[email protected] tmp]# koan --replace-self --server=192.168.10.10 --profile=Centos7.6-x86_64

 

建议:装机请设置专有的装机vlan网段,防止影响其它网段环境

 

--cobbler web管理介面

访问网址:https://192.168.10.10/cobbler_web

默认账号密码都是:cobbler

cobbler 自动化安装

 

修改密码方法如下:

登陆账号信息主要在

[[email protected] cobbler]# cat users.conf     //用户配置信息

[[email protected] cobbler]# cat users.digest     //登陆密码

[[email protected] cobbler]# htdigest /etc/cobbler/users.digest "cobbler" cobbler   //修改用户密码

Adding user cobbler in realm cobbler

New password:

Re-type new password:

 

--cobbler 自动安装提示界面修改

[[email protected] cobbler]#cat /etc/cobbler/pxe/pxedefault.template      //根据需求自定义修改

DEFAULT menu

PROMPT 0

MENU TITLE Cobbler | http://cobbler.github.io/

TIMEOUT 200

TOTALTIMEOUT 6000

ONTIMEOUT $pxe_timeout_profile

 

LABEL local

        MENU LABEL (local)

        MENU DEFAULT

        LOCALBOOT -1

 

$pxe_menu_items

 

MENU end

 

--cobbler yum 私有仓库

--从阿里云网上下载安装包

[[email protected] ~]# cobbler repo add --name=openstack-kolla --mirror=https://mirrors.aliyun.com/centos/7/cloud/x86_64/openstack-rocky/ --arch=x86_64 --breed=yum

[[email protected] ~]# cobbler reposync      //执行更新下载包

--系统安装时添加自定义yum源

[[email protected] ~]# cobbler profile edit --name=Centos7.6-x86_64 --repos=openstack-kolla

[[email protected] ~]# vim /etc/cobbler/settings (默认是1开启)

...

yum_post_install_mirror: 1

...

修改Kickstarts 文件要添加下面语句(或在已有的%post下添加$yum_config_stanza语句)

%post

$yum_config_stanza

%end

 

--cobbler 自动安装

  1. 首先规划好要上线的主机的相关信息

如profile安装哪个操作系统、分区等、预分配的ip地址、主机名、子网、网关、dns、角色等

  1. 例如:

主机名:linux-node1.ald8.com

MA地址:00:50:56:20:27:EE

Ip:192.168.10.160

Mask:255.255.255.0

Gateway:192.168.10.2

DNS:192.168.10.2

  1. 设置安装

[[email protected] ~]# cobbler system add --name=linux.node1.ald8.com --mac=00:50:56:20:27:EE --profile=Centos7.6-xCentos7.6-x86_64 --ip-address=192.168.10.60 --subnet=255.255.255.0 --gateway=192.168.10.2 --interface=eth0 --static=1 --hostname=linux.node1.ald8.com --name-servers="192.168.10.2" --kickstart=/var/lib/cobbler/kickstarts/sample_end.ks

开启那台00:50:56:20:27:EE的主机就会自动安装了

 

 

 

相关文章: