nutanix / terraform-provider-nutanix

Terraform Nutanix Provider
https://www.terraform.io/docs/providers/nutanix/
Mozilla Public License 2.0
100 stars 112 forks source link

cloud init is a mess #634

Open davhdavh opened 1 year ago

davhdavh commented 1 year ago

Nutanix v2 api has this definition (https://nutanix:9440/api/nutanix/v2/api_explorer/index.html#!/vms/createVM):

  "vm_customization_config": {
    "datasource_type": "CONFIG_DRIVE_V2",
    "files_to_inject_list": [
      {
        "destination_path": "string",
        "source_path": "string"
      }
    ],
    "fresh_install": true,
    "userdata": "string",
    "userdata_path": "string"
  },

Nutanix v3 api has this definition:

cloud_init
object

If this field is set, the guest will be customized using cloud-init. Either user_data or custom_key_values should be provided. If custom_key_ves are provided then the user data will be generated using these key-value pairs.
meta_data
string

The contents of the meta_data configuration for cloud-init. This can be formatted as YAML or JSON. The value must be base64 encoded.
<= 32000 characters
user_data
string

The contents of the user_data configuration for cloud-init. This can be formatted as YAML, JSON, or could be a shell script. The value must be base64 encoded.
<= 128000 characters
custom_key_values
Generic key value pair

Generic key value pair used for custom attributes

Terraform has this guest_customization_cloud_init_user_data: - (Optional) The contents of the user_data configuration for cloud-init. This can be formatted as YAML, JSON, or could be a shell script. The value must be base64 encoded. guest_customization_cloud_init_meta_data - (Optional) The contents of the meta_data configuration for cloud-init. This can be formatted as YAML or JSON. The value must be base64 encoded. guest_customization_cloud_init_custom_key_values: - (Optional) Generic key value pair used for custom attributes in cloud init.

And it is all a mess.

  1. v3 api for meta_data despite the documentation does NOT allow yaml code, only json is allowed.
  2. meta_data also MUST follow the openstack, ie. uuid is a REQUIRED key. Code
  3. Unlike v2, v3 has no way to upload extra files, such as the any of the NETWORK files, Code. So you MUST have DHCP.
  4. guest_customization_cloud_init_custom_key_values does not work if guest_customization_cloud_init_user_data is set, but terraform operator will gladly try and get a dump of the entire user_data and meta_data fields, which may or may not contain some of your secrets.
davhdavh commented 1 week ago

status?