cobbler自動化部署

cobblerlinux



目錄web

  前言vim

   1、簡介centos

   2、工做原理瀏覽器

   3、cobbler安裝配置bash

    一、啓動cobbler配置並檢查配置服務器

    二、執行Cobbler check報錯解決方式網絡

   3、配置及啓動cobbler所依賴的各服務dom

    一、dhcp服務koa

    二、TFTP服務

   4、配置Cobbler

    一、管理profile

   5、配置cobble_web

    一、配置cobbler_web的認證功能

    二、使用authn_pam模塊認證cobbler_web用戶

    三、使用authn_configfile模塊認證cobbler_web用戶

    四、centos7配置cobbler-web時問題

 

 前言

        cobbler是一個免費開源系統安裝部署軟件,用戶自動化網絡安裝操做系統。cobbler集成了DNS,DHCP,等方便操做系統安裝自動化。cobbler能夠支持pxe啓動,操做系統從新安裝,以及虛擬化客戶機建立,包括xen,KVM or Vmware。 cobbler透過koan程序以支持虛擬化客戶機安裝。cobbler能夠支持管理負責網絡環境,如建立在鏈路聚合以太網的橋接環境等。『維基百科』

 1、簡介

    關於操做系統安裝方面的自動化,早前咱們使用 RedHat 推出的 Kickstart來批量安裝操做系統,近年來 RedHat 又推出一個 Cobbler 。Cobbler 使用 Python 開發,小巧輕便,可以完成系統安裝、甚至一些服務的管理。( 號稱是補鞋匠都能學會的工具)Cobbler 支持命令行管理、web 界面管理、還提供了 API 接口,以便二次開法。

2、工做原理

 

wKiom1iNWRLAPyWwAABdD7fI-qY436.jpg

 

工做流:

    一、  client裸機配置了從網絡啓動後,開機後會發送廣播包請求dhcp服務器(cobbler server) 發送其分配好的ip一個ip

    二、  dhcp服務器(cobbler server)收到請求後發送responese,包括其ip地址

    三、  client裸機拿到ip後在向cobbler server 發送請求os引導文件的請求

    四、  cobbler server 告訴裸機os引導文件的名字和TFTP server的i和port

    五、  client 裸機經過上面告知的TFTP server 地址和port通訊,下載引導文件

    六、  client裸機執行該引導文件,肯定加載細膩,選擇要安裝的os,期間會在向cobbler server請求kickstart文件和os p_w_picpath

    七、  cobbler server 發送請求的kickstart和os iamges

    八、  client 裸機加載kickstart文件

    九、  client 裸機osp_w_picpath ,安裝該os p_w_picpath

 

 3、cobbler安裝配置

         yuminstall cobbler –y

一、啓動cobbler配置並檢查配置

        

 [root@centos7_1 ~]#systemctlcobblerd restart
 [root@centos7_1 ~]#cobbler check
  1 : The ‘server’ field in/etc/cobbler/settings must be set to something
   other than localhost, orkickstarting features will not work. This should
    be a resolvable hostname or IPfor 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
  mustbe set to something other than 127.0.0.1, and should match the IP of the 
  bootserver on the PXE network.
 3 :some network boot-loaders are missing from /var/lib/cobbler/loaders, you
  mayrun‘cobbler get-loaders’to download them, or, if you only want to handle
   x86/x86_64 netbooting, you mayensure that you have installed a recent version
    of the syslinux packageinstalled and can ignore this message entirely. 
    Files in this directory, shouldyou want to support all architectures, 
    should include pxelinux.0, menu.c32,elilo.efi, and yaboot. 
    The ‘cobbler get-loaders’ command is the easiest way toresolve 
    these requirements.
  4 : change ‘disable’ to ‘no’ in/etc/xinetd.d/rsync
  5 : comment ‘dists’ on /etc/debmirror.conffor proper debian support
  6 : comment ‘arches’ on /etc/debmirror.conffor proper debian support
  7 : The default password used by the sampletemplates 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 generatenew one
  8 : fencing tools were not found, and arerequired to use the (optional) power 
  management features. install cman orfence-agents to use them.
 
二、執行Cobblercheck報錯解決方式
一、 修改/etc/cobbler/settings文件中的server參數的值爲提供cobbler服務的主機相應的IP地址或主機名,如172.16.100.15;
二、 修改/etc/cobbler/settings文件中的next_server參數的值爲提供PXE服務的主機相應的IP地址,如172.16.100.16;
三、 若是當前節點能夠訪問互聯網,執行「 cobbler get-loaders」命令便可;不然, 須要安裝syslinux程序包,然後複製/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目錄中;
四、執行「 chkconfig rsync on」命令便可;
五、 註釋/etc/debmirror.conf文件中的「 @dists=」sid」;」一行;
六、 註釋/etc/debmirror.conf文件中的「@arches=」i386」;」一行;
七、 執行「 openssl passwd -1 -salt $(openssl rand -hex 4)」生成密碼,並用其替換/etc/cobbler/settings文件中default_password_crypted參數的值;
八、 執行「 yum install cman fence-agents」命令安裝相應的程序包便可.


4、配置及啓動cobbler所依賴的各服務

         cobbler的運行依賴於dhcp、tftp、rsync及dns服務。其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler自帶的tftp功能提供;rsync由rsync程序包提供;dns可由bind提供,也可由dnsmasq提供。

        cobbler可自行管理這些服務中的部分甚至是所有,但須要配置/etc/cobbler/settings文件中的「manage_dhcp」、「manage_tftpd」、「manage_rsync」和「manage_dns」分別進行定義。另外,因爲

每種服務都有着不一樣的實現方式,如若須要進行自定義,須要經過修改/etc/cobbler/modules.conf配置文件中各服

務的模塊參數的值來實現。

       本文采用了獨立管理的方式,即不經過cobbler來管理這些服務。

 一、dhcp服務

# yum install -y dhcp
 定義好所需的「subnet」及其它參數或選項,然後啓動dhcpd守護進程便可。本示例中所用的dhcpd
 的配置以下所示:
[root@centos7_1 ~]# cp/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@centos7_1 ~]# vim/etc/dhcp/dhcpd.conf
subnet 192.168.10.0 netmask 255.255.255.0 {
 range 192.168.10.100 192.168.10.110;
 option domain-name-servers 172.16.0.1;
 option routers 192.168.10.1;
 default-lease-time 600;
 max-lease-time 7200;
  filename"pxelinux.0";
 next-server 192.168.10.10;
}
接着使用從新啓動服務便可
# systemctl restart dchpd


二、TFTP服務

  [root@centos7_1~]# vim /etc/xinetd.d/tftp
    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
    }
  [root@centos7_1~]# systemctl restart tftp.socket


5、配置Cobbler

    使cobbler變得可用的第一步爲定義distro,其能夠經過爲其指定外部的安裝引導內核及ramdisk文件的方式實現。而若是已將有完整的系統安裝樹(如centos7的安裝鏡像)則推薦使用import直接導入的方式。

    例如,對於已經掛載至/mnt/dvd/目錄的centos7的安裝鏡像,則能夠了使用相似以下命令進行導入。

[root@centos7_1 ~]# mount /dev/sr0  /mnt/dvd/
[root@centos7_1 ~]# cobbler import--name="Centos7-x86_64" --path=/mnt/dvd 
task started: 2017-01-01_213654_import
task started (id=Media import, time=SunJan  1 21:36:54 2017)
Found a candidate signature: breed=redhat,version=rhel6
Found a candidate signature: breed=redhat,version=rhel7
Found a matching signature: breed=redhat,version=rhel7
Adding distros from path/var/www/cobbler/ks_mirror/Centos7-x86_64:
creating new distro: Centos7-x86_64
trying symlink:/var/www/cobbler/ks_mirror/Centos7-x86_64 ->/var/www/cobbler/links/
Centos7-x86_64
creating new profile: Centos7-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into/var/www/cobbler/ks_mirror/Centos7-x86_64 for Centos7-x86_64
processing repo at :/var/www/cobbler/ks_mirror/Centos7-x86_64
need to process repo/comps:/var/www/cobbler/ks_mirror/Centos7-x86_64
looking for/var/www/cobbler/ks_mirror/Centos7-x86_64/repodata/*comps*.xml
Keeping repodata as-is:/var/www/cobbler/ks_mirror/Centos7-x86_64/repodata
*** TASK COMPLETE ***
#可以使用「cobbler distrolist」 列出全部的distro
[root@centos7_1 ~]# cobbler distro list 
  Centos7-x86_64
[root@centos7_1 ~]#

    若是有kickstart文件,也可使用「—kickstart=/path/to/kickstart_file」進行導入,所以import會自動爲導入的distro生成一個profile。但因生成的kickstart適用咱們的實際生產要求因此kickstart因此咱們要作出必定的修改才能夠。

 

 

一、管理profile

cobble使用profile來爲特定的需求類別提供所須要安裝配置,即在distro的基礎之上經過提供kickstart文件來生成一個特定的系統安裝配置。distro的profile能夠出如今pxe的引導菜單中做爲安裝的選擇之一。

所以,若是須要爲前面建立的centos7-x86_64這個distro提供一個可引導安裝條目,其用到的kickstart文件爲/var/lib/cobbler/kickstarts/ks.cfg ,則可經過以下命令實現。

[root@centos7_1 ~]# cp ks.cfg  /var/lib/cobbler/kickstarts/
[root@centos7_1 ~]# cobbler profile add--name= Centos7-mini-x86_64 \
      --distro=Centos7-x86_64\ --kickstart=/var/lib/cobbler/kickstarts/ks.cfg
#可以使用「cobbler profilelist」查看已經建立的profile。
[root@centos7_1 ~]# cobbler profile  list
  Centos7-mini-x86_64
  Centos7-x86_64
[root@centos7_1 ~]#


至此即可實現自動化安裝操做系統。


 wKioL1iNWs6RQOydAAA-epq-IUo414.jpg

6、配置cobble_web

一、配置cobbler_web的認證功能

cobbler_web支持多種認證方式,如authn_configfile 、authn_ldap或authn_pam等,默認authn_denyall,即拒絕全部用戶登陸,下面說兩種認證用戶登陸cobbler_web的方式。

 二、使用authn_pam模塊認證cobbler_web用戶

         使用authn_pam模塊認證cobbler_web用戶

     首先修改modules中[authentication]段的module參數的值爲authn_pam。

     接着添加系統用戶,用戶名和密碼按需設定便可, 例以下面的命令所示

     #useradd cblradmin

    # echo 'cblrpass' | passwd --stdincblradmin

三、使用authn_configfile模塊認證cobbler_web用戶

     首先修改modules.conf中[authentication]段的module參數的值爲authn_configfile。

     接着建立其認證文件/etc/cobbler/users.digest, 並添加所需的用戶便可,須要注意的是,添加第一個用戶時, 須要爲htdigest命令使用「 -c」選項, 後續添加其餘用戶時不能再使用; 另外, cobbler_web的realm只能爲Cobbler。 以下所示。

     #htdigest -c /etc/cobbler/users.digest Cobbler cblradmin

訪問http://ip/cobbler_web便可實現web方式配置cobbler

wKiom1iNW2nh-4e7AAAsNq3qRYM252.jpg

 

四、centos7配置cobbler-web時問題

    在訪問http://192.168.10.10/cobbler_web時。瀏覽器報錯、

wKioL1iNW5Hxa-BgAAAbVML68BQ073.jpg

    解決方法1:

         使用https訪問即 https://192.168.10.10/cobbler_web

    解決方法2:

  [root@centos7_1~]# vim /etc/httpd/conf.d/cobbler_web.conf
   將如下配置在配置文件內的註釋掉:(全部)
   #  <IfModule mod_ssl.c>
   #    SSLRequireSSL
   # </IfModule>
相關文章
相關標籤/搜索