自动注册 Terraform 创建的客户端
Terraform 创建的新客户端可以自动注册到 SUSE Multi-Linux Manager 中。可以通过以下两种方式来完成注册:
-
cloud-initbased registration -
基于 remote-exec 置备器的注册
1. cloud-init Based Client Registration
Registering by leveraging cloud-init is the preferred way of automatic registering of the newly created virtual machines. This solution avoids configuring an SSH connection to the host. It can also be used regardless of the tool used for client creation.
User can pass the set of user data when deploying the image with Terraform, to automatically register the machine to SUSE Multi-Linux Manager. user_data is run only once at bootstrap, and only the first time the machine is started.
Before using cloud-init to register clients, the user must configure:
-
引导脚本。有关详细信息,请参见 使用引导脚本注册客户端。
-
激活密钥。有关详细信息,请参见 激活密钥。
The following command will download the bootstrap script and register the new machine when it is created. It should be added to the cloud-init configuration:
curl -s http://hub-server.tf.local/pub/bootstrap/bootstrap-default.sh | bash -s
|
Any time |
For more information about cloud-init on AWS, see https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/cloudinit_config.
For a cloud-init example, see https://registry.terraform.io/providers/hashicorp/cloudinit/latest/docs/data-sources/cloudinit_config#example-usage.
2. remote-exec Provisioner Based Registration
The second solution for automatic registering of the newly created virtual machines uses Terraform’s remote-exec provisioner.
remote-exec provisioner interacts with the newly created machines. It opens an SSH connection and can run commands on that machine.
|
When using |
其他要求与使用cloud-init Based Client Registration时相同:
-
引导脚本。有关详细信息,请参见 使用引导脚本注册客户端。
-
激活密钥。有关详细信息,请参见 激活密钥。
下面的命令会下载引导脚本并在新虚拟机创建后注册该虚拟机。应将此命令定义为要运行的远程命令:
curl -s http://hub-server.tf.local/pub/bootstrap/bootstrap-default.sh | bash -s
For more information about remote-exec provisioner, see https://www.terraform.io/docs/provisioners/remote-exec.html.