diff --git a/docs/resources/vm.md b/docs/resources/vm.md index bc1e66b..842fb18 100644 --- a/docs/resources/vm.md +++ b/docs/resources/vm.md @@ -29,22 +29,22 @@ This does not work in terraform since that is applied on Xen Orchestra's client ## Example Usage ```terraform -/* # cloud_config.tftpl file used by the cloudinit templating. #cloud-config hostname: ${hostname} fqdn: ${hostname}.${domain} package_upgrade: true -*/ +``` +```hcl # Content of the terraform files data "xenorchestra_pool" "pool" { - name_label = "pool name" + name_label = "pool name" } data "xenorchestra_template" "template" { - name_label = "Puppet agent - Bionic 18.04 - 1" + name_label = "Puppet agent - Bionic 18.04 - 1" } data "xenorchestra_network" "net" { @@ -56,69 +56,60 @@ resource "xenorchestra_cloud_config" "bar" { # Template the cloudinit if needed template = templatefile("cloud_config.tftpl", { hostname = "your-hostname" - domain = "your.domain.com" + domain = "your.domain.com" }) } resource "xenorchestra_vm" "bar" { - memory_max = 1073733632 - cpus = 1 - cloud_config = xenorchestra_cloud_config.bar.template - name_label = "Name" - name_description = "description" - template = data.xenorchestra_template.template.id - - # Prefer to run the VM on the primary pool instance - affinity_host = data.xenorchestra_pool.pool.master - network { - network_id = data.xenorchestra_network.net.id - } - - disk { - sr_id = "7f469400-4a2b-5624-cf62-61e522e50ea1" - name_label = "Ubuntu Bionic Beaver 18.04_imavo" - size = 32212254720 - } - - tags = [ - "Ubuntu", - "Bionic", - ] - - // Override the default create timeout from 5 mins to 20. - timeouts { - create = "20m" - } - - // Note: Xen Orchestra populates values within Xenstore and will need ignored via - // lifecycle ignore_changes or modeled in your terraform code - xenstore = { - key1 = "val1" - key2 = "val2" - } + memory_max = 1073733632 + cpus = 1 + cloud_config = xenorchestra_cloud_config.bar.template + name_label = "Name" + name_description = "description" + template = data.xenorchestra_template.template.id + + # Prefer to run the VM on the primary pool instance + affinity_host = data.xenorchestra_pool.pool.master + network { + network_id = data.xenorchestra_network.net.id + } + + disk { + sr_id = "7f469400-4a2b-5624-cf62-61e522e50ea1" + name_label = "Ubuntu Bionic Beaver 18.04_imavo" + size = 32212254720 + } + + tags = [ + "Ubuntu", + "Bionic", + ] + + // Override the default create timeout from 5 mins to 20. + timeouts { + create = "20m" + } + + // Note: Xen Orchestra populates values within Xenstore and will need ignored via + // lifecycle ignore_changes or modeled in your terraform code + xenstore = { + key1 = "val1" + key2 = "val2" + } } # vm resource that waits until its first network interface # is assigned an IP via DHCP resource "xenorchestra_vm" "vm" { + ... # Specify VM with two network interfaces network { - network_id = "7ed8998b-405c-40b5-b164-f9058efcf6b4" + ... expected_ip_cidr = "10.0.0.0/16" } network { - network_id = "b4cf8532-ae43-493b-9fc6-a6b456d16876" - } - # required arguments for xenorchestra_vm - cpus = 2 - disk { - sr_id = "7f469400-4a2b-5624-cf62-61e522e50ea1" - name_label = "Ubuntu Bionic Beaver 18.04_imavo" - size = 32212254720 + ... } - memory_max = 1073733632 - name_label = "Name" - template = data.xenorchestra_template.template.id } output "first-network-interface-ips" { diff --git a/examples/resources/xenorchestra_vm/resource.tf b/examples/resources/xenorchestra_vm/resource.tf index f04a41a..82fbc8a 100644 --- a/examples/resources/xenorchestra_vm/resource.tf +++ b/examples/resources/xenorchestra_vm/resource.tf @@ -1,19 +1,19 @@ -/* # cloud_config.tftpl file used by the cloudinit templating. #cloud-config hostname: ${hostname} fqdn: ${hostname}.${domain} package_upgrade: true -*/ +``` +```hcl # Content of the terraform files data "xenorchestra_pool" "pool" { - name_label = "pool name" + name_label = "pool name" } data "xenorchestra_template" "template" { - name_label = "Puppet agent - Bionic 18.04 - 1" + name_label = "Puppet agent - Bionic 18.04 - 1" } data "xenorchestra_network" "net" { @@ -25,69 +25,60 @@ resource "xenorchestra_cloud_config" "bar" { # Template the cloudinit if needed template = templatefile("cloud_config.tftpl", { hostname = "your-hostname" - domain = "your.domain.com" + domain = "your.domain.com" }) } resource "xenorchestra_vm" "bar" { - memory_max = 1073733632 - cpus = 1 - cloud_config = xenorchestra_cloud_config.bar.template - name_label = "Name" - name_description = "description" - template = data.xenorchestra_template.template.id + memory_max = 1073733632 + cpus = 1 + cloud_config = xenorchestra_cloud_config.bar.template + name_label = "Name" + name_description = "description" + template = data.xenorchestra_template.template.id - # Prefer to run the VM on the primary pool instance - affinity_host = data.xenorchestra_pool.pool.master - network { - network_id = data.xenorchestra_network.net.id - } + # Prefer to run the VM on the primary pool instance + affinity_host = data.xenorchestra_pool.pool.master + network { + network_id = data.xenorchestra_network.net.id + } - disk { - sr_id = "7f469400-4a2b-5624-cf62-61e522e50ea1" - name_label = "Ubuntu Bionic Beaver 18.04_imavo" - size = 32212254720 - } + disk { + sr_id = "7f469400-4a2b-5624-cf62-61e522e50ea1" + name_label = "Ubuntu Bionic Beaver 18.04_imavo" + size = 32212254720 + } - tags = [ - "Ubuntu", - "Bionic", - ] + tags = [ + "Ubuntu", + "Bionic", + ] - // Override the default create timeout from 5 mins to 20. - timeouts { - create = "20m" - } + // Override the default create timeout from 5 mins to 20. + timeouts { + create = "20m" + } - // Note: Xen Orchestra populates values within Xenstore and will need ignored via - // lifecycle ignore_changes or modeled in your terraform code - xenstore = { - key1 = "val1" - key2 = "val2" - } + // Note: Xen Orchestra populates values within Xenstore and will need ignored via + // lifecycle ignore_changes or modeled in your terraform code + xenstore = { + key1 = "val1" + key2 = "val2" + } } # vm resource that waits until its first network interface # is assigned an IP via DHCP resource "xenorchestra_vm" "vm" { + ... # Specify VM with two network interfaces network { - network_id = "7ed8998b-405c-40b5-b164-f9058efcf6b4" + ... expected_ip_cidr = "10.0.0.0/16" } network { - network_id = "b4cf8532-ae43-493b-9fc6-a6b456d16876" - } - # required arguments for xenorchestra_vm - cpus = 2 - disk { - sr_id = "7f469400-4a2b-5624-cf62-61e522e50ea1" - name_label = "Ubuntu Bionic Beaver 18.04_imavo" - size = 32212254720 + ... } - memory_max = 1073733632 - name_label = "Name" - template = data.xenorchestra_template.template.id } output "first-network-interface-ips" {