cobbler部署

cobbler部署

配置yum源

[root@linfan ~]# cd /etc/yum.repos.d/
[root@linfan yum.repos.d]# ls
CentOS-Base.repo.gz  CentOS-Debuginfo.repo.gz  CentOS-Media.repo.gz    CentOS-Vault.repo.gz
CentOS-CR.repo.gz    CentOS-fasttrack.repo.gz  CentOS-Sources.repo.gz  lin.repo
[root@linfan yum.repos.d]# curl -o 163.repo   http://mirrors.163.com/.help/CentOS7-Base-163.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1572  100  1572    0     0   3917      0 --:--:-- --:--:-- --:--:--  3930
[root@linfan yum.repos.d]# ls
163.repo             CentOS-CR.repo.gz         CentOS-fasttrack.repo.gz  CentOS-Sources.repo.gz  lin.repo
CentOS-Base.repo.gz  CentOS-Debuginfo.repo.gz  CentOS-Media.repo.gz      CentOS-Vault.repo.gz
[root@linfan yum.repos.d]# sed -i 's/\$releasever/7/g' 163.repo
[root@linfan yum.repos.d]# sed -i 's/^enabled=.*/enabled=1/g' 163.repo
[root@linfan yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base centosplus extras lin updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@linfan yum.repos.d]# yum -y install epel-release 

安裝cobbler以及相關軟件

[root@linfan ~]#  yum -y install httpd dhcp tftp python-ctypes cobbler xinetd cobbler-web pykickstart

啓動服務並設置開機自啓動

[root@linfan ~]#  systemctl start httpd
[root@linfan ~]# systemctl start cobblerd
[root@linfan ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@linfan ~]# systemctl enable cobblerd
Created symlink from /etc/systemd/system/multi-user.target.wants/cobblerd.service to /usr/lib/systemd/system/cobblerd.service.

修改server的ip爲本機ip

[root@linfan ~]# sed -i 's/^server: 127.0.0.1/server: 192.168.24.168/' /etc/cobbler/settings  

設置tftp的ip地址爲本機ip

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

開啓tfp

[root@linfan ~]# sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp

下載缺失文件


[root@linfan ~]# cobbler get-loaders
task started: 2018-08-29_105820_get_loaders
task started (id=Download Bootloader Content, time=Wed Aug 29 10:58:20 2018)
downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***

啓動rysnc並設置開啓自啓動

root@linfan ~]# systemctl start rsyncd
[root@linfan ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

生成加密的密碼

[root@linfan ~]# openssl passwd -1 -salt "$RANDOM" 'linfan123'
$1$22895$x1tfkN/VsYusTzt449H.L. 

將新生成的加密密碼加入配置文件

[root@linfan ~]# sed -i 's/default_password_crypted/#default_password_crypted/g' /etc/cobbler/settings
[root@linfan ~]# echo "default_password_crypted:  "$1$22895$x1tfkN/VsYusTzt449H.L."" >> /etc/cobbler/settings    

重啓cobbler

[root@linfan ~]# systemctl restart cobblerd
[root@linfan ~]#  ss -antl
State      Recv-Q Send-Q                Local Address:Port                               Peer Address:Port
LISTEN     0      128                               *:22                                            *:*
LISTEN     0      100                       127.0.0.1:25                                            *:*
LISTEN     0      5                         127.0.0.1:25151                                         *:*
LISTEN     0      5                                 *:873                                           *:*
LISTEN     0      128                              :::80                                           :::*
LISTEN     0      128                              :::22                                           :::*
LISTEN     0      100                             ::1:25                                           :::*
LISTEN     0      128                              :::443                                          :::*
LISTEN     0      5                                :::873                                          :::*   

通過cobbler check 覈對當前設置

[root@linfan ~]# 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.

以上兩個是關於debian系統的錯誤,請忽略

配置cobbler dhcp

修改cobbler配置文件,讓cobbler控制dhcp

[root@linfan ~]#  sed -i '/^manage_dhcp/s/
0/1/g' /etc/cobbler/settings
[root@linfan ~]# sed -n '/^manage_dhcp/p' /etc/cobbler/settings
manage_dhcp: 1

配置dhcp

[root@linfan ~]#sed -i 's/subnet 192.168.1.0/subnet 192.168.24.0/g'  /etc/cobbler/dhcp.template
[root@linfan ~]# sed -i 's/option routers             192.168.1.5;/option routers             192.168.24.168;/g' /etc/cobbler/dhcp.template
[root@linfan ~]# sed -i 's/option domain-name-servers 192.168.1.1;/option domain-name-servers 192.168.24.168;/g' /etc/cobbler/dhcp.template

[root@linfan ~]#  sed -i 's/range dynamic-bootp        192.168.1.100 192.168.1.254;/range dynamic-bootp        192.168.24.100 192.168.24.150;/g' /etc/cobbler/dhcp.template     

重啓服務並同步配置,改完dhcp必須要先sync同步配置

[root@linfan ~]# systemctl restart cobblerd
[root@linfan ~]# cobbler sync
task started: 2018-08-29_120850_sync
task started (id=Sync, time=Wed Aug 29 12:08:50 2018)
running pre-sync triggers
cleaning trees
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/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 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.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

檢查dhcp是否正常

[root@linfan ~]#  netstat -anulp|grep dhcp
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1709/dhcpd  

導入centos7鏡像

[root@linfan ~]# mount /dev/cdrom /mnt
[root@linfan ~]# cobbler import --path=/mnt --name=centos7 --arch=x86_64
task started: 2018-08-29_123313_import
task started (id=Media import, time=Wed Aug 29 12:33:13 2018)
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/centos7-x86_64:
creating new distro: centos7-x86_64
trying symlink: /var/www/cobbler/ks_mirror/centos7-x86_64 -> /var/www/cobbler/links/centos7-x86_64
creating new profile: centos7-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/centos7-x86_64 for centos7-x86_64
processing repo at : /var/www/cobbler/ks_mirror/centos7-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/centos7-x86_64
looking for /var/www/cobbler/ks_mirror/centos7-x86_64/repodata/*comps*.xml
Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7-x86_64/repodata
*** TASK COMPLETE ***

//說明

--path //鏡像路徑
--name //爲安裝源定義一個名字
--arch //指定安裝源平臺

//安裝源的唯一標識就是根據name參數來定義

查看cobbler鏡像列表

 [root@linfan ~]# cobbler list
distros:
   centos7-x86_64

profiles:
   centos7-x86_64

systems:

repos:

images:

mgmtclasses:

packages:

files:

創建kickstarts自動安裝腳本

[root@linfan ~]# cat > /var/lib/cobbler/kickstarts/centos7-x86_64.ks <<'EOF'
> auth --enableshadow --passalgo=sha512
> bootloader --location=mbr
> clearpart --all --initlabel
> part /boot --asprimary --fstype="ext4" --size=500
> part swap --fstype="swap" --size=4096
> part / --fstype="ext4" --grow --size=14000
> text
> firewall --disabled
> firstboot --disable
> keyboard us
> lang en_US
> url --url=http://192.168.24.168/cobbler/ks_mirror/centos7-x86_64
> $yum_repo_stanza
> $SNIPPET('network_config')
> reboot
>  rootpw --iscrypted $6$noLJ6S9MCXH6zxix$vUora.pqzXplCt/bKqiqSDtxH0E1.hfJ4BxRkLmkfgtb7HlPb3kYehTtS6/GutiCWNC4P2uU2Wm/Ra7W3uxjK.
> selinux --disabled
> skipx
> timezone Asia/Shanghai --isUtc --nontp
> install
> zerombr
> %packages
> @^minimal
> @core
> kexec-tools
> %end
> %addon com_redhat_kdump --enable --reserve-mb='auto'
> %end
> %anaconda
> pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
> pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
> pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
> %end
> EOF

檢查ks文件語法是否有誤

[root@linfan ~]# cobbler validateks
task started: 2018-08-29_124757_validateks
task started (id=Kickstart Validation, time=Wed Aug 29 12:47:57 2018)
----------------------------
osversion: rhel7
checking url: http://192.168.24.168/cblr/svc/op/ks/profile/centos7-x86_64
running: /usr/bin/ksvalidator -v "rhel7" "http://192.168.24.168/cblr/svc/op/ks/profile/centos7-x86_64"
received on stdout:
received on stderr:
*** all kickstarts seem to be ok ***
*** TASK COMPLETE ***

查看當前cobbler有哪些配置文件

[root@linfan ~]# cobbler profile list
   centos7-x86_64

修改profile,將我們新建的ks文件設置爲默認的kickstarts安裝文件

[root@linfan ~]# cobbler profile edit --name centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-x86_64.ks 

配置網卡名稱爲傳統網卡名稱eth0

[root@linfan ~]# cobbler profile edit --name centos7-x86_64 --kopts='net.ifnames=0 biosdevname=0'   

檢查當前系統cobbler配置文件信息

[root@linfan ~]# cobbler profile report
Name                           : centos7-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : centos7-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/centos7-x86_64.ks
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : ['admin']
Parent Profile                 :
Internal proxy                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
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@linfan ~]#  cobbler sync
task started: 2018-08-29_125708_sync
task started (id=Sync, time=Wed Aug 29 12:57:08 2018)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/centos7-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/centos7-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: centos7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/centos7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/centos7-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: centos7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/centos7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/centos7-x86_64/initrd.img
Writing template files for centos7-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: centos7-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.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

爲避免發生未知問題,先把服務端所有服務重啓

[root@linfan ~]# systemctl restart xinetd
[root@linfan ~]# systemctl restart cobblerd
[root@linfan ~]# systemctl restart httpd
[root@linfan ~]# ss -antl
State      Recv-Q Send-Q                Local Address:Port                               Peer Address:Port
LISTEN     0      128                               *:22                                            *:*
LISTEN     0      100                       127.0.0.1:25                                            *:*
LISTEN     0      5                         127.0.0.1:25151                                         *:*
LISTEN     0      5                                 *:873                                           *:*
LISTEN     0      128                              :::80                                           :::*
LISTEN     0      128                              :::22                                           :::*
LISTEN     0      100                             ::1:25                                           :::*
LISTEN     0      128                              :::443                                          :::*
LISTEN     0      5                                :::873                                          :::*     
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章