Cobbler自动化部署系统
1、cobbler简介
cobbler是一个LInux
服务器安装的服务,可以通过网络启动(PXE
)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等
cobbler可以使用命令行的方式来管理,也提供了基于web
的界面管理工具(cobble-web
),还提供了API接口,可以方便二次开发的使用。
Cobbler是早些年前的kickstart的升级版,优点是比较容易配置的,还自带web方便管理
Cobbler内置一个轻量级管理系统,但他也支持其他配置管理系统集成,如Puppet,暂时不支持SaltStack
cobbler 集成的服务
- PXE服务支持
- DHCP服务管理
- DNS服务管理
- 电源管理
- Kickstart服务支持
- YUM仓库管理
- TFTP(PXE启动时需要)
- Apache(提供kickstart的安装源,并提供定制化的kickstart)
cobbler配置文件详解
cobbler的所在目录:/etc/cobbler
配置文件 | 作用 |
---|---|
/etc/cobbler/sttings | cobbler主配置文件 |
/etc/cobbler/iso | iso模板配置文件 |
/etc/cobbler/pxe | pxe配置文件 |
/etc/cobbler/power | 电源配置文件 |
/etc/cobbler/user.conf | web授权配置文件 |
/etc/cobbler/users.digest | web的访问的用户名和密码 |
/etc/cobbler/dhcp.template | dhcp服务器的配置模板 |
/etc/cobbler/dnsmasq.template | dns服务器的配置模板 |
/etc/cobbler/tftpd.template | tftp服务的配置文件 |
/etc/cobbler/modules.conf | 模块配置文件 |
cobbler的数据目录
目录 | 作用 |
---|---|
/var/lib/cobbler/config/ | 用于存放distros,system,profiles等信息文件 |
/var/lib/cobbler/triggers/ | 用于存放用户定义的cobber命令 |
/var/lib/cobbler/kickstart/ | 默认存放kickstart文件 |
/var/lib/cobbler/loaders/ | 存放各种引导程序以及镜像目录 |
/var/www/cobbler/ks_mirror/ | 导入发行版本系统的所有数据 |
/var/www/cobbler/repo_mirror/ | yum 仓库储存目录 |
/var/www/cobbler/images/ | 导入发行版本的kernel和initrd镜像用于远程网络启动 |
cobbler日志文件
日志文件路径 | 说明 |
---|---|
/var/log/cobbler/installing | 客户端日志 |
/var/log/cobbler/cobbler.log | cobbler日志 |
cobbler命令详解
cobbler check //核对配置有没有问题
cobbler list //列出所有的cobbler元素
cobbler report //列出元素的详细信息
cobbler sync //同步数据目录
2、配置cobbler服务
1、关闭防火墙和selinux
# 关闭防火墙、selinux等
[root@cobbler ~]# systemctl stop firewalld
[root@cobbler ~]# systemctl disable firewalld
[root@cobbler ~]# setenforce 0
[root@cobbler ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/sysconfig/selinux
2、下载cobbler和相关依赖
# 配置epel源
[root@cobbler ~]# yum -y install epel-release
# 安装cobbler及dhcp httpd xinetd cobbler-web
[root@cobbler ~]# yum -y install cobbler cobbler-web tftp-server dhcp httpd xinetd
# 启动cobbler及httpd并加入开机启动
[root@cobbler ~]# systemctl start httpd cobblerd
[root@cobbler ~]# systemctl enable httpd cobblerd
3、设置可以动态的配置文件
[root@cobbler ~]# sed -ri '/allow_dynamic_settings:/c\allow_dynamic_settings: 1' /etc/cobbler/settings
[root@cobbler ~]# grep allow_dynamic_settings /etc/cobbler/settings
allow_dynamic_settings: 1
[root@cobbler ~]# systemctl restart cobblerd
4、查看cobbler的相关配置
#192.168.2.128为本机ip
[root@cobbler ~]# cobbler setting edit --name=server --value=192.168.2.128
[root@cobbler ~]# cobbler setting edit --name=next_server --value=192.168.2.128
[root@cobbler ~]# sed -ri '/disable/c\disable = no' /etc/xinetd.d/tftp
[root@cobbler ~]# systemctl enable xinetd
[root@cobbler ~]# systemctl restart xinetd
#下载某些cobbler插件
[root@cobbler ~]# cobbler get-loaders
#设置你的开机密码
[root@cobbler ~]# openssl passwd -1 -salt `openssl rand -hex 4` 'admin'
$1$675f1d08$oJoAMVxdbdKHjQXbGqNTX0
[root@cobbler ~]# vim vim /etc/cobbler/settings
......
default_password_crypted: $1$675f1d08$oJoAMVxdbdKHjQXbGqNTX0
......
[root@cobbler ~]# yum -y install fence-agents
[root@cobbler ~]# cobbler check
#检查是否有错误
[root@cobbler ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : 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
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories
[root@cobbler ~]# cobbler setting edit --name=manage_dhcp --value=1
# 修改cobbler的dhcp模块,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖
[root@cobbler ~]# vim /etc/cobbler/dhcp.template
...
subnet 192.168.2.0 netmask 255.255.255.0 { #这里改为分配的网段和掩码
#option routers 192.168.1.5; #如果有网关,这里改为网关地址
#option domain-name-servers 192.168.1.1; #如果有DNS,这里改为DNS地址
option subnet-mask 255.255.255.0; #改为分配的IP的掩码
range dynamic-bootp 192.168.2.100 192.168.2.254; #改为分配的IP的范围
...
5、cobbler的同步设置
[root@cobbler ~]# cobbler sync
task started: 2020-06-01_093828_sync
task started (id=Sync, time=Mon Jun 1 09:38:28 2020)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/radhat7-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/radhat7-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
copying: /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0
copying: /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32
copying: /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot
copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk
copying: /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying: /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
copying distros to tftpboot
copying files for distro: radhat7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/radhat7-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/radhat7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/radhat7-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/radhat7-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: radhat7-x86_64
trying hardlink /var/www/cobbler/ks_mirror/radhat7-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/radhat7-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/radhat7-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/radhat7-x86_64/initrd.img
Writing template files for radhat7-x86_64
rendering DHCP files
generating /etc/dhcp/dhcpd.conf
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: radhat7-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.manage_genders
running python trigger cobbler.modules.scm_track
running shell triggers from /var/lib/cobbler/triggers/change/*
*** TASK COMPLETE ***
5、cobbler配置安装radhad7x
1、创建挂载点,并且挂载
[root@test2 ~]# mount /dev/cdrom /radhat-7/
2、导入挂载镜像
[root@cobbler ~]# cobbler import --path=/centos6 --name=centos6.9 --arch=x86_64
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64
# 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:centos6.9,如果重复,系统会提示导入失败。
3、查看导入镜像
[root@cobbler ~]# cobbler distro report --name=radhat7-x86_64
Name : radhat7-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/radhat7-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/radhat7-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/radhat7-x86_64'}
Management Classes : []
OS Version : rhel7
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
[root@cobbler ~]#
4、查看profile信息
[root@cobbler ~]# cobbler profile report --name=radhat7-x86_64
Name : radhat7-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : radhat7-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/radhat7.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
[root@cobbler ~]#
5、copy
一份profile
文件(ks
),进行修改
[root@cobbler ~]# cd /var/lib/cobbler/kickstarts/
[root@cobbler kickstarts]# ls
default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample.ks
esxi4-ks.cfg legacy.ks sample_end.ks sample_esxi5.ks sample_old.seed
esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample_esxi6.ks sample.seed
[root@cobbler kickstarts]# cp sample_end.ks radhat7.ks
#修改内容如下
# This kickstart file should only be used with EL > 5 and/or Fedora > 7.
# For older versions please use the sample.ks kickstart file.
# 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
#Root password
rootpw --iscrypted $default_password_crypted
# System authorization information
auth --useshadow --enablemd5
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --disabled
# Use network installation
url --url=$tree
# Clear the Master Boot Record
zerombr
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
#这是磁盘分区
part /boot --fstype="ext4" --size=500
part swap --fstype="swap" --size=4096
part / --fstype="ext4" --grow --size=15000
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Do not configure the X Window System
skipx
# Run the Setup Agent on first boot
firstboot --disable
# Reboot after installation
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
$SNIPPET('func_install_if_enabled')
@core
@base
tree
nmap
wget
lftp
lrzsz
telnet
%end
%post --nochroot
$SNIPPET('log_ks_post_nochroot')
%end
%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
sed -ri "/^#UseDNS/c\UseDNS no" /etc/ssh/sshd_config
sed -ri "/^GSSAPIAuthentication/c\GSSAPIAuthentication no" /etc/ssh/sshd_config
%end
编辑radhat7
镜像所使用的kickstart
文件
# 动态编辑指定使用新的kickstart文件
[root@cobbler ~]# cobbler profile edit --name=radhat7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/radhat7.ks
# 验证是否更改成功
[root@cobbler kickstarts]# cobbler profile report --name=radhat7-x86_64 |grep Kickstart
Kickstart : /var/lib/cobbler/kickstarts/radhat7.ks
#同步文件
[root@cobbler ~]# cobbler sync
效果
3、自定制安装
![
Cobbler自动化部署系统的更多相关文章
- Cobbler 自动化部署系统
yum安装 yum install -y epel-release yum install -y httpd dhcp tftp cobbler cobbler-web pykickstart xin ...
- Cobbler自动化部署最佳实践
第1章 Cobbler自动化部署最佳实践 运维自动化在生产环境中占据着举足轻重的地位,尤其是面对几百台,几千台甚至几万台的服务器时,仅仅是安装操作系统,如果不通过自动化来完成,根本是不可想象的. 面对 ...
- .NET持续集成与自动化部署之路第一篇——半天搭建你的Jenkins持续集成与自动化部署系统
.NET持续集成与自动化部署之路第一篇(半天搭建你的Jenkins持续集成与自动化部署系统) 前言 相信每一位程序员都经历过深夜加班上线的痛苦!而作为一个加班上线如家常便饭的码农,更是深感其痛 ...
- centos7.2环境nginx+mysql+php-fpm+svn配置walle自动化部署系统详解
centos7.2环境nginx+mysql+php-fpm+svn配置walle自动化部署系统详解 操作系统:centos 7.2 x86_64 安装walle系统服务端 1.以下安装,均在宿主机( ...
- Cobbler自动化部署
一:PXE.Kickstart与Cobbler的概念: PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的技术,需要网卡的硬件支持,工作于C/S的 ...
- cobbler自动化安装系统
笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 在很久很久以前,使用kickstart实现自动化安装的时候,我一直认为装系统是多么高大上的活,直到cobbler的 ...
- .NET 半天搭建Jenkins持续集成与自动化部署系统
前言 相信每一位程序员都经历过深夜加班上线的痛苦!而作为一个加班上线如家常便饭的码农,更是深感其痛.由于我们所做的系统业务复杂,系统庞大,设计到多个系统之间的合作,而核心系统更是采用分布式系统架构,由 ...
- 自动化运维之Cobbler自动化部署安装操作系统
Cobbler概述: Cobbler可以用来快速建立 Linux 网络安装环境,它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会. 在生产环境中,经常批 ...
- (转)Cobbler自动化部署最佳实践
原文:http://www.xuliangwei.com/xubusi/446.html 运维自动化在生产环境中占据着举足轻重的地位,尤其是面对几百台,几千台甚至几万台的服务器时,仅仅是安装操作系统, ...
随机推荐
- 实验三 Java基本程序设计(2)
实验三 Java基本程序设计(2) ...
- hdu6153KMP
A Secret Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 256000/256000 K (Java/Others)Total ...
- PHP实现插入100万条数据优化
第一种方法一条一条执行插入,结果会很慢 <?php header("Content-Type:text/html;charset=utf-8"); date_default_ ...
- 工作中遇到的SQL
1.根据a表中的字段col,修改b表中的col UPDATE a INNER JOIN b ON a.id = b.id SET b.col = xx WHERE a.col = xx 2.模糊查询 ...
- Java——native关键字
说明:在使用HashSet的过程中,查看Object.java过程中发现hashCode()方法是以native关键字修饰,没看到过该关键字,这里记录下来. native关键字用来修饰方法,是使用一些 ...
- Dubbo源码阅读-服务导出
Dubbo服务导出过程始于Spring容器发布刷新事件,Dubbo在接收到事件后,会立即执行服务导出逻辑.整个逻辑大致可分为三个部分,第一部分是前置工作,主要用于检查参数,组装URL.第二部分是导出服 ...
- [JavaWeb基础] 025.JAVA把word转换成html
用第三方插件POI把word文档转换成HTML,下面直接上代码 package com.babybus.sdteam.wordtopdf; import java.io.BufferedWriter; ...
- BZOJ1003 物流运输 题解
发现\(n,m\)很小,我们可以先把任意\(2\)天的最短路都给求出来,考虑\(DP\),设\(f[i][j]\)表示\(j+1\)~ \(i\)这几天内走的是最短路线的最优方案,显然最优情况下\(j ...
- List<T> 的扩展方法
//List<T>.Take(m) //取出 前m行 IEnumerable<Person> takeList = lstPerson.Take(4); foreac ...
- 如何减小SRAM读写操作时的串扰
静态存储器SRAM是一款不需要刷新电路即能保存它内部存储数据的存储器.在SRAM 存储阵列的设计中,经常会出现串扰问题发生.那么要如何减小如何减小SRAM读写操作时的串扰,以及提高SRAM的可靠性呢, ...