• cobbler配置解析


    1、Cobbler命令说明:

    命令名称

    命令用途

    cobbler check

    检查cobbler配置

    cobbler list

    列出所有的cobbler元素

    cobbler report

    列出元素的详细信息

    cobbler distro

    查看导入的发行版系统信息

    cobbler system

    查看添加的系统信息

    cobbler profile

    查看配置信息

    cobbler sync

    同步Cobbler配置,更改配置最好都要执行下

    cobbler reposync

    同步yum仓库

    命令参考

    cobbler --help

    cobbler distro --help 

    cobbler distro add --help

    2、Cobbler配置文件说明

    Cobbler配置文件存放在/etc/cobbler下

    配置文件名称

    作    用

    /etc/cobbler/settings

    Cobbler主配置文件

    /etc/cobbler/users.digest

    用于web访问的用户名密码配置文件

    /etc/cobbler/modules.conf

    模块配置文件

    /etc/cobbler/users.conf

    Cobbler WebUI/Web 服务授权配置文件

    /etc/cobbler/iso/

    Buildiso 模板配置文件

    /etc/cobbler/power

    电源配置文件

    /etc/cobbler/pxe

    Pxeprofile配置模板

    /etc/cobbler

    此目录也包含rsync、dhcp、dns、pxe、dnsmasq等服务的模板配置文件

       

    3、系统镜像数据目录/var/www/cobbler

    导入的系统发行版,repos镜像和kickstart文件都放置在/var/www/cobbler目录下。确保/var目录有足够的空间来存储这些文件。

    目录名称

    作    用

    /var/www/cobbler/images/

    存储所有导入发行版的Kernel和initrd镜像用于远程网络启动

    /var/www/cobbler/ks_mirror/

    存储导入的发行版系统数据

    /var/www/cobbler/repo_mirror/

    仓库存储目录

    /var/log/cobbler

    Cobbler日志文件 cobbler.log install.log

    4、Cobbler数据目录/var/lib/cobbler

    此目录存储和Cobbler profiles、systems、distros相关的配置。

    目录名称

    作    用

    /var/lib/cobbler/config/

    存放distros、repos、systems和profiles等信息配置文件,一般都是json文件

    /var/lib/cobbler/snippets/

    存放ks文件可以导入的脚本小片段,值得研究

    /var/lib/cobbler/triggers

    存放用户定义的cobbler 命令

    /var/lib/cobbler/kickstarts/

    存放kickstart配置文件

    5、相关日志文件

    web日志存放点

    /var/log/httpd/access_log

    /var/log/httpd/error_log

    /var/log/httpd/ssl_access_log

    /var/log/httpd/ssl_error_log

    Cobbler日志

    /var/log/cobbler/cobbler.log

    /var/log/cobbler/install.log

    可以通过Cobbler日志可以获取系统的安装状态

    三、Cobbler 常用命令汇总

    1.导入镜像文件

    命令:cobbler import --path=镜像路径 -- name=安装引导名 --arch=32位或64位

    参数:

    • path 是镜像所挂载的目录
    • name 是导入到cobbler里面显示的名字
    • arch 是32位系统还是64位系统

    2.导入kickstart文件

    命令:cobbler profile add --name=list名 --distro=镜像 --kickstart=路径

    参数:

    • name是表示添加的ks 的名字,用cobbler report可以看到这个名字
    • distro 是用哪个镜像,list的distros里面选择一个,需要版本相对应
    • kickstart 是具体的 ks 文件路径

    3.同步DHCP、HTTPD

    命令:cobbler sync

    注,每次修改完dhcp.template之类的配置文件需要执行一次使其生效。

    4.查看Cobbler列表

    命令:cobbler list

    注,列出Cobbler所有的元素。

    5.删除相关列表

    命令:cobbler distro/profile remove --name=要删除的引导文件名

    • 删除指定 distro , 也就是镜像
    • 删除指定的 profile 文件,也就是 ks

    四、Cobbler 各种目录说明(注,这里只介绍重点的文件或目录 )

    1.cobbler配置文件目录/etc/cobbler

    [root@node2 cobbler]# ls /etc/cobbler/

    auth.conf    cobblerd.service    dnsmasq.template    mongodb.conf  rsync.exclude    users.conf 

    cheetah_macros  cobbler_web.conf    import_rsync_whitelist named.template rsync.template   users.digest 

    cobbler_bash   completions       iso           power      secondary.template version 

    cobbler.conf   dhcp.template      ldap          pxe       settings      zone.template 

    cobblerd_rotate distro_signatures.json modules.conf      reporting    tftpd.template   zone_templates

    • /etc/cobbler/settings cobbler主配置文件
    • /etc/cobbler/iso/ iso模板配置文件
    • /etc/cobbler/pxe pxe模板文件
    • /etc/cobbler/power 电源的配置文件
    • /etc/cobbler/users.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模块配置文件

    2.cobbler数据目录/var/lib/cobbler

    1

    2

    3

    4

    5

    6

    7

    [root@node2 cobbler]# ls /var/lib/cobbler/

    config distro_signatures.json kickstarts loaders lock scripts snippets triggers web.ss

    [root@node2 config]# ls

    distros.d files.d images.d mgmtclasses.d packages.d profiles.d repos.d systems.d

    [root@node2 loaders]# ls

    COPYING.elilo   COPYING.yaboot grub-x86_64.efi menu.c32  README 

    COPYING.syslinux elilo-ia64.efi grub-x86.efi   pxelinux.0 yaboot

    • /var/lib/cobbler/config/ 用于存放distros、systems、profiles等信息配置文件
    • /var/lib/cobbler/triggers 用于存放用户定义的cobbler 命令
    • /var/lib/cobbler/kickstarts/ 默认存放kickstart文件
    • /var/lib/cobbler/loaders 存放的各种引导程序

    3.镜像数据目录/var/www/cobbler

    1

    2

    [root@node2 cobbler]# ls

    aux images ks_mirror links localmirror pub rendered repo_mirror svc

    • /var/www/cobbler/ks_mirror/ 导入的发行版系统的所有数据
    • /var/www/cobbler/images/ 导入发行版的Kernel和initrd镜像用于远程网络启动
    • /var/www/cobbler/repo_mirror/ yum仓库存储目录

    4.日志目录 /var/log/cobbler/

    1

    2

    3

    4

    5

    [root@node2 cobbler]# ls

    anamon cobbler.log install.log kicklog syslog tasks

    [root@node2 cobbler]# cat install.log

    profile  CentOS-5.5-x86_64  192.168.18.222  start  1384219313.49 

    profile  CentOS-5.5-x86_64  192.168.18.222  stop  1384219512.05

    • /var/log/cobbler/install.log 客户端的安装系统日志
    • /var/log/cobbler/cobbler.log cobbler日志

    下面我们来具体看一下sample.ks的内容。

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    31

    32

    33

    34

    35

    36

    37

    38

    39

    40

    41

    42

    43

    44

    45

    46

    47

    48

    49

    50

    51

    52

    53

    54

    55

    56

    57

    58

    59

    60

    61

    62

    63

    64

    65

    66

    67

    68

    [root@node2 ~]# cat /var/lib/cobbler/kickstarts/sample.ks

    #platform=x86, AMD64, or Intel EM64T

    # System authorization information

    auth --useshadow --enablemd5 #用户登录认证

    # System bootloader configuration

    bootloader --location=mbr #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 #默认的yum仓库

    # Network information

    $SNIPPET('network_config') 

    # Reboot after installation

    reboot #安装完成后重启

    #Root password

    rootpw --iscrypted $default_password_crypted #密码是我们/etc/cobbler/settings设置密码

    # SELinux configuration

    selinux --disabled #默认关闭selinux

    # 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 #默认清空所有的mbr

    # Allow anaconda to partition the system as needed

    autopart #默认自动分区

    #下面就是Cobbler自定执行的一些脚本,我就不解释了。

    %pre

    $SNIPPET('log_ks_pre')

    $SNIPPET('kickstart_start')

    $SNIPPET('pre_install_network_config')

    # Enable installation monitoring

    $SNIPPET('pre_anamon')

    %packages

    $SNIPPET('func_install_if_enabled')

    $SNIPPET('puppet_install_if_enabled')

    %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('puppet_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

    一个ks.cfg示例:

    #platform=x86, AMD64, or Intel EM64T
    #version=DEVEL
    # Firewall configuration
    firewall --disabled
    # Install OS instead of upgrade
    install
    # Use network installation
    url --url="http://10.1.1.223/cobbler/ks_mirror/CentOS-6.4-x86_64/"
    # Root password
    rootpw --iscrypted $1$KIGcVL58$htt.2om3G9elvGX3hYHab1
    # System authorization information
    auth  --useshadow  --passalgo=sha512
    # Use text install
    text
    # System keyboard
    keyboard us
    # System language
    lang en_US
    # SELinux configuration
    selinux --disabled
    # Do not configure the X Window System
    skipx
    # Installation logging level
    logging --level=info
    # Reboot after installation
    reboot
    # System timezone
    timezone  Asia/Shanghai
    # Network information
    network  --bootproto=dhcp --device=em1 --onboot=on
    # System bootloader configuration
    bootloader --location=mbr
    # Partition clearing information
    #clearpart --all --initlabel
    zerombr

     

     

    %include /tmp/partition.ks
    %pre
    #!/bin/sh

    act_mem=`cat /proc/meminfo | grep MemTotal | awk '{printf("%d",$2/1024)}'`
    cat >> /tmp/partition.ks  << END
    clearpart --all
    part /boot --size=500  --fstype=ext4 
    part swap  --fstype=swap  --size=${act_mem}  
    part / --size=1 --grow

    END

    %end

    # Disk partitioning information
    #clearpart --all
    #part swap --fstype="swap" --size=${act_mem}
    #part /boot --asprimary --fstype="ext4" --size=500
    #part / --fstype="ext4" --grow --size=1

     

    %packages
    @chinese-support
    @development
    @ruby-runtime
    git
    -ibus-table-cangjie
    -ibus-table-erbi
    -ibus-table-wubi

    %end

    %post

    #!/bin/sh
    hostip=`ifconfig em1 | sed -n '/inet /{s/.*addr://;s/ .*//;p}'`
    /bin/sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-em1
    /bin/sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=static/' /etc/sysconfig/network-scripts/ifcfg-em1
    /bin/sed -i  '/BOOTPROTO=/a IPADDR='${hostip}' NETMASK=255.255.255.0 GATEWAY='10.1.4.1''  /etc/sysconfig/network-scripts/ifcfg-em1
    service network restart
    %end

  • 相关阅读:
    第一节 软件测试概述(2)
    第一节 软件测试概述(1)
    Sql语句,查询效率
    Js cdn 学习
    Java内部类详解
    UML用例图
    UML类图几种关系的总结
    JFinal框架_定时触发程序
    利用EXCEL函数LINEST进行统计学中的回归分析
    Windows 10 64 Bit 编译安装 PyLucene 8.3.0
  • 原文地址:https://www.cnblogs.com/wjoyxt/p/4588715.html
Copyright © 2020-2023  润新知