天天看點

cobbler 自動化安裝

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 --inter192.168.10.2" --kickstart=/var/lib/cobbler/kickstarts/sample_end.ks

開啟那台00:50:56:20:27:EE的主機就會自動安裝了

繼續閱讀