Hi @jack0ne
First of all, our Terraform provider is moved under canonical. Therefore, you should fetch it from canonical/maas
rather than maas/maas
.
In addition, based on the Rancher provider documentation you need a custom cluster so that you can get the rancher2_cluster_v2.foo.cluster_registration_token.node_command
here.
When you do, you need to create proper cloud-init user data and add them to your maas_instance:
resource "maas_instance" "demo" {
deploy_params {
distro_series = "jammy"
user_data = data.template_cloudinit_config.config.rendered
}
}
data "template_cloudinit_config" "config" {
gzip = false
base64_encode = false
part {
filename = "init.sh"
content_type = "text/x-shellscript"
content = data.template_file.script.rendered
}
}
data "template_file" "script" {
template = file("${path.module}/templates/cloud_init.tpl")
vars = {
rancher_command = rancher2_cluster_v2.foo.cluster_registration_token.node_command
}
}
cat templates/cloud_init.tpl
#!/bin/bash
set -x
# echo Rancher command
echo "${rancher_command}"
It is up to you to decide what the contents of that cloud-init script should be.