update
This commit is contained in:
+166
-7
@@ -1,15 +1,35 @@
|
||||
|
||||
|
||||
# 树莓派 配置 cobbler
|
||||
|
||||
[TOC]
|
||||
|
||||
## 安装
|
||||
|
||||
```bash
|
||||
# 源码安装
|
||||
sudo apt install git make python-dev python-setuptools python-cheetah openssl
|
||||
sudo apt install createrepo apache2 python-cheetah python-netaddr python-simplejson python-urlgrabber python-yaml rsync yum-utils libapache2-mod-wsgi xinetd tftpd tftp python-django
|
||||
sudo a2enmod proxy
|
||||
sudo a2enmod proxy_http
|
||||
sudo a2enmod rewrite
|
||||
sudo a2ensite cobbler.conf
|
||||
|
||||
sudo apt install make git python3-yaml python3-cheetah python3-netaddr python3-simplejson python3-future python3-distro python3-setuptools python3-sphinx python3-coverage pyflakes3 python3-pycodestyle python3-django
|
||||
|
||||
|
||||
|
||||
|
||||
git clone https://github.com/cobbler/cobbler.git
|
||||
cd cobbler
|
||||
git checkout release28
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
本来Google的方案需要从源码安装,但是尝试了下apt, 发现有现成的包,~~所以简单太多了~~ 版本太老,有额外的问题要处理.
|
||||
|
||||
```bash
|
||||
sudo apt install cobbler cobbler-web
|
||||
sudo apt install cobbler cobbler-web xinetd
|
||||
# 安装过程中会让输密码
|
||||
# 该包是2.6.6版本 有点老,现在来说有好几个bug
|
||||
# cobbler-web 有bug, 不兼容新的
|
||||
@@ -76,6 +96,10 @@ subnet 192.168.1.0 netmask 255.255.255.0 {
|
||||
max-lease-time 43200;
|
||||
next-server $next_server;
|
||||
}
|
||||
|
||||
# 树莓派版本用的dnsmasq,所以改这个
|
||||
# 配置DHCP /etc/cobbler/dnsmasq.template
|
||||
|
||||
```
|
||||
|
||||
cobbler 会将 镜像存储到 /var/lib/cobbler/www/cobbler/ks_mirror/下, 注意容量和权限
|
||||
@@ -112,7 +136,7 @@ sudo cobbler sync
|
||||
```bash
|
||||
# http://mirrors.aliyun.com/centos 下载镜像, 下载minimal版方便测试
|
||||
sudo mkdir /mnt/centos_mini
|
||||
sudo mount -t iso9660 -o loop,ro ~/CentOS-8.2.2004-x86_64-dvd1.iso /mnt
|
||||
sudo mount -t iso9660 -o loop,ro ~/CentOS-8.2.2004-x86_64-dvd1.iso /mnt/centos_mini
|
||||
sudo cobbler import --name=centos8-mini --arch=x86_64 --path=/mnt/centos_mini
|
||||
|
||||
# 出现这个问题
|
||||
@@ -122,7 +146,8 @@ No signature matched in /var/lib/cobbler/www/cobbler/ks_mirror/centos8-x86_64
|
||||
!!! TASK FAILED !!!
|
||||
# 使用该指令之后再导入一次
|
||||
sudo cobbler signature update
|
||||
sudo cobbler import --name=centos8 --arch=x86_64 --path=/mnt
|
||||
sudo cobbler import --name=centos8-mini --arch=x86_64 --path=/mnt/centos_mini
|
||||
|
||||
|
||||
# 出现这个问题
|
||||
Exception occured: <type 'exceptions.KeyError'>
|
||||
@@ -320,7 +345,9 @@ timezone Asia/ShangHai
|
||||
|
||||
|
||||
# System authorization information
|
||||
auth --useshadow --enablemd5
|
||||
# centos8 已经将authconfig 更新为authselect
|
||||
# auth --useshadow --enablemd5
|
||||
authselect --enableshadow --passlgo=sha512
|
||||
#Root password
|
||||
rootpw --iscrypted $default_password_crypted
|
||||
|
||||
@@ -358,6 +385,9 @@ autopart
|
||||
|
||||
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
|
||||
$yum_repo_stanza
|
||||
# add repo manually
|
||||
# repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
|
||||
|
||||
# Network information
|
||||
$SNIPPET('network_config')
|
||||
# Do not configure the X Window System
|
||||
@@ -373,6 +403,7 @@ $SNIPPET('kickstart_start')
|
||||
$SNIPPET('pre_install_network_config')
|
||||
# Enable installation monitoring
|
||||
$SNIPPET('pre_anamon')
|
||||
%end
|
||||
|
||||
%packages
|
||||
$SNIPPET('func_install_if_enabled')
|
||||
@@ -395,7 +426,7 @@ $SNIPPET('log_ks_post')
|
||||
# Start yum configuration
|
||||
$yum_config_stanza
|
||||
# End yum configuration
|
||||
$SNIPPET('post_install_kernel_options')
|
||||
$('post_install_kernel_options')
|
||||
$SNIPPET('post_install_network_config')
|
||||
$SNIPPET('func_register_if_enabled')
|
||||
$SNIPPET('puppet_register_if_enabled')
|
||||
@@ -408,12 +439,136 @@ $SNIPPET('post_anamon')
|
||||
# Start final steps
|
||||
$SNIPPET('kickstart_done')
|
||||
# End final steps
|
||||
%end
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 验证
|
||||
|
||||
- failed to load ldlinux.c32
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
sudo cp /usr/lib/syslinux/ldlinux.c32 /var/lib/cobbler/tftp/
|
||||
```
|
||||
|
||||
- Failed to load libutil.c32 failed to load COM32 file menu.c32
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
sudo cp /usr/lib/syslinux/libutil.c32 /var/lib/cobbler/tftp/
|
||||
sudo cp /usr/lib/syslinux/menu.c32 /var/lib/cobbler/tftp/
|
||||
```
|
||||
|
||||
- 暂时成功
|
||||
|
||||

|
||||
|
||||
- failed to fetch kickstart from http://.../cblr/svc/op/ks/profile/cobbler-centos8-mini-x86_x64
|
||||
|
||||
dracut-initqueue[944]: Warning: dracut-initqueue timeout
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
# 又是版本不对应的锅
|
||||
# apache2 升级到2.4之后之前的的配置不能通过授权
|
||||
sudo vim /etc/apache2/apache2.conf
|
||||
|
||||
<Directory />
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
#Require all denied
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
# 查看日志有错误
|
||||
Tue Jul 14 08:18:54 2020 - INFO | Exception occured: <class 'cobbler.cexceptions.CX'>
|
||||
Tue Jul 14 08:18:54 2020 - INFO | Exception value: 'Error templating file, check cobbler.log for more details'
|
||||
Tue Jul 14 08:18:54 2020 - INFO | Exception Info:
|
||||
File "/usr/lib/python2.7/dist-packages/cobbler/remote.py", line 1062, in generate_kickstart
|
||||
return self.api.generate_kickstart(profile,system)
|
||||
File "/usr/lib/python2.7/dist-packages/cobbler/api.py", line 696, in generate_kickstart
|
||||
return self.kickgen.generate_kickstart_for_profile(profile)
|
||||
File "/usr/lib/python2.7/dist-packages/cobbler/kickgen.py", line 312, in generate_kickstart_for_profile
|
||||
return self.generate_kickstart(profile=g)
|
||||
File "/usr/lib/python2.7/dist-packages/cobbler/kickgen.py", line 290, in generate_kickstart
|
||||
data = self.templar.render(raw_data, meta, None, obj)
|
||||
File "/usr/lib/python2.7/dist-packages/cobbler/templar.py", line 116, in render
|
||||
data_out = self.render_cheetah(raw_data, search_table, subject)
|
||||
File "/usr/lib/python2.7/dist-packages/cobbler/templar.py", line 215, in render_cheetah
|
||||
raise CX("Error templating file, check cobbler.log for more details")
|
||||
|
||||
# 修改该文件37行
|
||||
sudo vim /usr/lib/python2.7/dist-packages/cobbler/templar.py
|
||||
# 改为: fix_cheetah_class = (int(major), int(minor), int(release)) >= (2, 4, 2)
|
||||
```
|
||||
|
||||
- 系统安装中出现一些异常
|
||||
|
||||
pykickstart.errors.KickstartError: /usr/sbin/authconfig is missing
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
# 该问题是centos 8 没有authconfig指令了,更新为了 authselect
|
||||
# 更改ks文件,将auth 行 换成authselect
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- missing packages: 配置本地源即可解决
|
||||
-
|
||||
|
||||

|
||||
|
||||
- sbin/dmsquash-live-root: line 273: write error: No space left on device
|
||||
|
||||
确保虚拟机有至少2g内存
|
||||
|
||||
- pyanaconda.payload.PayloadError: Payload error - DNF installation has ended up abruptly: No available modular metadata for modular package Traceback
|
||||
|
||||
Dnf.exceptions.Error: No available modular metadata for modular package
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 配置 centos8 本地源
|
||||
|
||||
```bash
|
||||
sudo apt install yum-utils
|
||||
# 添加
|
||||
|
||||
sudo cobbler repo add --name=Centos8-BaseOS --mirror=http://mirrors.aliyun.com/centos/8.2.2004/BaseOS/x86_64/os/ --arch=x86_64 --breed=yum
|
||||
sudo cobbler repo add --name=Centos8-AppStream --mirror=http://mirrors.aliyun.com/centos/8.2.2004/AppStream/x86_64/os/ --arch=x86_64 --breed=yum
|
||||
|
||||
sudo cobbler repo add --name=Centos8-extras --mirror=http://mirrors.aliyun.com/centos/8.2.2004/extras/x86_64/os/ --arch=x86_64 --breed=yum
|
||||
sudo cobbler repo add --name=Centos8-Epel --mirror=http://mirrors.aliyun.com/epel/8/Everything/x86_64/ --arch=x86_64 --breed=yum
|
||||
|
||||
sudo cobbler repo add --name=Centos8-Openstack-ussuri --mirror=http://mirrors.aliyun.com/centos/8.2.2004/cloud/x86_64/openstack-ussuri/ --arch=x86_64 --breed=yum
|
||||
|
||||
# 查看
|
||||
sudo cobbler repo list
|
||||
|
||||
# 同步
|
||||
# 需要 sudo apt install yum-utils, 安装完后重启cobbler
|
||||
# 存储在 /var/lib/cobbler/www/cobbler/repo_mirror/
|
||||
sudo cobbler reposync
|
||||
sudo cobbler profile edit --name=cobbler-centos8-mini-x86_64 --repos='Centos8-BaseOS Centos8-AppStream Centos8-extras Centos8-Epel Centos8-Openstack-ussuri'
|
||||
# 或者手动在ks文件里添加
|
||||
# repo --name="BaseOS" --baseurl=http://192.168.10.50/cblr/repo_mirror/Centos8-BaseOS/
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -424,6 +579,10 @@ $SNIPPET('kickstart_done')
|
||||
[2]: https://cobbler.readthedocs.io/en/latest/
|
||||
[3]: https://bashtheshell.com/guide/setting-up-pxe-boot-server-on-raspberry-pi/
|
||||
[4]: http://wiki.inford.net/使用树莓派3构建PXE服务器自动安装操作系统
|
||||
[5]: https://blog.51cto.com/dyc2005/2130240
|
||||
[6]: https://www.golinuxcloud.com/rhel-centos-8-kickstart-example-generator/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# golang raspberrr
|
||||
|
||||
|
||||
|
||||
## install
|
||||
|
||||
```bash
|
||||
wget https://docs.studygolang.com/src/bootstrap.bash?m=text -O bootstrap.bash
|
||||
chmod u+x bootstrap.bash
|
||||
|
||||
wget https://studygolang.com/dl/golang/go1.15.2.linux-armv6l.tar.gz -O go.tar.gz
|
||||
sudo tar -C /usr/local -xzf go.tar.gz
|
||||
|
||||
PATH=$PATH:/usr/local/go/bin
|
||||
GOPATH=$HOME/go
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
# 树莓派部署 kickstart 服务器
|
||||
|
||||
[TOC]
|
||||
|
||||
|
||||
|
||||
## dhcp
|
||||
|
||||
```bash
|
||||
sudo apt install isc-dhcp-server
|
||||
|
||||
cat > /etc/dhcp/dhcpd.conf <<EOF
|
||||
ddns-update-style interim;
|
||||
allow booting;
|
||||
allow bootp;
|
||||
ignore client-updates;
|
||||
set vendorclass = option vendor-class-identifier;
|
||||
option pxe-system-type code 93 = unsigned integer 16;
|
||||
subnet 192.168.10.0 netmask 255.255.255.0 {
|
||||
#option routers 192.168.10.1;
|
||||
option domain-name-servers 223.5.5.5;
|
||||
option subnet-mask 255.255.255.0;
|
||||
range dynamic-bootp 192.168.10.100 192.168.10.254;
|
||||
filename "/pxelinux.0";
|
||||
default-lease-time 21600;
|
||||
max-lease-time 43200;
|
||||
next-server 192.168.10.50;
|
||||
class "pxeclients" {
|
||||
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
|
||||
if option pxe-system-type = 00:02 {
|
||||
filename "ia64/elilo.efi";
|
||||
} else if option pxe-system-type = 00:06 {
|
||||
filename "grub/grub-x86.efi";
|
||||
} else if option pxe-system-type = 00:07 {
|
||||
filename "grub/grub-x86_64.efi";
|
||||
} else if option pxe-system-type = 00:09 {
|
||||
filename "grub/grub-x86_64.efi";
|
||||
} else {
|
||||
filename "pxelinux.0";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
# group for Cobbler DHCP tag: default
|
||||
group {
|
||||
}
|
||||
EOF
|
||||
|
||||
sudo /etc/init.d/isc-dhcp-server start
|
||||
```
|
||||
|
||||
|
||||
|
||||
## tftp
|
||||
|
||||
```bash
|
||||
sudo apt install xinetd tftpd tftp
|
||||
sudo touch /etc/xinetd.d/tftp
|
||||
|
||||
cat > /etc/xinetd.d/tftp <<EOF
|
||||
service tftp
|
||||
{
|
||||
disable = no
|
||||
socket_type = dgram
|
||||
protocol = udp
|
||||
wait = yes
|
||||
user = root
|
||||
server = /usr/sbin/in.tftpd
|
||||
server_args = -B 1380 -v -s /var/lib/tftpboot
|
||||
per_source = 11
|
||||
cps = 100 2
|
||||
flags = IPv4
|
||||
}
|
||||
EOF
|
||||
|
||||
sudo mkdir /var/lib/tftpboot
|
||||
# 授予所有读写权限
|
||||
sudo chmod -R 777 /var/lib/tftpboot
|
||||
sudo chown -R nobody /var/lib/tftpboot
|
||||
sudo /etc/init.d/xinetd restart
|
||||
```
|
||||
|
||||
|
||||
|
||||
## httpd
|
||||
|
||||
```bash
|
||||
sudo apt install apache2
|
||||
cd /var/www/html
|
||||
rm index.html
|
||||
sudo sed -i 's/\/var\/www\/html/\/var\/www/' /etc/apache2/sites-enabled/000-default.conf
|
||||
sudo service apache2 restart
|
||||
sudo chmod -R 777 /var/www
|
||||
sudo mkdir /var/www/kickstart
|
||||
sudo mkdir /var/www/images
|
||||
sudo mkdir /var/www/images/centos7
|
||||
sudo mkdir /var/www/repo
|
||||
```
|
||||
|
||||
## 引导
|
||||
|
||||
```bash
|
||||
|
||||
wget http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/Packages/syslinux-4.05-15.el7.x86_64.rpm -O /tmp/syslinux.rpm
|
||||
sudo apt install rpm2cpio
|
||||
sudo rpm2cpio /tmp/syslinux.rpm | cpio -idmv
|
||||
|
||||
cp /tmp/usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
|
||||
|
||||
mkdir /var/lib/tftpboot/pxelinux.cfg
|
||||
cat > /var/lib/tftpboot/pxelinux.cfg/default << EOF
|
||||
DEFAULT menu
|
||||
PROMPT 0
|
||||
MENU TITLE PrideCloud
|
||||
TIMEOUT 200
|
||||
TOTALTIMEOUT 6000
|
||||
ONTIMEOUT local
|
||||
|
||||
LABEL local
|
||||
MENU LABEL (local)
|
||||
MENU DEFAULT
|
||||
LOCALBOOT -1
|
||||
|
||||
LABEL centos7-x86_64
|
||||
kernel /images/centos7-x86_64/vmlinuz
|
||||
MENU LABEL centos7-x86_64
|
||||
append initrd=/images/centos7-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.10.50/kickstart/centos7.ks
|
||||
ipappend 2
|
||||
|
||||
MENU end
|
||||
EOF
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 挂载镜像
|
||||
|
||||
```bash
|
||||
sudo mount -t iso9660 -o loop,ro ~/CentOS-7-x86_64-Minimal-2003.iso /var/www/images/centos7
|
||||
# 编辑kickstart 文件
|
||||
sudo vim /var/www/kickstart/centos7.ks
|
||||
```
|
||||
|
||||
```bash
|
||||
# /var/www/kickstart/centos7.ks
|
||||
# platform =x86, AMD64, or Intel EM64T
|
||||
# os=centos7
|
||||
# Install OS instead of upgrade
|
||||
install
|
||||
# Use text mode install
|
||||
text
|
||||
# System keyboard
|
||||
keyboard us
|
||||
# System language
|
||||
lang en_US
|
||||
# System timezone
|
||||
timezone Asia/ShangHai
|
||||
# System authorization information
|
||||
auth --useshadow --enablemd5
|
||||
rootpw --iscrypted $1$XiTkwMpL$Y9cGAcWZC2koVK68De7LZ.
|
||||
# Firewall configuration
|
||||
firewall --disabled
|
||||
# SELinux configuration
|
||||
selinux --disabled
|
||||
|
||||
|
||||
# Use network installation
|
||||
url --url=http://192.168.10.50/images/centos7
|
||||
|
||||
|
||||
# Clear the Master Boot Record
|
||||
zerombr
|
||||
# System bootloader configuration
|
||||
# bootloader --location=mbr
|
||||
# interface can be named as eth*
|
||||
bootloader --location=mbr --append="net.ifnames=0 biosdevname=0 rhgb quiet"
|
||||
|
||||
# Partition clearing information
|
||||
clearpart --all --initlabel
|
||||
# Allow anaconda to partition the system as needed
|
||||
autopart
|
||||
# or
|
||||
# # create 1MB biosboot type partition, centos7 and centos8 .
|
||||
# part biosboot --fstype=biosboot --size=1
|
||||
# # Disk partitioning information
|
||||
# part /boot --fstype=xfs --size=300
|
||||
# part pv.122 --fstype="lvmpv" --grow
|
||||
# volgroup VolGroup00 --pesize=16384 pv.122
|
||||
# logvol / --fstype="xfs" --size=10000 --name=LogVol00 --vgname=VolGroup00
|
||||
|
||||
|
||||
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
|
||||
# repo --name=Centos7-Base --baseurl=http://192.168.10.50/repo/Centos7-Base
|
||||
# repo --name=Centos7-Updates --baseurl=http://192.168.10.50/repo/Centos7-Updates
|
||||
# repo --name=Centos7-extras --baseurl=http://192.168.10.50/repo/Centos7-extras
|
||||
# repo --name=Centos7-Epel --baseurl=http://192.168.10.50/repo/Centos7-Epel
|
||||
# repo --name=source-1 --baseurl=http://192.168.10.50/images/centos7
|
||||
|
||||
# add repo manually
|
||||
# repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
|
||||
|
||||
# Network information
|
||||
network --bootproto=dhcp --device=eth0 --onboot=on
|
||||
|
||||
# Do not configure the X Window System
|
||||
skipx
|
||||
# Run the Setup Agent on first boot
|
||||
firstboot --disable
|
||||
# Reboot after installation
|
||||
reboot
|
||||
|
||||
%pre
|
||||
set -x -v
|
||||
exec 1>/tmp/ks-pre.log 2>&1
|
||||
|
||||
# Once root's homedir is there, copy over the log.
|
||||
while : ; do
|
||||
sleep 10
|
||||
if [ -d /mnt/sysimage/root ]; then
|
||||
cp /tmp/ks-pre.log /mnt/sysimage/root/
|
||||
logger "Copied %pre section log to system"
|
||||
break
|
||||
fi
|
||||
done &
|
||||
|
||||
|
||||
# Enable installation monitoring
|
||||
|
||||
%end
|
||||
|
||||
%packages
|
||||
|
||||
|
||||
# if you need puppet to install pkgs, just uncomment it
|
||||
#
|
||||
|
||||
@core
|
||||
@base
|
||||
tree
|
||||
nmap
|
||||
wget
|
||||
telnet
|
||||
zsh
|
||||
docker
|
||||
python-pip
|
||||
|
||||
%end
|
||||
|
||||
%post --nochroot
|
||||
set -x -v
|
||||
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1
|
||||
%end
|
||||
|
||||
%post
|
||||
set -x -v
|
||||
exec 1>/root/ks-post.log 2>&1
|
||||
|
||||
|
||||
wget http://192.168.10.50/pride/init.sh -O /tmp/init.sh
|
||||
chmod u+x /tmp/init.sh
|
||||
/tmp/init.sh
|
||||
# wget http://192.168.10.60/cblr/pride/init.sh -O /tmp/init.sh && chmod u+x /tmp/init.sh && /tmp/init.sh
|
||||
%end
|
||||
```
|
||||
|
||||
@@ -52,6 +52,7 @@ deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
|
||||
```bash
|
||||
sudo apt install zsh
|
||||
sudo curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
|
||||
sudo curl -L https://public.veypi.com/install_zsh.sh | sh
|
||||
chsh -s /bin/zsh
|
||||
```
|
||||
|
||||
@@ -96,6 +97,12 @@ network={
|
||||
sudo wpa_cli -i wlan0 reconfigure
|
||||
```
|
||||
|
||||
## docker
|
||||
|
||||
```bash
|
||||
sudo curl -sSL https://get.docker.com | sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
------------------------
|
||||
|
||||
Reference in New Issue
Block a user