Skip to content

Commit

Permalink
Revert "update xenorchestra_vm example, valid hcl (#323)"
Browse files Browse the repository at this point in the history
This reverts commit 0315be6.
  • Loading branch information
ddelnano authored Apr 22, 2024
1 parent 0315be6 commit 9f1ab8c
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 99 deletions.
95 changes: 43 additions & 52 deletions docs/resources/vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand All @@ -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" {
Expand Down
85 changes: 38 additions & 47 deletions examples/resources/xenorchestra_vm/resource.tf
Original file line number Diff line number Diff line change
@@ -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" {
Expand All @@ -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" {
Expand Down

0 comments on commit 9f1ab8c

Please sign in to comment.