Automatic Registration of Clients Created by Terraform
New clients created by Terraform can be automatically registered to SUSE Manager. Registration can be achieved in two ways:
-
cloud-init based registration
-
remote execution provisioner based registration
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, in order to automatically register the machine to SUSE 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:
-
Bootstrap script. See Register Clients with a Bootstrap Script
-
Activation keys. See Activation Keys
This 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
Anytime |
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 |
The remaining requirements are the same as when using cloud-init based client registration
-
Bootstrap script. See Register Clients with a Bootstrap Script
-
Activation keys. See Activation Keys
This command will download the bootstrap script and register the new machine when it is created. It should be defined as the remote command to run:
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