cobbler运维自动化安装linux

Cobbler批量装系统

1、 简介
网络安装服务器套件 Cobbler(补鞋匠)从前,我们一直在做装机民工这份很有前途的职业。自打若干年前 Red Hat 推出了 Kickstart,此后我们顿觉身价倍增。不再需要刻了光盘一台一台地安装 Linux,只要搞定 PXE、DHCP、TFTP,还有那满屏眼花缭乱不知所云的 Kickstart 脚本,我们就可以像哈里波特一样,轻点魔棒,瞬间安装上百台服务器。这一堆花里胡哨的东西可不是一般人都能整明白的,没有大专以上学历,通不过英语四级, 根本别想玩转。总而言之,这是一份多么有前途,多么有技术含量的工作啊。很不幸,Red Hat 最新(Cobbler项目最初在2008年左右发布)发布了网络安装服务器套件 Cobbler(补鞋匠),它已将 Linux 网络安装的技术门槛,从大专以上文化水平,成功降低到初中以下,连补鞋匠都能学会。对于我们这些在装机领域经营多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来说,不啻为一个晴天霹雳。
2、 系统环境准备
[[email protected] ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[[email protected] ~]# uname -r
2.6.32-573.el6.x86_64
[[email protected] ~]# ifconfig|awk -F "[ :]+" ‘NR==2 {print $4}‘
192.168.1.131
添加阿里epel源
[[email protected] ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel- 6.repo
准备环境软件httpd、dhcp、xinetd、rsync、pykickstart、cobbler和cobbler-web:
[[email protected] ~]# yum install -y httpd dhcp xinetd rsync pykickstart
[[email protected] ~]# yum install -y cobbler cobbler-web
报错:Error: Package: cobbler-web-2.6.11-7.git95749a6.el6.noarch (epel)
Requires: Django >= 1.4
缺少依赖包:Djange,Djange依赖包是python-simplejson,所以
[[email protected] ~]# yum install -y python-simplejson
[[email protected] ~]# wgethttps://kojipkgs.fedoraproject.org//packages/Django14/1.4.14/1.el6/noarch/Django14-1.4.14-1.el6.noarch.rpm
[[email protected] ~]# rpm -ivh Django14-1.4.14-1.el6.noarch.rpm
3、 配置文件
[[email protected] ~]# /etc/init.d/httpd status
httpd (pid 1960) is running...
[[email protected] ~]# /etc/init.d/cobblerd status
cobblerd (pid 1948) is running...
[[email protected] ~]# cobbler check #检查cobcler配置
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 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync
6 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked
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.
关于问题:
6、防火墙iptables还在运行
[[email protected] ~]# setenforce 0
setenforce: SELinux is disabled
[[email protected] ~]# service iptables stop
[[email protected] ~]# chkconfig iptables off
[[email protected] ~]# vim /etc/selinux/config
SELINUX=disabled
1、2、在/etc/cobbler/settings修改server,next_server的IP地址
[[email protected] ~]# sed -i "s/next_server: 127.0.0.1/next_server: 192.168.1.131/g" /etc/cobbler/settings
[[email protected] ~]# sed -i "s/server: 127.0.0.1/server: 192.168.1.131/g" /etc/cobbler/settings
修改cobbler管理dhcp和tftp
[[email protected] ~]# sed -i "s/manage_dhcp: 0/manage_dhcp: 1/" /etc/cobbler/settings
[[email protected] ~]# sed -i "s/manage_rsync: 0/manage_rsync: 1/g" /etc/cobbler/settings
PXE启动时不允许重复装机
[[email protected] ~]# sed -i ‘s/pxe_just_once: 0/pxe_just_once: 1/g‘ /etc/cobbler/settings
8、设置系统登录的root密码openssl passwd -1 -salt ‘guoge‘ ‘your-password-here‘"
[[email protected] ~]# openssl passwd -1 -salt ‘guoge‘ ‘123456‘ ##guoge为干扰内
##123456为密码
$1$guoge$4kUDFV7TavolzgIUxLM2m0
[[email protected] ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$guoge$4kUDFV7TavolzgIUxLM2m0" ##红色为修改内容

3、5、修改/etc/xinetd.d/rsync 和/etc/xinetd.d/rsync
[[email protected] ~]# sed -i "s/disable = yes/disable = no/g" /etc/xinetd.d/rsync
[[email protected] ~]#sed -i "s/disable = yes/disa disable = no /g" /etc/xinetd.d/tftp
4、需要使用cobbler get-loaders命令下载loaders文件
[[email protected] ~]# cobbler get-loaders
task started: 2018-07-31_080115_get_loaders
task started (id=Download Bootloader Content, time=Tue Jul 31 08:01:15 2018)
downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README
downloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot
downloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0
downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32
downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
TASK COMPLETE
所下载的文件在/var/lib/cobbler/loaders/当中
[[email protected] ~]# cobbler sync同步配置
重启服务
[[email protected] ~]# /etc/init.d/xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]
[[email protected] ~]# /etc/init.d/cobblerd restart
Stopping cobbler daemon: [ OK ]
Starting cobbler daemon: [ OK ]
[[email protected] ~]# cobbler check
The following are potential configuration items that you may want to fix:

1 : service dhcpd is not running
2 : debmirror package is not installed, it will be required to manage debian deployments and repositories # 和debian系统相关,不需要

3 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them # fence设备相关,不需要

Restart cobblerd and then run ‘cobbler sync‘ to apply changes.
问题1、配置并启动DHCP
[[email protected] ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.131;
option domain-name-servers 192.168.1.131;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.1.100 192.168.1.254;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
[[email protected] ~]# cobbler sync同步配置
设置开机自启动:
[[email protected] ~]# /etc/init.d/httpd restart
[[email protected] ~]#/etc/init.d/xinetd restart
[[email protected] ~]# /etc/init.d/dhcpd restart
[[email protected] ~]# /etc/init.d/cobblerd restart
[[email protected] ~]# chkconfig --level 35 httpd on
[[email protected] ~]# chkconfig --level 35 xinetd on
[[email protected] ~]# chkconfig --level 35 dhcpd on
[[email protected] ~]# chkconfig --level 35 cobblerd on

4、 设置镜像
[[email protected] ~]# mount /dev/cdrom /mnt/
[[email protected] ~]# cobbler import --path=/mnt/ --name=Centos-6.7-x86_64 --arch=x86_64
[[email protected] ~]# cobbler sync
[[email protected] ~]# /etc/init.d/httpd restart
[[email protected] ~]#/etc/init.d/xinetd restart
[[email protected] ~]# /etc/init.d/dhcpd restart
[[email protected] ~]# /etc/init.d/cobblerd restart
5、 ks.cfk文件
[[email protected] ~]# cat /var/lib/cobbler/kickstarts/sample_e
sample_end.ks sample_esx4.ks sample_esxi4.ks sample_esxi5.ks
[[email protected] ~]# cat /var/lib/cobbler/kickstarts/sample_e
sample_end.ks sample_esx4.ks sample_esxi4.ks sample_esxi5.ks
[[email protected] ~]# cat /var/lib/cobbler/kickstarts/sample_end.ks


# kickstart template for Fedora 8 and later.
# (includes %end blocks)
# do not use with earlier distros

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET(‘network_config‘)
# Reboot after installation
reboot

#Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
# install
# Clear the Master Boot Record
zerombr
#### Allow anaconda to partition the system as needed
autopart

%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‘)
%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
%end

查看安装镜像文件信息
[[email protected] ~]#cobbler distro report --name=CentOS-7.1-x86_64
查看所有的profile设置
[[email protected] ~]# cobbler profile report
查看指定的profile设置
[[email protected] ~]#cobbler profile report --name=CentOS-7.1-x86_64
[[email protected] ~]# cobbler sync同步配置

6、 cobbler-web支持网页登录
/etc/cobbler/users.conf # Web服务授权配置文件
/etc/cobbler/users.digest # 用于web访问的用户名密码配置文件 [[email protected] ~]# cat /etc/cobbler/users.digest
cobbler:Cobbler:a2d6bae81669d707b72c0bd9806e01f3
设置Cobbler web用户登陆密码
在Cobbler组添加cobbler用户
[[email protected] ~]# htdigest /etc/cobbler/users.digest "Cobbler" cobbler
Changing password for user cobbler in realm Cobbler
New password: 123456
Re-type new password:123456
登录地址为:http://192.168.1.131/cobbler_web或者https://192.168.1.131/cobbler_web
账户密码:cobbler 123456

参考

http://blog.oldboyedu.com/autoinstall-cobbler/
http://blog.51cto.com/mailfile/1395657
http://www.mamicode.com/info-detail-2328653.html

原文地址:http://blog.51cto.com/11575772/2152537

时间: 2024-10-24 15:40:26

cobbler运维自动化安装linux的相关文章

运维自动化之Cobbler系统安装详解

原文链接 参考文档 参考文档SA们现在都知道运维自动化的重要性,尤其是对于在服务器数量按几百台.几千台增加的公司而言,单单是装系统,如果不通过自动化来完成,根本是不可想象的. 运维自动化安装方面,早期一般使用人工配置pxe+dhcp+tftp配合kickstart,现在开源工具就多了,如cobbler,OpenQRM和Spacewalk.本文重点介绍Cobbler. Cobbler介绍 Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows.该工具使用p

运维自动化工具Cobbler之——安装实践

运维自动化工具--Cobbler实践 第1章 About Cobbler 1.1 Cobbler Introduction Cobbler是一个Linux服务器安装的服务,可以通过网络启动(PXE)的方式来快速安装.重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等. Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用.Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web

运维自动化之使用Cobbler自动化部署Linux操作系统

1.Cobbler是什么? Cobbler是一个Linux安装服务器,能够快速设置好网络安装环境.它实现了许多与Linux相关的任务的自动化和组合,因此你在部署新的(操作)系统或更改已经存在的操作系统时不需要在繁多的命令和应用程序之间来回切换.Cobbler能帮助(用户.管理者)置备和管理DNS.DHCP.软件包更新.电源管理.配置管理以及更多. "Cobbler is a Linux installation server that allows for rapid setup of netw

运维自动化 Cobbler 安装

运维自动化之Cobbler系统安装详解 设置epel源 rpm -Uvh 'http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm' yum 安装 yum -y installcobbler dhcp httpd xinetd tftp-server ==========================================================================

linux运维自动化之puppet简单应用(一)

一.pupper概述 puppet,这是目前运维主流的运维自动化工具,大多数运维管理人员都听说过,或者在使用以及在正在考虑使用中.puppet可以配合cobbler,puppet也可以配合func实现运维自动化,简单化,化繁杂为简单. 1.什么是puppet puppet是一种Linux.Unix平台的集中配置管理系统,使用ruby语言,可管理配置文件.用户.cron任务.软件包.系统服务等.puppet把这些系统实体称之为资源,puppet的设计目标是简化对这些资源的管理以及妥善处理资源间的依

linux运维自动化之puppet简单应用(二)

上篇博客介绍了在单机环境下的puppet应用,这次我们基于C/S模式来介绍下puppet! 一.实验环境 服务器角色 IP地址 安装软件 主机名 服务器端 172.16.8.1 puppet-server www.gulong.com 客户机端 172.16.8.2 puppet node1.gulong.com 客户机端 172.16.8.3 puppet node2.gulong.com 三台主机时间同步: #ntpdate 172.16.0.1 三台主机可以相互解析: # vim /etc

Ansible自动化运维的安装及常用模块解释

(一)前言: Ansible是今年来越来越火的一款开源运维自动化工具,通过Ansible可以实现运维自动化,提高运维工程师的工作效率,减少人为失误.Ansible通过本身集成的非常丰富的模块可以实现各种管理任务,其自带模块超过上千个.更为重要的是,它操作简单,但提供的功能又非常丰富,在运维领域,几乎可以做任何事. Ansible自2012年发布以来,很快在全球流行,其特点如下: Ansible基于Python开发,运维工程师对其二次开发相对比较容易: Ansible丰富的内置模块,几乎可以满足一

Ansible自动化运维的安装及常用模块详解

Ansible作为今年来越来越火的一款开源运维自动化工具,通过Ansible可以实现运维自动化,提高运维工程师的工作效率,减少人为失误.Ansible通过本身集成的非常丰富的模块可以实现各种管理任务,其自带模块超过上千个.更为重要的是,它操作简单,但提供的功能又非常丰富,在运维领域,几乎可以做任何事..Ansible自2012年发布以来,很快在全球流行,其特点如下: 1.Ansible基于Python开发,运维工程师对其二次开发相对比较容易2.Ansible丰富的内置模块,几乎可以满足一切要求3

运维自动化 SaltStack 安装

运维自动化 SaltStack SaltStack介绍:(略) 设置epel源 rpm -ivh 'http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm' yum安装master.minion Master主机安装: [[email protected]_1 yum.repos.d]# yum install salt-master 正在安装: salt-master