自动安装配置文件
在 SUSE Multi-Linux Manager 中,您可以使用两种不同的配置文件,具体取决于您要安装的客户端的操作系统:
-
对于 SUSE Linux Enterprise 或 openSUSE 客户端,请使用 AutoYaST。
-
对于 Red Hat Enterprise Linux 客户端,请使用 Kickstart。
自动安装配置文件决定了如何安装操作系统。例如,您可以指定更多要传递给安装程序的内核参数。
配置文件最重要的部分是自动安装文件。当您手动执行安装操作时,必须向安装程序提供相关信息,例如分区配置、网络配置信息以及用户详细信息等。自动安装文件是一种以脚本形式提供此类信息的方式。这类文件有时也被称为应答文件。
如果您要安装具有不同操作系统的客户端,可以使用 AutoYaST 和 Kickstart 配置文件。
-
有关如何声明配置文件的信息,请参见声明配置文件
-
有关 AutoYaST 配置文件的信息,请参见 AutoYaST 配置文件。
-
有关 Kickstart 配置文件的信息,请参见 Kickstart 配置文件。
配置文件中包含的自动安装文件可以包含变量和代码段。有关变量和代码段的信息,请参见模板语法。
1. 声明配置文件
准备好自动安装文件和发行套件后,您可以创建配置文件来管理 SUSE Multi-Linux Manager 服务器上的自动安装。配置文件会决定如何安装您选择的此发行套件。创建配置文件的其中一个方式是上载 AutoYaST 或 Kickstart 文件。或者,您也可以使用 Web UI 向导(仅针对 Kickstart)。
-
在 SUSE Multi-Linux Manager Web UI 中,导航到。
-
单击 上载 Kickstart/AutoYaST 文件。
-
In the
Labelfield, type a name for the profile. Do not use spaces. -
In the
Autoinstall Treefield, select the autoinstallable distribution to use for this profile. -
In the
Virtualization Typefield, select the type of virtualization to use for this profile, or selectNoneif you do not want to use this profile to create a new virtual machine. -
Copy the contents of your autoinstallation file into the
File Contentsfield, or upload the file directly using theFile to Uploadfield.有关此处要包含的细节的详细信息,请参见 AutoYaST 配置文件 或 Kickstart 配置文件。
-
单击 创建 以创建配置文件。
-
在 SUSE Multi-Linux Manager Web UI 中,导航到。
-
单击 创建 Kickstart 配置文件。
-
In the
Labelfield, type a name for the profile. Do not use spaces. -
In the
Base Channelfield, select the base channel to use for this profile. This field is populated from the distributions available. If the base channel you need is not available, check that you have created the distribution correctly. -
In the
Virtualization Typefield, select the type of virtualization to use for this profile, or selectNonefor no virtualization. -
单击 下一步。
-
In the
Distribution File Locationtype the path to the installation media installed on the SUSE Multi-Linux Manager Server. -
单击 下一步。
-
提供客户端上 root 用户的口令。
-
单击 完成。
-
查看新配置文件的细节,并视需要进行自定义。
When you are creating your autoinstallation profile, you can check Always use the newest Tree for this base channel. This setting allows SUSE Multi-Linux Manager to automatically pick the latest distribution that is associated with the specified base channel. If you add new distributions later, SUSE Multi-Linux Manager uses the most recently created or modified.
Changing the Virtualization Type usually requires changes to the profile bootloader and partition options. This can overwrite your customization. Verify new or changed settings before saving them, by navigating to the Partitioning tab.
来自发行套件和配置文件的内核选项会进行合并。
您可以更改自动安装配置文件的细节和设置,方法是导航到,然后单击要编辑的配置文件的名称。或者,可导航到,选择要置备的客户端,然后导航到子选项卡。
2. AutoYaST 配置文件
An AutoYaST profile consists of a Label that identifies the profile, an Autoinstall Tree that points to an autoinstallable distribution, various options, and, most importantly, an AutoYaST installation file.
AutoYaST 安装文件是一个 XML 文件,用于向 AutoYaST 安装程序提供指示。AutoYaST 将其称为“控制文件”。有关 AutoYaST 安装文件的完整语法,请参见 https://doc.opensuse.org/projects/autoyast/#cha-configuration-installation-options。
SUSE provides templates of AutoYaST installation files that you can use as a starting point for your own custom files. You will find the templates at https://github.com/SUSE/manager-build-profiles in the AutoYast directory. Each of these profiles requires you to set some variables before you use it. Check the README file included with the script to determine which variables you need. For more information about using variables in AutoYaST scripts, see Variables.
|
提供的 AutoYaST 模板未设置任何用户口令。建议您配置 root 帐户及其他用户帐户并设置口令,或采用其他身份验证方式。有关 AutoYaST 配置文件中用户帐户的详细信息,请参见 https://doc.opensuse.org/projects/autoyast/#Configuration-Security-users-and-groups。 |
在 AutoYaST 安装文件中,用于通过 SUSE Multi-Linux Manager 安装的最重要的部分如下:
-
<add-on>allows to add child channels to the installation. For an example, see https://doc.opensuse.org/projects/autoyast/#Software-Selections-additional. -
<general>$SNIPPET('spacewalk/sles_no_signature_checks')</general>disables signature checks -
<software>allows to specify product for the Unified Installer-
请参见 https://doc.opensuse.org/projects/autoyast/#CreateProfile-Software,其中包含“<software>”示例
-
-
<init-scripts config:type="list">$SNIPPET('spacewalk/minion_script')</init-scripts>allows the client to register to SUSE Multi-Linux Manager as a Salt client.
有关 AutoYaST 的详细信息,请参见 https://doc.opensuse.org/projects/autoyast/。
近期一个基于 Salt 的方案 Yomi 可替代 AutoYaST。有关 Yomi 的信息,请参见 使用 Yomi 安装。
3. Kickstart 配置文件
Kickstart 配置文件提供了大量配置选项。要创建这些配置文件,您可以上载它们,也可以使用专用向导。
Kickstart 配置文件允许您使用文件保留列表。如果您有许多自定义配置文件位于要使用 Kickstart 重新安装的客户端上,则可以将它们保存为列表,并将该列表与 Kickstart 配置文件相关联。
-
在 SUSE Multi-Linux Manager Web UI 中,导航到,然后单击 创建文件保留列表。
-
输入适当的标签,并列出要保存的所有文件和目录的绝对路径。
-
单击 创建列表。
-
将该文件保留列表包含到 Kickstart 配置文件中。
-
导航到,选择要编辑的配置文件,转到子选项卡,然后选择要包含的文件保留列表。
|
File preservation lists are limited to a total size of 1 MB. Special devices like |
有关 Kickstart 的详细信息,请参见 Red Hat 文档。
4. 模板语法
安装文件的部分内容在安装过程中会被替换。变量会被替换为相应的单个值,代码段会被替换为整段文本。转义符或转义部分不会被替换。
名为 Cheetah 的模板引擎允许 Cobbler 进行这些替换。利用此机制,您在重新安装大量系统时就无需为每个系统手动创建配置文件。
You can create autoinstallation variables and code snippets within the SUSE Multi-Linux Manager Web UI. Within a profile, the Autoinstallation File tab allows you to see the result of the substitutions.
4.1. 变量
Autoinstallation variables can be used to substitute values into Kickstart and AutoYaST profiles. To define a variable, from the profile, navigate to the Variables subtab, and create a name=value pair in the text box.
For example, you could create a variable that holds the IP address of the client, and another that holds the address of its gateway. Those variables can then be defined for all the clients installed from the same profile. To do that, add these lines to the Variables text box:
ipaddr=192.168.0.28 gateway=192.168.0.1
To use the variable, prepend a $ sign in the profile to substitute the value. For example, the network part of a Kickstart file may look like the following:
network --bootproto=static --device=eth0 --onboot=on --ip=$ipaddr \ --gateway=$gateway
The $ipaddr is resolved to 192.168.0.28, and the $gateway to 192.168.0.1.
在安装文件中,变量使用层次结构。系统变量优先于配置文件变量,而配置文件变量优先于发行套件变量。
4.2. 代码段
SUSE Multi-Linux Manager 附带了大量预定义的代码段。导航到,以查看现有代码段列表。
Use a snippet by inserting the $SNIPPET() macro in your autoinstallation file. For example, in Kickstart:
$SNIPPET('spacewalk/redhat_register_using_salt')
或者,在 AutoYaST 中,插入该宏:
<init-scripts config:type="list">
$SNIPPET('spacewalk/minion_script')
</init-scripts>
宏会经过 Cobbler 的分析,并会替换为代码段的内容。您还可以存储自己的代码段,以供日后在自动安装文件中使用。单击 创建代码段 以创建新代码段。
下面的示例设置了通用硬盘分区配置的 Kickstart 代码段:
clearpart --all part /boot --fstype ext3 --size=150 --asprimary part / --fstype ext3 --size=40000 --asprimary part swap --recommended part pv.00 --size=1 --grow volgroup vg00 pv.00 logvol /var --name=var vgname=vg00 --fstype ext3 --size=5000
下面是使用该代码段的一个示例:
$SNIPPET('my_partition')
4.3. 转义
If the autoinstallation file contains shell script variables like $(example), the content needs to be escaped with a backslash: \$(example). Escaping the $ symbol prevents the templating engine from evaluating the symbol as an internal variable.
Text blocks such as code fragments or scripts can be escaped by wrapping them with the \#raw and \#end raw directives. For example:
#raw
#!/bin/bash
for i in {0..2}; do
echo "$i - Hello World!"
done
#end raw
Any line with a # symbol followed by a whitespace is treated as a comment and is therefore not evaluated. For example:
# start some section(此为注释) echo "Hello, world" # end some section(此为注释)