首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

使用 Cobbler 自动化和管理系统安装(3)

使用 Cobbler 自动化和管理系统安装(3)

创建配置文件下一步是创建配置文件。对于自动安装,使用 kickstart 模板特性指定一个 kickstart 文件。创建一个基于 /var/lib/cobbler/kickstarts 中的文件的简单 kickstart。然后,在 %packages 一节中,定义变量 $desktop_pkg_group,该变量在后面会被替换来确定安装哪些桌面包。清单 4 显示了 kickstart 文件的内容:
清单 4. kickstart 文件的内容
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
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Run the Setup Agent on first boot
firstboot --disable
# Activate X
xconfig --startxonboot
# Use network installation
url --url=$tree
# additional repostories get added here
$yum_repo_stanza
# Reboot after installation
reboot
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  America/New_York
# Root password
rootpw --iscrypted $default_password_crypted
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

%packages
@base
@base-x
firefox
flash-plugin
$desktop_pkg_group
%end

%post
# create a default user to log in X
useradd desktop-user
passwd -d desktop-user

# adds the yum repositories to the installed system
$yum_config_stanza
# cobbler final steps
$SNIPPET('kickstart_done')
%end




$ 开头的变量替换为 Cheetah 程序(参阅 ),Cobbler 使用该程序处理其模板。如果熟悉 Cheetah 模板,那么规则都是一样的。如需了解有关内部 Cobbler 变量的更多信息,比如 $yum_config_stanza,请查阅 /var/lib/cobbler/kickstarts 中的可用 kickstart。
创建该文件后,将其复制到 /var/lib/cobbler/kickstarts(如果不这么做,Cobbler 可能无法使用它)。Cobbler 知道 $desktop_pkg_group 的值,因为您在创建配置文件时已使用 --ksmeta 选项对其定义过。使用此选项,可确定在替换 kickstart 模板中的一个变量时要使用的值。清单 5 中的命令创建了 Xfce 和 GNOME 配置文件:
清单 5. 创建 Xfce 和 GNOME 配置文件的命令
1
2
3
4
5
6
7
8
9
cobbler profile add --name=Fedora17-xfce \
                    --ksmeta='desktop_pkg_group=@xfce-desktop' \
                    --kickstart=/var/lib/cobbler/kickstarts/example.ks \
                    --parent=Fedora17-x86_64
cobbler profile add --name=Fedora17-gnome \
                    --ksmeta='desktop_pkg_group=@gnome-desktop' \
                    --kickstart=/var/lib/cobbler/kickstarts/example.ks \
                    --parent=Fedora17-x86_64
cobbler profile report




--parent 参数告诉这些配置文件继承 Fedora 配置文件。这些配置文件使用 Fedora 发行版和额外的 Flash-plugin 存储库。要确保一切设置都是正确的,可在处理之后验证 kickstart 内容。结果类似于清单 6:
清单 6. 验证 kickstart 内容
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
cobbler profile getks --name=Fedora17-xfce

# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Run the Setup Agent on first boot
firstboot --disable
# Activate X
xconfig --startxonboot
# Use network installation
url --url=http://192.168.122.1/cblr/links/Fedora17-x86_64
# additional repostories get added here
repo --name=Flash-plugin --baseurl=http://192.168.122.1/cobbler/repo_mirror/Flash-plugin
repo --name=source-1 --baseurl=http://192.168.122.1/cobbler/ks_mirror/Fedora17-x86_64

# Reboot after installation
reboot
# System keyboard
keyboard us
# System language
lang en_US
# System timezone
timezone  America/New_York
# Root password
rootpw --iscrypted $1$mF86/UHC$WvcIcX2t6crBz2onWxyac.
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart

%packages
@base
@base-x
firefox
flash-plugin
@xfce-desktop
%end

%post
# create a user we can use to log on X
useradd desktop-user
passwd -d desktop-user

# adds the yum repositories to the installed system
wget "http://192.168.122.1/cblr/svc/op/yum/profile/Fedora17-xfce" \
   --output-document=/etc/yum.repos.d/cobbler-config.repo

# cobbler final steps


wget "http://192.168.122.1/cblr/svc/op/ks/profile/Fedora17-xfce" -O /root/cobbler.ks
wget "http://192.168.122.1/cblr/svc/op/trig/mode/post/profile/Fedora17-xfce" -O /dev/null
%end




变量 $dekstop_pkg_group 已被正确替换为 @xfce-desktop,它告诉 Anaconda 安装程序安装 Xfce 桌面包分组。
返回列表