码迷,mamicode.com
首页 > 系统相关 > 详细

CentOS7 安装cobbler自动部署ubuntu

时间:2016-10-11 14:37:43      阅读:773      评论:0      收藏:0      [点我收藏+]

标签:centos7 cobbler2.6 ubuntu

CentOS7 安装cobbler自动部署ubuntu

 

一、简介

二、安装CentOS 7 调整配置及安装相关软件

1、调整配置

2、安装 epel

3、安装cobblercobbler-web 以及相关依赖软件

4、设置开机启动

三、Cobblertftpdhcprsync配置

1TFTP配置

2、配置rsync

3、配置/etc/cobbler/settings

4、修改/etc/cobbler/modules.conf

5、修改/etc/cobbler/dhcp.template

6、重启cobbler httpd服务

四、检查cobbler配置

五、导入镜像并查看导入情况

1、导入镜像

2、查看

六、编辑seed文件

1、普通分区配置

2lvm分区配置

七、注意事项

八、截图



 

一、简介

Cobbler是红帽开发的批量部署系统的工具,对RHELCentOS支持完美

对其他发行版的linux部分支持,也不是很完美

本文介绍的是基于CentOS 7上安装cobbler 2.6的文档

参照了网上的一些教程和官方文档,加上自己的实践,特别是分区部分,调试了数十次才算完美了。

二、安装CentOS 7 调整配置及安装相关软件

1、调整配置

安装完成后关闭selinux或参照cobbler官方文档设置selinuxhttp://cobbler.github.io/manuals/2.6.0/4/2_-_SELinux.html

[root@cobbler-server ~]# sed -i ‘/SELINUX/s/enforcing/disabled/‘ /etc/selinux/config  

重启服务器

关闭iptables以及取消开机启动,centos7 minimal没有安装ipables

关闭firewall或放行80 67 68 69 443 端口

80 443cobbler web管理界面端口

67 68 DHCP端口

69TFTP端口

[root@cobbler-server ~]# systemctl stop firewalld

[root@cobbler-server ~]# systemctl disable firewalld

2、安装 epel

[root@cobbler-server ~]# yum install epel-release

[root@cobbler-server ~]# yum makecache

3、安装cobblercobbler-web 以及相关依赖软件

[root@cobbler-server ~]# yum install cobbler cobbler-web xinetd pykickstart cman dhcp -y

4、设置开机启动

[root@cobbler-server ~]# systemctl enable httpd

[root@cobbler-server ~]# systemctl enable dhcpd  

[root@cobbler-server ~]# systemctl enable cobblerd

三、Cobblertftpdhcprsync配置

1TFTP配置

配置tftp绿色着色为修改后的值

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

# default: off

# description: The tftp server serves files using the trivial file transfer \

#       protocol.  The tftp protocol is often used to boot diskless \

#       workstations, download configuration files to network-aware printers, \

#       and to start the installation process for some operating systems.

service tftp

{

        socket_type             = dgram

        protocol                = udp

        wait                    = yes

        user                    = root

        server                  = /usr/sbin/in.tftpd

        server_args             = -s /var/lib/tftpboot

        disable                 = no

        per_source              = 11

        cps                     = 100 2

        flags                   = IPv4

}

2、配置rsync

[root@cobbler-server ~]# systemctl enable rsyncd

CentOS7上安装cobbler 对于rsync无需额外配置

3、配置/etc/cobbler/settings

[root@cobbler-server ~]# cat /etc/cobbler/settings |grep ‘^[^#]‘

---

allow_duplicate_hostnames: 0

allow_duplicate_ips: 0

allow_duplicate_macs: 0

allow_dynamic_settings: 0

anamon_enabled: 0

authn_pam_service: "login"

auth_token_expiration: 3600

build_reporting_enabled: 0

build_reporting_sender: ""

build_reporting_email: [ ‘root@localhost‘ ]

build_reporting_smtp_server: "localhost"

build_reporting_subject: ""

build_reporting_ignorelist: [ "" ]

cheetah_import_whitelist:

 - "random"

 - "re"

 - "time"

createrepo_flags: "-c cache -s sha"

default_kickstart: /var/lib/cobbler/kickstarts/default.ks

default_name_servers: []

default_ownership:

 - "admin"

default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

default_template_type: "cheetah"

default_virt_bridge: xenbr0

default_virt_file_size: 5

default_virt_ram: 512

default_virt_type: xenpv

enable_gpxe: 0

enable_menu: 1

func_auto_setup: 0

func_master: overlord.example.org

http_port: 80

kernel_options:

 ksdevice: bootif

 lang: ‘ ‘

 text: ~

kernel_options_s390x:

 RUNKS: 1

 ramdisk_size: 40000

 root: /dev/ram0

 ro: ~

 ip: off

 vnc: ~

ldap_server: "ldap.example.com"

ldap_base_dn: "DC=example,DC=com"

ldap_port: 389

ldap_tls: 1

ldap_anonymous_bind: 1

ldap_search_bind_dn: ‘‘

ldap_search_passwd: ‘‘

ldap_search_prefix: ‘uid=‘

ldap_tls_cacertfile: ‘‘

ldap_tls_keyfile: ‘‘

ldap_tls_certfile: ‘‘

mgmt_classes: []

mgmt_parameters:

 from_cobbler: 1

puppet_auto_setup: 0

sign_puppet_certs_automatically: 0

puppetca_path: "/usr/bin/puppet"

remove_old_puppet_certs_automatically: 0

manage_dhcp: 1

#cobbler接管DHCP,默认为0,此处修改以后需要修改对应/etc/cobbler/dhcp.template模板

manage_dns: 0

bind_chroot_path: ""

bind_master: 127.0.0.1

manage_tftpd: 1

manage_rsync: 1 #接管rsync,无需额外配置rsync

manage_forward_zones: []

manage_reverse_zones: []

next_server: 192.168.11.252 #本机ip地址

power_management_default_type: ‘ipmitool‘

power_template_dir: "/etc/cobbler/power"

pxe_just_once: 0

pxe_template_dir: "/etc/cobbler/pxe"

consoles: "/var/consoles"

redhat_management_type: "off"

redhat_management_server: "xmlrpc.rhn.redhat.com"

redhat_management_key: ""

redhat_management_permissive: 0

register_new_installs: 0

reposync_flags: "-l -n -d"

restart_dns: 1

restart_dhcp: 1

run_install_triggers: 1

scm_track_enabled: 0

scm_track_mode: "git"

server: 192.168.11.252 #本机ip地址

client_use_localhost: 0

client_use_https: 0

snippetsdir: /var/lib/cobbler/snippets

template_remote_kickstarts: 0

virt_auto_boot: 1

webdir: /var/www/cobbler

xmlrpc_port: 25151

yum_post_install_mirror: 1

yum_distro_priority: 1

yumdownloader_flags: "--resolve"

serializer_pretty_json: 0

replicate_rsync_options: "-avzH"

replicate_repo_rsync_options: "-avzH"

always_write_dhcp_entries: 0

proxy_url_ext: ""

proxy_url_int: ""

 

4、修改/etc/cobbler/modules.conf

[root@cobbler-server ~]# cat /etc/cobbler/modules.conf |grep ‘^[^#]‘

 

[authentication]

module = authn_configfile

[authorization]

module = authz_allowall

[dns]

module = manage_bind

[dhcp]

module = manage_isc #如果是dnsmasq就应该为manage_dnsmasq

[tftpd]

module = manage_in_tftpd

 

5、修改/etc/cobbler/dhcp.template

[root@localhost cobbler]# cat /etc/cobbler/dhcp.template |grep ‘^[^#]‘

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.11.0 netmask 255.255.255.0 {

     option routers             192.168.11.252;

     option domain-name-servers 192.168.11.252;

     option subnet-mask         255.255.255.0;

     range dynamic-bootp        192.168.11.100 192.168.11.200;

     default-lease-time         21600;

     max-lease-time             43200;

     next-server                $next_server;

     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 {

                  filename "pxelinux.0";

          }

     }

}

    ## group could be subnet if your dhcp tags line up with your subnets

    ## or really any valid dhcpd.conf construct ... if you only use the

    ## default dhcp tag in cobbler, the group block can be deleted for a

    ## flat configuration

group {

        #for mac in $dhcp_tags[$dhcp_tag].keys():

            #set iface = $dhcp_tags[$dhcp_tag][$mac]

    host $iface.name {

        hardware ethernet $mac;

        #if $iface.ip_address:

        fixed-address $iface.ip_address;

        #end if

        #if $iface.hostname:

        option host-name "$iface.hostname";

        #end if

        #if $iface.netmask:

        option subnet-mask $iface.netmask;

        #end if

        #if $iface.gateway:

        option routers $iface.gateway;

        #end if

        #if $iface.enable_gpxe:

        if exists user-class and option user-class = "gPXE" {

            filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";

        } else if exists user-class and option user-class = "iPXE" {

            filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";

        } else {

            filename "undionly.kpxe";

        }

        #else

        filename "$iface.filename";

        #end if

        ## Cobbler defaults to $next_server, but some users

        ## may like to use $iface.system.server for proxied setups

        next-server $next_server;

        ## next-server $iface.next_server;

    }

        #end for

}

6、重启cobbler httpd服务

[root@cobbler-server ~]# systemctl restart cobblerd

[root@cobbler-server ~]# systemctl restart httpd

 

四、检查cobbler配置

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

 

Restart cobblerd and then run ‘cobbler sync‘ to apply changes.

以上两点都可以忽略

第二点是修改部署系统默认的root密码

若提示enabled rsyncd or use systemctl to start rsyncd.service

是叫你把rsync加到开机启动

[root@cobbler-server ~]# systemctl enable rsyncd

执行以上命令后就不会出现这个提示了

五、导入镜像并查看导入情况

1、导入镜像

[root@cobbler-server ~]# mount /dev/cdrom /mnt/cdrom/

mount: /dev/sr0 is write-protected, mounting read-only

[root@cobbler-server ~]#cobbler import --path=/mnt/cdrom/ --name=ubuntu-12.04.5 --arch=x86_64

task started: 2016-10-07_221950_import

task started (id=Media import, time=Fri Oct  7 22:19:50 2016)

Found a candidate signature: breed=freebsd, version=10.1

Found a candidate signature: breed=freebsd, version=10.0

Found a candidate signature: breed=freebsd, version=8.3

Found a candidate signature: breed=freebsd, version=8.2

Found a candidate signature: breed=freebsd, version=8.4

Found a candidate signature: breed=freebsd, version=10.2

Found a candidate signature: breed=freebsd, version=9.0

Found a candidate signature: breed=freebsd, version=9.1

Found a candidate signature: breed=freebsd, version=9.2

Found a candidate signature: breed=freebsd, version=9.3

Found a candidate signature: breed=ubuntu, version=precise

running: /usr/bin/file /var/www/cobbler/ks_mirror/ubuntu-12.04.5-x86_64/dists/precise/Release

received on stdout: /var/www/cobbler/ks_mirror/ubuntu-12.04.5-x86_64/dists/precise/Release: ASCII text

 

received on stderr:

Found a matching signature: breed=ubuntu, version=precise

Adding distros from path /var/www/cobbler/ks_mirror/ubuntu-12.04.5-x86_64:

creating new distro: ubuntu-12.04.5-x86_64

trying symlink: /var/www/cobbler/ks_mirror/ubuntu-12.04.5-x86_64 -> /var/www/cobbler/links/ubuntu-12.04.5-x86_64

creating new profile: ubuntu-12.04.5-x86_64

associating repos

checking for apt repo(s)

adding apt repo for ubuntu-12.04.5-x86_64

Added repos for ubuntu-12.04.5-x86_64

*** TASK COMPLETE ***

有些镜像是不支持的,不支持就会导入错误

2、查看

查看导入的镜像和使用到的kickstart文件信息

[root@cobbler-server ~]# cobbler distro list

   CentOS-7.2-x86_64

   ESXi-6.0.0-x86_64

   ubuntu-12.04.5-x86_64

[root@cobbler-server ~]# cobbler profile report

Name                           : ESXi-6.0.0-x86_64

TFTP Boot Files                : {}

Comment                        :

DHCP Tag                       : default

Distribution                   : ESXi-6.0.0-x86_64

Enable gPXE?                   : 0

Enable PXE Menu?               : 1

Fetchable Files                : {}

Kernel Options                 : {}

Kernel Options (Post Install)  : {}

Kickstart                      : /var/lib/cobbler/kickstarts/sample_esxi5.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

 

Name                           : CentOS-7.2-x86_64

TFTP Boot Files                : {}

Comment                        :

DHCP Tag                       : default

Distribution                   : CentOS-7.2-x86_64

Enable gPXE?                   : 0

Enable PXE Menu?               : 1

Fetchable Files                : {}

Kernel Options                 : {}

Kernel Options (Post Install)  : {}

Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.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

 

Name                           : ubuntu-12.04.5-x86_64

TFTP Boot Files                : {}

Comment                        :

DHCP Tag                       : default

Distribution                   : ubuntu-12.04.5-x86_64

Enable gPXE?                   : 0

Enable PXE Menu?               : 1

Fetchable Files                : {}

Kernel Options                 : {}

Kernel Options (Post Install)  : {}

Kickstart                      : /var/lib/cobbler/kickstarts/sample.seed

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

六、编辑seed文件

1、普通分区配置

[root@cobbler-server ~]# grep "^[^#]" /var/lib/cobbler/kickstarts/sample.seed

d-i debian-installer/locale string en_US

d-i console-setup/ask_detect boolean false

d-i keyboard-configuration/layoutcode string us

d-i keyboard-configuration/variantcode string

d-i netcfg/choose_interface select auto

d-i netcfg/get_hostname string $myhostname

d-i time/zone string US/Eastern

d-i clock-setup/utc boolean true

d-i clock-setup/ntp boolean true

d-i clock-setup/ntp-server  string ntp.ubuntu.com

d-i mirror/country string manual

d-i mirror/http/hostname string $http_server

d-i mirror/http/directory string $install_source_directory

d-i mirror/http/proxy string

d-i live-installer/net-image string http://$http_server/cobbler/links/$distro_name/install/filesystem.squashfs

d-i partman-auto/disk string /dev/sda

d-i partman-auto/method string regular

d-i partman-auto/choose_recipe select fsm

d-i partman-lvm/device_remove_lvm boolean true

d-i partman-md/device_remove_md boolean true

d-i partman-auto/expert_recipe string \

fsm :: \

1024 100% 1024 linux-swap method{ swap } \

format{ } \

. \

2048 2048 2048 ext4 method{ format } \

mountpoint{ /home } \

format{ } use_filesystem{ } filesystem{ ext4 } \

. \

10240 10240 10240 ext4 method{ format } \

mountpoint{ / } \

format{ } use_filesystem{ } filesystem{ ext4 } \

options/relatime{ relatime } \

. \

768 1024 1024 ext4 method{ format } \

mountpoint{ /tmp } \

format{ } use_filesystem{ } filesystem{ ext4 } \

options/relatime{ relatime } \

. \

1 2048 1000000000 ext4 method{ format } \

mountpoint{ /www } \

format{ } use_filesystem{ } filesystem{ ext4 } \

options/relatime{ relatime } \

.

d-i partman-lvm/confirm_nooverwrite boolean true

d-i partman-lvm/confirm boolean true

d-i partman-partitioning/confirm_write_new_label boolean true

d-i partman/confirm_nooverwrite boolean true

d-i partman/confirm boolean true

d-i partman/choose_partition \

select Finish partitioning and write changes to disk

d-i passwd/root-login boolean true

d-i passwd/root-password-crypted password $default_password_crypted

d-i passwd/make-user boolean false

$SNIPPET(‘preseed_apt_repo_config‘)

d-i pkgsel/include string ntp ssh wget vim

d-i debian-installer/add-kernel-opts string $kernel_options_post

d-i finish-install/reboot_in_progress note

d-i preseed/early_command string wget -O- \

   http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_early_default | \

   /bin/sh -s

d-i preseed/late_command string wget -O- \

   http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_late_default | \

   chroot /target /bin/sh -s

2lvm分区配置

绿色标记部分是最重要的,定制分区的配置,以上是普通分区方式

如果是lvm分区方式,用以下配置

d-i partman-auto/disk string /dev/sda#指定磁盘

d-i partman-auto/method string lvm#分区格式lvm还是普通分区还是raid

d-i partman-auto/choose_recipe select fsm

d-i partman-lvm/device_remove_lvm boolean true

d-i partman-md/device_remove_md boolean true

d-i partman-auto-lvm/no_boot boolean true

d-i partman-auto-lvm/new_vg_name string vg0

d-i partman-auto/expert_recipe string \

fsm :: \

1024 100% 1024 linux-swap method{ swap } \

format{ } $lvmok{ } lv_name{ swap } \

. \

2048 2048 2048 ext4 method{ lvm } \

$lvmok{ } mountpoint{ /home } lv_name{ home } \

format{ } use_filesystem{ } filesystem{ ext4 } \

. \

10240 10240 10240 ext4 method{ lvm } \

$lvmok{ } mountpoint{ / } lv_name{ root } \

format{ } use_filesystem{ } filesystem{ ext4 } \

options/relatime{ relatime } \

. \

768 1024 1024 ext4 method{ lvm } \

$lvmok{ } mountpoint{ /tmp } lv_name{ tmp } \

format{ } use_filesystem{ } filesystem{ ext4 } \

options/relatime{ relatime } \

. \

1 2048 1000000000 ext4 method{ lvm } \

$lvmok{ } mountpoint{ /www } lv_name{ www } \

format{ } use_filesystem{ } filesystem{ ext4 } \

options/relatime{ relatime } \

.

d-i partman-lvm/confirm_nooverwrite boolean true

d-i partman-lvm/confirm boolean true

d-i partman-partitioning/confirm_write_new_label boolean true

d-i partman/confirm_nooverwrite boolean true

d-i partman/confirm boolean true

d-i partman/choose_partition \

    select Finish partitioning and write changes to disk    #保存分区

技术分享 

 

注:

$lvmok{ }必须存在,不然安装会报错无法继续

技术分享 

不存在这个选项cobbler又会报错

{‘code‘: u‘VFFSL(SL,"lvmok",True)‘,

  ‘exc_val‘: NotFound(u"cannot find ‘lvmok‘",),

  ‘lineCol‘: (60, 11),

  ‘rawCode‘: u‘$lvmok‘,

  ‘time‘: ‘Sun Oct  9 23:43:14 2016‘}]

不知道是不是cobblerbug

 

七、注意事项

11 2048 1000000000 ext4 method{ lvm } \ 这三个数字分别代表最少1M ,权重,最多1000000000M

如果把剩余的都分配就用三个-1,即-1 -1 -1 ext4 method{ lvm } \

2d-i partman-auto/choose_recipe select fsmfsm随意命名,但必须和d-i partman-auto/expert_recipe string fsm :: 这个fsm对应

3seed文件中不能有中文哪怕是注释,不然会报错

4、每次修改/etc/cobbler/setting配置后需要执行cobbler sync进行同步

5、对于esxi的支持,默认不支持esxi6,但是可以用esxi5kickstart文件,部分不兼容,但仍能全自动安装

 

八、截图

 

技术分享 

 

 


本文出自 “玩玩” 博客,请务必保留此出处http://lm3810.blog.51cto.com/846925/1860546

CentOS7 安装cobbler自动部署ubuntu

标签:centos7 cobbler2.6 ubuntu

原文地址:http://lm3810.blog.51cto.com/846925/1860546

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!