使用引导脚本注册客户端
1. 简介
使用引导脚本注册客户端可让您控制参数,并且便于您在需要时一次性注册大量客户端。
要使用引导脚本注册客户端,建议您先创建一个模板引导脚本,之后可以复制和修改该脚本。注册客户端时,您创建的引导脚本会在客户端上执行,并会确保所有必要的软件包都部署到该客户端。引导脚本中的某些参数确保能够使用激活密钥和 GPG 密钥将客户端系统指派到它的基础通道。
请务必仔细检查储存库信息,以确保其与基础通道储存库匹配。如果储存库信息未完全匹配,引导脚本将无法下载正确的软件包。
其他注意事项:
-
所有客户端都需要引导储存库。同步产品时,会自动在 SUSE Multi-Linux Manager 服务器上创建并重新生成该引导储存库。引导储存库包含用于在客户端上安装 Salt 的软件包,以及用于注册客户端的软件包。有关如何创建引导储存库的详细信息,请参见 引导储存库。
-
openSUSE Leap 15 和 SLE 15 默认使用 Python 3。必须为 openSUSE Leap 15 和 SLE 15 系统创建基于 Python 2 的引导脚本。如果您使用 Python 2 注册 Leap 15 或 SLE 15 系统,引导脚本将会失败。
|
从旧版 SUSE Multi-Linux Manager 迁移到新版本后,我们强烈建议在初始配置新系统之前重新生成引导脚本,以防出现任何潜在问题。 |
|
To access a shell inside the server container run |
2. Create a bootstrap script with mgr-bootstrap
The mgr-bootstrap command generates custom bootstrap scripts. A bootstrap script is used by SUSE Multi-Linux Manager client systems for simplifying their initial registration and configuration.
The arguments --activation-keys and --script, are the only mandatory arguments. On the SUSE Multi-Linux Manager Server, as root at the command line execute it with the mandatory arguments. Replace <ACTIVATION_KEY and <EDITED_NAME> with your values:
-
在 SUSE Multi-Linux Manager 容器主机的命令行中,以 root 用户身份运行以下命令进入服务器容器:
mgrctl term
-
执行以下命令(根据需要调整参数值)
mgr-bootstrap --activation-keys=<ACTIVATION_KEY> --script=bootstrap-<EDITED_NAME>.sh
The mgr-bootstrap command offers several other options, including the ability to set a specific hostname, set specific GPG keys, and set the registration method (salt-minion or salt-bundle).
|
For more information, see the mgr-bootstrap man page, or run mgr-bootstrap --help.
3. 从 Web UI 中创建引导脚本
您可以使用 SUSE Multi-Linux Manager Web UI 创建可编辑的引导脚本。
在 SUSE Multi-Linux Manager Web UI 中,导航到。
必填字段中会预填充从之前的安装步骤获得的值。有关每个设置的细节,请参见 引导脚本。
单击 更新 创建脚本。
The bootstrap script is generated and stored on the server in the
/srv/www/htdocs/pub/bootstrapdirectory. Alternatively, you can access the bootstrap script over HTTPS. Replace<example.com>with the host name of your SUSE Multi-Linux Manager Server:https://<example.com>/pub/bootstrap/bootstrap.sh
|
Do not disable SSL in your bootstrap script. Ensure that 有关自定义证书的详细信息,请参见 SSL 证书。 |
4. 编辑引导脚本
您可以复制和修改所创建的模板引导脚本,以对其进行自定义。要将引导脚本用于 SUSE Multi-Linux Manager,对其进行修改时至少需包含激活密钥。大多数软件包都是使用 GPG 签名的,因此系统上还需要有可信的 GPG 密钥才能安装这些软件包。
In this procedure, you need to know the exact name of your activation keys. Navigate to and, in the Tasks box, click Manage Activation Keys. All keys created for channels are listed on this page. You must enter the full name of the key you wish to use in the bootstrap script exactly as presented in the key field. For more information about activation keys, see 激活密钥.
在 SUSE Multi-Linux Manager 容器主机的命令行中,以 root 用户身份运行以下命令进入服务器容器:
mgrctl term在 SUSE Multi-Linux Manager 服务器上的命令行中,以 root 身份运行以下命令切换到引导目录:
cd /srv/www/htdocs/pub/bootstrap/创建并重命名用于每个客户端的两个模板引导脚本副本。
cp bootstrap.sh bootstrap-sles12.sh cp bootstrap.sh bootstrap-sles15.shOpen
bootstrap-sles15.shfor modification. Scroll down until you can see the text shown below. Ifexit 1exists in the file, comment it out by typing a hash or pound sign (#) at the beginning of the line. This activates the script. Enter the name of the key for this script in theACTIVATION_KEYS=field:echo "Enable this script: comment (with #'s) this block (or, at least just" echo "the exit below)" echo #exit 1 # can be edited, but probably correct (unless created during initial install): # NOTE: ACTIVATION_KEYS *must* be used to bootstrap a client machine. ACTIVATION_KEYS=1-sles15 ORG_GPG_KEY=
用户无需手动编辑脚本,只需在运行时传递以下环境变量即可:
ACTIVATION_KEYS:用于注册的激活密钥
ORG_GPG_KEY:GPG 密钥的路径或标识符
REACTIVATION_KEY:用于之前已注册的系统的重新激活密钥
MGR_SERVER_HOSTNAME:客户端要注册到的服务器或代理的主机名使用环境变量可实现运行时的动态输入,并让用户更轻松地在不同系统或环境中重复使用同一引导脚本。
完成后,保存该文件,然后对第二个引导脚本重复此过程。
|
By default, bootstrap script will try to install 有关详细信息,请参见 Salt 捆绑包。 |
5. 运行引导脚本来注册客户端
创建好脚本后,您便可以使用它来注册客户端。
在 SUSE Multi-Linux Manager 容器主机的命令行中,以 root 用户身份运行以下命令进入服务器容器:
mgrctl term在 SUSE Multi-Linux Manager 服务器上,切换到引导目录:
cd /srv/www/htdocs/pub/bootstrap/Run this command to execute the bootstrap script on the client; replace
EXAMPLE.COMwith the host name of your client:cat bootstrap-sles15.sh | ssh root@EXAMPLE.COM /bin/bash或者,在客户端上运行以下命令:
ACTIVATION_KEYS="17-someactivationkey" \ MGR_SERVER_HOSTNAME="proxy.example.com" \ ORG_GPG_KEY="mykey" \ REACTIVATION_KEY=my-reactivation-key \ curl -Sks https://server_hostname/pub/bootstrap/bootstrap.sh | /bin/bash如果您不需要覆盖任何值,完全可以省略环境变量:
curl -Sks https://server_hostname/pub/bootstrap/bootstrap.sh | /bin/bash
To avoid problems, make sure the bootstrap script is executed using
bash.此脚本会下载位于您先前创建的储存库目录下的所需依赖项。
脚本运行完成后,可以检查客户端是否已正确注册。打开 SUSE Multi-Linux Manager Web UI 并导航到 ,确保列出了新客户端。如果未列出该客户端,请在 SUSE Multi-Linux Manager Web UI 中导航到 ,检查是否接受了客户端密钥。
|
使用 SUSE Multi-Linux Manager 在客户端上安装新的软件包或更新时,会自动接受所有最终用户许可协议 (EULA)。要查看软件包 EULA,请打开 Web UI 中的软件包细节页面。 |