vatesfr / terraform-provider-xenorchestra

Xen Orchestra provider for Terraform
MIT License
150 stars 32 forks source link

The cloud-init example in the documentation does not work #123

Closed TheBeems closed 3 years ago

TheBeems commented 3 years ago

I have been playing around with the terraform provider for xenorchestra and wanted to use cloud-init to setup my vm's.

I found that the example given in the documentation does not work:

resource "xenorchestra_cloud_config" "demo" {
  name = "cloud config name"
  template = <<EOF
#cloud-init

runcmd:
 - [ ls, -l, / ]
 - [ sh, -xc, "echo $(date) ': hello world!'" ]
 - [ sh, -c, echo "=========hello world'=========" ]
 - ls -l /root
EOF
}

resource "xenorchestra_vm" "bar" {
  // ...
  cloud_config = xenorchestra_cloud_config.demo.template
  // ...
}

The culprit is the commentline #cloud-init

After changing this to #cloud-config, all worked fine. Took me a full hour to figure this out why the cloud-init wasn't working. I suggest to change the documentation into the following:

resource "xenorchestra_cloud_config" "demo" {
  name = "cloud config name"
  template = <<EOF
#cloud-config

runcmd:
 - [ ls, -l, / ]
 - [ sh, -xc, "echo $(date) ': hello world!'" ]
 - [ sh, -c, echo "=========hello world'=========" ]
 - ls -l /root
EOF
}

resource "xenorchestra_vm" "bar" {
  // ...
  cloud_config = xenorchestra_cloud_config.demo.template
  // ...
}
ddelnano commented 3 years ago

Thanks for spotting this @TheBeems. I opened up a PR to fix this discrepancy.