个人笔记-cobbler自动部署系统

简介: 个人笔记-cobbler自动部署系统

准备环境:

系统:centos7.4.1708

IP地址:eth0:192.168.10.32 eth1:172.16.1.32

防火墙:关闭

selinux:关闭

镜像源:阿里源

需要工具:dhcp;cobbler;cobbler-web;tftp-server;httpd;pykickstart;python-django;

第一步:

安装所需要的软件:

[root@cobbler ~]# yum -y install cobbler cobbler-web httpd dhcp tftp-server pykickstart python-django

查看是否安装成功:

[root@cobbler ~]# rpm -qa cobbler cobbler-web httpd dhcp tftp-server pykickstart python-django
httpd-2.4.6-89.el7.centos.1.x86_64
dhcp-4.2.5-68.el7.centos.1.x86_64
cobbler-2.8.4-4.el7.x86_64
pykickstart-1.99.66.19-2.el7.noarch
tftp-server-5.2-22.el7.x86_64
cobbler-web-2.8.4-4.el7.noarch

开启cobbler服务和httpd服务:

[root@cobbler ~]# systemctl start cobblerd.service httpd.service

查看其状态:

[root@cobbler ~]# systemctl is-active cobblerd.service httpd.service 
active
active

检查cobbler自身需要配置的项;

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

对应的中文翻译:

以下是可能需要修复的配置项:
1: /etc/cobbler/settings中的“server”字段必须设置为localhost以外的其他字段,否则启动功能将不起作用。这应该是引导服务器的一个可解析主机名或IP,所有使用它的机器都可以访问它。
2:要使PXE起作用,/etc/cobbler/settings中的'next_server'字段必须设置为127.0.0.1之外的值,并且应该与PXE网络上引导服务器的IP相匹配。
3:将/etc/xinetd.d/tftp中的“disable”更改为“no”
4: /var/lib/cobbler/loaders中缺少一些网络引导加载程序,您可以运行“cobbler get-loaders”来下载它们,或者,如果您只想处理x86/x86_64 netbooting,您可以确保已经安装了syslinux包的“最新”版本,并且可以完全忽略这条消息。如果希望支持所有体系结构,这个目录中的文件应该包括pxelinux。0,菜单。c32 elilo。efi, yaboot。“cobbler get-loaders”命令是解决这些需求的最简单方法。
5:启用并启动rsyncd。服务与systemctl
6:没有安装debmirror包,需要管理debian部署和存储库
7:新安装机器的示例模板使用的默认密码(default_password_crypted in /etc/cobbler/settings)仍然被设置为“cobbler”,应该进行更改,尝试“openssl passwd -1 -salt”随机短语“here”“your-password-here”来生成新密码
8.没有找到击剑工具,需要使用(可选)电源管理功能。安装cman或击剑代理来使用它们
重启cobblerd,然后运行“cobbler sync”应用更改。

(其中第六项和第八项不用配置,其他项依次配置)

第二步:配置

修改配置文件,解决第一,二,七项问题:

[root@cobbler ~]# vim /etc/cobbler/settings

首先,授权cobbler可管理dhcp服务:

末行模式输入:/^manage

20190816145919969_.png

配置serverIP和next_serverIP:

末行模式输入:/^server

20190816150231680_.png

修改客户端默认密码:(可在ssh复制渠道操作)

生成密码:(密码为123123),然后将生成的密文密码输入至配置文件

[root@cobbler ~]# openssl passwd -1
Password: 
Verifying - Password: 
$1$meoQaqMc$qrmCAPy2sPBTOnPzRLJZ/0

末行模式输入:/default_password

(将默认密码删除,写入生成的密文密码,然后保存退出配置文件)

管理dhcp默认配置:

[root@cobbler ~]# vim /etc/cobbler/dhcp.template

在末行模式输入:%s#192.168.1#192.168.10#g将文件默认的192.168.1替换为192.168.10,然后删除圈中的两行内容:

20190816151403653_.png

将tftp服务的默认关闭状态改成no解决第三项问题:

[root@cobbler ~]# vim /etc/xinetd.d/tftp


20190816151611255_.png

下载引导文件解决第四项问题:

[root@cobbler ~]# cobbler get-loaders

开启rsyncd服务,并设置开机启动解决第五项问题:

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

重新启动cobbler服务:

[root@cobbler ~]# systemctl restart cobblerd.service

生成配置清单:

[root@cobbler ~]# cobbler sync
task started: 2019-08-16_152901_sync
task started (id=Sync, time=Fri Aug 16 15:29:01 2019)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
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.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***

重新检测配置问题:(发现还剩两项)

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

启动tftp服务:

[root@cobbler ~]# systemctl start tftp.socket

检查需要的服务是否都已经开启:

[root@cobbler ~]# systemctl is-active cobblerd.service httpd.service tftp.socket rsyncd.service
active
active
active
active

访问测试:https://192.168.10.32/cobbler_web

20190816153323970_.png

如果出现报错,且单独网站可以访问,可能是django版本问题:

解决方案:

查看django版本:

[root@cobbler ~]# rpm -qa | grep python2-django
python2-django-1.11.21-2.el7.noarch

强制卸载djang:

[root@cobbler ~]#  rpm -e --nodeps python2-django-1.11.21-2.el7.noarch

安装python2-pip工具:

[root@cobbler ~]#  yum -y install python2-pip

安装pip:

[root@cobbler ~]# pip install --upgrade pip

安装django1.8版本:

[root@cobbler ~]#  pip install Django==1.8.17

重启cobbler服务:

[root@cobbler ~]# systemctl restart cobblerd.service

然后重新访问网页:

出现这个页面说明安装成功,然后登陆,默认用户密码为:cobbler

第三步:配置客户端自动安装配置

挂载光盘镜像:

[root@cobbler ~]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only

将镜像导入cobbler:

查看导入情况;:出现complete说明导入成功

修改网卡名为eth格式:DIstros——点击镜像——修改内容——save


20190816155755785_.png

创建新的自动应答文件:

配置文件内容如下:

# Cobbler for Kickstart Configurator for CentOS 7 by yyang
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

应用自定义的ks文件模板:

Profiles——单击镜像——找到kickstart——选择刚才自定义的模板-save

制定系统基本信息:(网卡信息根据需求配置)

选择systems——创建新系统(create new system)

跳过第二页配置第三页:配置主机名,网关,DNS

指定网卡ip地址。(如果装多台不建议指定)

然后保存,注mac地址需要到虚拟机上查看

配置完成,点击sync刷新配置:

————————————————————————————————

防止误重装操作:

[root@cobbler ~]# sed -i 's/pxe_just_once:0/pxe_just_once:1/g' /etc/cobbler/settings

新建虚拟机测试:

配置好信息后进入安装页面,选择要安装的系统centos7.4

安装完成:

20190816171933517_.png

目录
相关文章
|
7月前
|
自然语言处理 Shell 网络安全
Liunx服务器搭建SVN服务,并通过钩子实现代码自动部署
Liunx服务器搭建SVN服务,并通过钩子实现代码自动部署
86 3
|
Linux 持续交付 网络安全
个人笔记-PXE-kickstart自动化部署系统
个人笔记-PXE-kickstart自动化部署系统
135 0
个人笔记-PXE-kickstart自动化部署系统
|
Java jenkins 持续交付
项目部署(jenkins 需要软件安装)| 学习笔记
快速学习 项目部署(jenkins 需要软件安装)
132 0
项目部署(jenkins 需要软件安装)| 学习笔记
|
jenkins 持续交付 数据安全/隐私保护
Jenkins 服务器环境的安装与部署| 学习笔记
快速学习 Jenkins 服务器环境的安装与部署。
Jenkins 服务器环境的安装与部署| 学习笔记
|
jenkins Linux 持续交付
windows服务+OpenSSH+SVN在Jenkins上的自动化部署进阶篇
使用jenkins如何将编译好的源码包传输到其他服务器上时,顺便一起将windows服务做持续部署的内容也加入进来
1242 0
windows服务+OpenSSH+SVN在Jenkins上的自动化部署进阶篇
|
Linux 网络安全 数据安全/隐私保护
Vagrant 搭建开发环境实践
vagrant是一个命令行的虚拟机管理程序。用于简化搭建开发环境。 vagrant使用ruby语言基于Chef 开发。需要配合其他虚拟机程序进行工作,如vmare、virualbox、hyper-v等。并通过 CLI和VagrantFile(配置文件)管理虚拟机的所有功能。vagrant 使用自己的镜像格式进行环境部署,即box。类似于虚机的iso或者docker中的镜像。
422 0
|
存储 网络协议 开发工具
|
存储 开发工具 数据安全/隐私保护
|
数据安全/隐私保护
|
网络安全 开发工具 git
下一篇
DataWorks