cobbler 無人值守安裝
阿新 • • 發佈:2018-10-31
所需服務
PXE服務支援
DHCP服務管理
DNS服務管理(可選bind,dnsmasq)
電源管理
Kickstart服務支援
YUM倉庫管理
TFTP(PXE啟動時需要)
Apache(提供kickstart的安裝源,並提供定製化的kickstart配置)
環境
[[email protected] ~]# cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core)
[[email protected] ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[ [email protected] ~]# getenforce
Disabled
[[email protected] ~]# hostname
cobbler
[[email protected] ~]# hostname -I
10.0.0.206 172.16.1.206
PS:虛擬機器的dhcp關閉
安裝cobbler
yum install -y cobbler cobbler-web dhcp tftp-server pykickstart httpd python-django --下載一些需要的軟體
[[email protected] ~]# cobbler check
cobblerd does not appear to be running/accessible: error(111, 'Connection refused')
這裡報了一個錯,
解決
[[email protected] ~]# systemctl start httpd.service
[[email protected] ~]# systemctl start cobblerd.service
繼續執行cobbler check
[[email protected] ~]# cobbler check httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 251, in check_setup s.ping() 還是報了一個錯,擷取一部分
解決
發現是selinux開啟了,關閉就好
setenforce 0 --臨時關閉
vim /etc/selinux/config
修改 SELINUX=disabled --永久關閉
繼續執行cobbler
[[email protected] ~]# 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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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 wa to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and ya▽oot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
6 : enable and start rsyncd.service with systemctl
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : 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.
一個個解決
1 2 6
vim /etc/cobbler/settings
next_server: 172.16.1.206
default_password_crypted: "$1$oldboy$Npg9Pt9k98Mlg0ZeqHAuN1"
server: 172.16.1.206
將這三項修改一下,按照自己的實際情況,密碼是通過openssl passwd -1 -salt 'oldboy' '123456' 加密得出的密文,明文為“123456”
3
[[email protected] ~]# cobbler get-loaders
[[email protected] ~]# tree /var/lib/cobbler/loaders/
/var/lib/cobbler/loaders/
├── COPYING.elilo
├── COPYING.syslinux
├── COPYING.yaboot
├── elilo-ia64.efi
├── grub-x86_64.efi
├── grub-x86.efi
├── menu.c32
├── pxelinux.0
├── README
└── yaboot
4
[[email protected] ~]# vim /etc/xinetd.d/rsync
disable = no
還有兩個是不用修改的
配置dhcp
修改cobbler的dhcp模板,不要直接修改dhcp服務本身的配置檔案,cobbler會將其覆蓋掉
vim /etc/cobbler/dhcp.template
subnet 172.16.1.0 netmask 255.255.255.0 {
22 option routers 172.16.1.5;
23 option domain-name-servers 172.16.1.1;
24 option subnet-mask 255.255.255.0;
25 range dynamic-bootp 172.16.1.100 172.16.1.254;
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings --用cobbler 管理dhcp
同步cobbler 配置
[[email protected] ~]# cobbler sync
task started: 2018-10-12_110455_sync
task started (id=Sync, time=Fri Oct 12 11:04:55 2018)
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 ***
擷取部分,可以看出他幹了什麼
[[email protected] ~]# cat /etc/dhcp/dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Fri Oct 12 03:04:56 2018)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
dhcp服務已接管
重啟相關服務& 設定開機自啟
[[email protected] ~]# systemctl restart cobblerd.service rsyncd tftp.socket httpd.service
[[email protected] ~]# systemctl enable cobblerd.service rsyncd tftp.socket httpd.service
cobbler命令相關
[[email protected] ~]# cobbler
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...
[add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]
[[email protected] ~]# cobbler import --help # 匯入映象
Usage: cobbler [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 檢視配置資訊
接下來就是web介面了
登陸
賬號密碼都為:cobbler
配置
配置內容
# Cobbler for Kickstart Configurator for CentOS 7 by yao zhang
install
url --url=$tree
text
lang en_US.UTF-8
keyboard us
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
#Network information
$SNIPPET('network_config')
#network --bootproto=dhcp --device=eth0 --onboot=yes --noipv6 --hostname=CentOS7
timezone --utc Asia/Shanghai
authconfig --enableshadow --passalgo=sha512
rootpw --iscrypted $default_password_crypted
clearpart --all --initlabel
part /boot --fstype xfs --size 1024
part swap --size 1024
part / --fstype xfs --size 1 --grow
firstboot --disable
selinux --disabled
firewall --disabled
logging --level=info
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@^minimal
@compat-libraries
@core
@debugging
@development
bash-completion
chrony
dos2unix
kexec-tools
lrzsz
nmap
sysstat
telnet
tree
vim
wget
%end
%post
systemctl disable postfix.service
%end
截圖來自何導,自己沒截。。。內容根據自己實際修改即可
完成之後開啟虛擬機器,等待一段時間即可。時間長短看自己電腦配置了