<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Terraform with cloud-init]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">New to the IaC world, trying to get Terraform to create a couple of VMs through Xen Orchestra but having a little trouble with cloud-init functionality. Network config gets parsed fine and the expected IP is applied.</p>
<p dir="auto">However using the cloud-init user config that I usually use on the XO Web UI does not work. Within this cloud-init config, I'm using the name variable as shown below:<br />
<img src="/forum/assets/uploads/files/1641032993271-f9903baf-0bc1-487d-b397-872a012880c0-image.png" alt="f9903baf-0bc1-487d-b397-872a012880c0-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">However it appears when this is used via Terraform, the variable does not get parsed and the cloud config drive ends up being generated and given to the VM as</p>
<p dir="auto">#cloud-config<br />
hostname: {name}</p>
<p dir="auto">If anyone can help with this, would be much appreciated.</p>
]]></description><link>https://xcp-ng.org/forum/topic/5391/terraform-with-cloud-init</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 19:54:24 GMT</lastBuildDate><atom:link href="https://xcp-ng.org/forum/topic/5391.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 01 Jan 2022 10:31:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Terraform with cloud-init on Fri, 25 Nov 2022 17:47:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/antoniolfdacruz" aria-label="Profile: antoniolfdacruz">@<bdi>antoniolfdacruz</bdi></a> glad to hear you were able to figure it out <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f44d.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--+1" style="height:23px;width:auto;vertical-align:middle" title=":+1:" alt="👍" /></p>
]]></description><link>https://xcp-ng.org/forum/post/55420</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/55420</guid><dc:creator><![CDATA[ddelnano]]></dc:creator><pubDate>Fri, 25 Nov 2022 17:47:43 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Thu, 24 Nov 2022 15:57:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/olivierlambert" aria-label="Profile: olivierlambert">@<bdi>olivierlambert</bdi></a> Thank you, Olivier. In fact I found in this forum another topic, don't remember by who. But that has already given me enough info to reach the solution. It was about generating images to use with cloud-init. Thank you all!</p>
]]></description><link>https://xcp-ng.org/forum/post/55375</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/55375</guid><dc:creator><![CDATA[antoniolfdacruz]]></dc:creator><pubDate>Thu, 24 Nov 2022 15:57:34 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Wed, 23 Nov 2022 19:36:19 GMT]]></title><description><![CDATA[<p dir="auto">Question for <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ddelnano" aria-label="Profile: ddelnano">@<bdi>ddelnano</bdi></a> I think <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://xcp-ng.org/forum/post/55350</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/55350</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Wed, 23 Nov 2022 19:36:19 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Wed, 23 Nov 2022 18:23:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi there!</p>
<p dir="auto">Please, delete my question if it is considered bad in any way.</p>
<p dir="auto">I am able to write terraform code that creates a vm in one of our xcp pools.</p>
<p dir="auto">But can't undertand how I must configure the template in order to be able to pass cloud-init userdata and metadata.</p>
<p dir="auto">I am using a simple VM install from ubuntu 20.04.5 ISO, turned into a template. It does not seem to load the yaml templates.</p>
<pre><code>code_textalfcruz-adm@local.hcpa.ufrgs.br@volt-ampere:~/terraform-provider-xenorchestra-intro/mkxcpvm2n$ cat main.tf
# Infrastructure parametrization

variable "xoa_pool_name" {
  type        = string
  description = "Pool Name at HCPA's XCP-ng infrastructure managed by XenOrchestra"
  default     = "UAAPool01"
}

variable "xoa_template_name" {
  type        = string
  description = "Template name at the chosen XCP-ng pool (must be unique between all the HCPA's pools"
  #default     = "Ubuntu 20.04 LTS Focal Fossa (20211008u)"
  default = "template-ubuntu-20045"
}

variable "xoa_sr_name" {
  type        = string
  description = "Name of the Storage Resource to place the VM disk(s) at the chosen pool"
  default     = "EQL01UHAASR01"
}

variable "xoa_public_vlanid" {
  type        = string
  description = "The VLAN id of the public (first) network interface of this VM"
  default     = "VLAN702"
}

variable "xoa_private_vlanid" {
  type        = string
  description = "The VLAN id of the private (or second) network interface of this VM"
  default     = "VLAN902"
}

# VM parametrization

variable "vm_memory_max" {
  type        = number
  description = "VM's maximum memory (in bytes)"
  default     = 2147467264
}

variable "vm_cpus" {
  type        = number
  description = "VM's number of virtual CPU cores"
  default     = 4
}

variable "vm_name_label" {
  type        = string
  description = "The VM's name on the XCP-ng infrastructure (XOA and XCP console)"
  default     = "Terraformed at HCPA"
}

variable "vm_disk_name_label" {
  type        = string
  description = "The name of the first VM's disk"
  default     = "Filesystem root"
}

variable "vm_disk_size" {
  type        = number
  description = "The size of this VM's first disk (in bytes - default = template thick / size - 30GB)"
  default     = 32212254720
}

variable "vm_public_domain" {
  type        = string
  description = "Name of the local intranet domain"
  default     = "local.hcpa.ufrgs.br"
}

variable "vm_public_ipv4_address" {
  type        = string
  description = "The VM's public (first) interface IPv4 address"
  default     = "10.70.3.250"
}

variable "vm_public_ipv4_prefixlen" {
  type        = string
  description = "The number of network bits to use for the public IPv4 interface netmask"
  default     = "23"
}

variable "vm_public_ipv4_gateway" {
  type        = string
  description = "The IPv4 default gateway for the public interface"
  default     = "10.72.0.1"
}

# Gattering ambient facts

data "xenorchestra_pool" "pool" {
  name_label = var.xoa_pool_name
}

data "xenorchestra_template" "vm_template" {
  name_label = var.xoa_template_name
}

data "xenorchestra_sr" "sr" {
  name_label = var.xoa_sr_name
  pool_id    = data.xenorchestra_pool.pool.id
}

data "xenorchestra_network" "public_vlanid" {
  name_label = var.xoa_public_vlanid
  pool_id    = data.xenorchestra_pool.pool.id
}

data "xenorchestra_network" "private_vlanid" {
  name_label = var.xoa_private_vlanid
  pool_id    = data.xenorchestra_pool.pool.id
}

# Create cloudinit templates

data "template_file" "userdata" {
  template  = file("./cloud_userdata_cfg.yaml")
  vars      = {
    hostname = var.vm_name_label
    domain   = var.vm_public_domain
  }
}

data "template_file" "metadata" {
  template = file("./cloud_metadata_cfg.yaml")
  vars     = {
    hostname  = var.vm_name_label
    ip        = var.vm_public_ipv4_address
    prefixlen = var.vm_public_ipv4_prefixlen
    gateway   = var.vm_public_ipv4_gateway
  }
}

resource "xenorchestra_cloud_config" "userdataconfig" {
  name = "user data config"
  template = data.template_file.userdata.rendered
}

resource "xenorchestra_cloud_config" "metadataconfig" {
  name = "network data config"
  template = data.template_file.metadata.rendered
}

# VM creation

resource "xenorchestra_vm" "vm" {
#  cloud_config = templatefile("cloud_userdata_cfg.yaml", {
#    hostname = var.vm_name_label
#    domain   = var.vm_public_domain
#  })
#  cloud_network_config = templatefile("cloud_metadata_cfg.yaml", {
#    hostname  = var.vm_name_label
#    ip        = var.vm_public_ipv4_address
#    prefixlen = var.vm_public_ipv4_prefixlen
#    gateway   = var.vm_public_ipv4_gateway
#  })
  cloud_network_config = xenorchestra_cloud_config.metadataconfig.template
  cloud_config = xenorchestra_cloud_config.userdataconfig.template
  memory_max = var.vm_memory_max
  cpus       = var.vm_cpus
  name_label = var.vm_name_label
  template   = data.xenorchestra_template.vm_template.id

  network {
    network_id = data.xenorchestra_network.public_vlanid.id
  }

#  network {
#    network_id = data.xenorchestra_network.private_vlanid.id
#  }

  disk {
    sr_id      = data.xenorchestra_sr.sr.id
    name_label = var.vm_disk_name_label
    size       = var.vm_disk_size
  }
}

alfcruz-adm@local.hcpa.ufrgs.br@volt-ampere:~/terraform-provider-xenorchestra-intro/mkxcpvm2n$
alfcruz-adm@local.hcpa.ufrgs.br@volt-ampere:~/terraform-provider-xenorchestra-intro/mkxcpvm2n$ cat cloud_userdata_cfg.yaml
#cloud-config
groups:
  - aghuse: [aghu]

users:
  # seiseg and aghu / REDACTED | same public key
  - name: aghu
    uid: 1003
    gecos: AGHU Application Standard User
    passwd: &lt;REDACTED&gt;
    lock_passwd: true
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: [aghuse]
    shell: /bin/bash
    homedir: /opt/aghu
    no_create_home: false

packages:
  - tree

runcmd:
  - sed -i -e "s/PARAMMYHOSTNAME/${hostname}/g" /etc/postfix/main.cf
  - sed -i -e "s/PARAMMYHOSTNAME/${hostname}/" /etc/puppetlabs/puppet/puppet.conf
  - /opt/ds_agent/dsa_control -r
  - /opt/ds_agent/dsa_control -a dsm://goodman.local.hcpa.ufrgs.br:4120/ "policyid:60"
  - systemctl disable networker
  -


alfcruz-adm@local.hcpa.ufrgs.br@volt-ampere:~/terraform-provider-xenorchestra-intro/mkxcpvm2n$ cat cloud_metadata_cfg.yaml
#cloud-config
local-hostname: ${hostname}
instance-id: ${hostname}
network:
  version: 2
  ethernets:
    ens192:
      dhcp4: false
      addresses:
        - ${ip}/${prefixlen}
      gateway4: ${gateway}
      nameservers:
        search: [local.hcpa.ufrgs.br, hcpa]
        addresses: [10.10.31.13, 10.10.31.14, 10.10.31.42]
growpart:
  mode: auto
  devices: ['/dev/sda2']
  ignore_growroot_disabled: true
wait-on-network:
  ipv4: true

alfcruz-adm@local.hcpa.ufrgs.br@volt-ampere:~/terraform-provider-xenorchestra-intro/mkxcpvm2n$


</code></pre>
]]></description><link>https://xcp-ng.org/forum/post/55348</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/55348</guid><dc:creator><![CDATA[antoniolfdacruz]]></dc:creator><pubDate>Wed, 23 Nov 2022 18:23:56 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 15 May 2022 10:11:38 GMT]]></title><description><![CDATA[<p dir="auto">Hello there!</p>
<p dir="auto">If you think some extra doc would be important to avoid searching for the solution, please do so <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://xcp-ng.org/forum/post/49240</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/49240</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Sun, 15 May 2022 10:11:38 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 15 May 2022 07:38:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m4xm0rris" aria-label="Profile: m4xm0rris">@<bdi>m4xm0rris</bdi></a> thanks, it helped much.</p>
]]></description><link>https://xcp-ng.org/forum/post/49232</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/49232</guid><dc:creator><![CDATA[dydomby]]></dc:creator><pubDate>Sun, 15 May 2022 07:38:00 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Mon, 24 Jan 2022 13:50:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m4xm0rris" aria-label="Profile: m4xm0rris">@<bdi>m4xm0rris</bdi></a> This was very helpful. Thank you!</p>
]]></description><link>https://xcp-ng.org/forum/post/46060</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/46060</guid><dc:creator><![CDATA[bxen]]></dc:creator><pubDate>Mon, 24 Jan 2022 13:50:24 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 16 Jan 2022 12:24:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ppikna97" aria-label="Profile: ppikna97">@<bdi>ppikna97</bdi></a> Np, I was also using template_file originally but as its now deprecated there have been no builds released for M1 based Mac (leading/forcing me down the templatefile function route).</p>
]]></description><link>https://xcp-ng.org/forum/post/45783</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45783</guid><dc:creator><![CDATA[m4xm0rris]]></dc:creator><pubDate>Sun, 16 Jan 2022 12:24:14 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 16 Jan 2022 12:14:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m4xm0rris" aria-label="Profile: m4xm0rris">@<bdi>m4xm0rris</bdi></a> thanks. I was using template_file data source with xenorchestra_cloud_config data source like this:</p>
<p dir="auto"><img src="/forum/assets/uploads/files/1642334470190-905476d3-fd92-4cf1-8d10-2611cd7c8a31-image.png" alt="905476d3-fd92-4cf1-8d10-2611cd7c8a31-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">But I found answer to both of us...  Some video linked me here <a href="https://github.com/ned1313/terraform-tuesdays/tree/main/2021-02-16-TemplateFile" target="_blank" rel="noopener noreferrer nofollow ugc">templatefile vs template_file</a>. Resulting that it is better to use templatefile function to match terraform version and for working with different data types. But in the essence templatefile and template_file do the same thing.</p>
]]></description><link>https://xcp-ng.org/forum/post/45782</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45782</guid><dc:creator><![CDATA[ppikna97]]></dc:creator><pubDate>Sun, 16 Jan 2022 12:14:24 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 16 Jan 2022 10:50:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ppikna97" aria-label="Profile: ppikna97">@<bdi>ppikna97</bdi></a> Hi! How are you calling the templates in your VM resources? As you can see above from my examples I'm simply pulling both user data and network inline with the rest of my config e.g.</p>
<pre><code>cloud_config = templatefile("cloud_config.tftpl", {
  hostname = "bw-lab"
  domain = var.network["domain"]
})
cloud_network_config = templatefile("cloud_network_config.tftpl", {
  ip = "10.1.55.37"
  netmask = var.network["netmask"]
  gateway = var.network["gateway"]
})
</code></pre>
]]></description><link>https://xcp-ng.org/forum/post/45781</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45781</guid><dc:creator><![CDATA[m4xm0rris]]></dc:creator><pubDate>Sun, 16 Jan 2022 10:50:14 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 16 Jan 2022 10:48:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ddelnano" aria-label="Profile: ddelnano">@<bdi>ddelnano</bdi></a> Sir, the only thing I could point out from that pull request is the block in your <a href="http://vm.md" target="_blank" rel="noopener noreferrer nofollow ugc">vm.md</a> where you are templating the variables in a separate block.</p>
<p dir="auto">"</p>
<pre><code># Template the cloudinit if needed
template = templatefile("cloud_config.tftpl", {
  hostname = "your-hostname"
  domain = "your.domain.com"
})
</code></pre>
<p dir="auto">"<br />
I have no where near enough experience with Terraform to tell if makes any practical difference, but I am able to redner the template inline with the rest of my VM resource definition. eg.</p>
<pre><code>cloud_network_config = templatefile("cloud_network_config.tftpl", {
   ip = "10.1.55.37"
   netmask = var.network["netmask"]
   gateway = var.network["gateway"]
 })
</code></pre>
<p dir="auto">Just a little tidier IMO, but again have no idea if the way you have done this is better practice etc.</p>
<p dir="auto">Thanks <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://xcp-ng.org/forum/post/45780</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45780</guid><dc:creator><![CDATA[m4xm0rris]]></dc:creator><pubDate>Sun, 16 Jan 2022 10:48:07 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 16 Jan 2022 10:41:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi, I have question to this topic. I figured out to use templatefiles in terraform to provision my VMs. But when I try to provision network alongside with userdata configuration (2 templatefiles) it did not work. It just apply network configuration. My use case was to firstly configure static networking and than install some packages, hostname and so on. I was resolving this few months ago, but did not understand how execution sequence works or if it is even possible. Cloud-init official documentation is not very clear.</p>
<p dir="auto">I would appreciate any help with this.</p>
]]></description><link>https://xcp-ng.org/forum/post/45779</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45779</guid><dc:creator><![CDATA[ppikna97]]></dc:creator><pubDate>Sun, 16 Jan 2022 10:41:45 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Wed, 12 Jan 2022 02:43:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m4xm0rris" aria-label="Profile: m4xm0rris">@<bdi>m4xm0rris</bdi></a> thanks for posting your solution. Would you mind reviewing my changes to the terraform registry documentation (<a href="https://github.com/terra-farm/terraform-provider-xenorchestra/pull/184" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>)?</p>
<p dir="auto">Since I've been working with terraform long before Xen Orchestra, having your opinion on the documentation would be valuable <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://xcp-ng.org/forum/post/45649</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45649</guid><dc:creator><![CDATA[ddelnano]]></dc:creator><pubDate>Wed, 12 Jan 2022 02:43:31 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Wed, 12 Jan 2022 02:13:16 GMT]]></title><description><![CDATA[<p dir="auto">I was able to confirm that using the cloudinit data source does work with Xen Orchestra.</p>
<p dir="auto">Here is the following terraform code that I used (essential pieces like SR and network are excluded for the example):</p>
<pre><code>data "cloudinit_config" "cloud_config" {
  gzip = false
  base64_encode = false

  part {
    content_type = "text/cloud-config"
    content = &lt;&lt;EOF
users:
  - name: ddelnano
    sudo: ALL=(ALL) NOPASSWD:ALL
    ssh_import_id:
      - gh:ddelnano

packages:
- make
- build-essential

runcmd:
- echo 'this is a test'
EOF
  }
}

resource "xenorchestra_vm" "vm" {
  memory_max = 2147467264
  cpus = 1
  name_label = "XO terraform tutorial"
  template = data.xenorchestra_template.vm_template.id
  cloud_config = data.cloudinit_config.cloud_config.rendered

  network {
    network_id = data.xenorchestra_network.network.id
  }

  disk {
    sr_id = data.xenorchestra_sr.sr.id
    name_label = "VM root volume"
    size = 4294967296
  }
}

</code></pre>
<p dir="auto">This creates a VM and runs the cloudinit I specified, however, it doesn't allow you to do any templating. So you would still need to use the <code>templatfile</code> function built into Terraform.</p>
<p dir="auto">I'm going to update the docs to use the <code>templatefile</code> function since that is the most streamlined approach.</p>
]]></description><link>https://xcp-ng.org/forum/post/45648</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45648</guid><dc:creator><![CDATA[ddelnano]]></dc:creator><pubDate>Wed, 12 Jan 2022 02:13:16 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Tue, 11 Jan 2022 19:34:43 GMT]]></title><description><![CDATA[<p dir="auto">In case anyone comes here looking for an example (as it took me days of banging head against the proverbial wall to get this working with templatefile function):</p>
<p dir="auto">cloud_config.tftpl</p>
<pre><code>#cloud-config
hostname: ${hostname}
user: ops-user
ssh_authorized_keys:
  - OPS_USER_SSH_KEY
manage_etc_hosts: true
fqdn: ${hostname}.${domain}
package_upgrade: true
users:
 - default
</code></pre>
<p dir="auto">cloud_network_config.tftpl</p>
<pre><code>#cloud-config
version: 1
config:
    - type: physical
      name: eth0
      subnets:
      - type: static
        address: '${ip}'
        netmask: '255.255.255.0'
        gateway: '10.1.50.1'
</code></pre>
<p dir="auto"><a href="http://vm.tf" target="_blank" rel="noopener noreferrer nofollow ugc">vm.tf</a></p>
<pre><code>resource "xenorchestra_vm" "unc-lab" {
......
 cloud_config = templatefile("cloud_config.tftpl", {
  hostname = "unc-lab"
  domain = "morris.lan"
})
cloud_network_config = templatefile("cloud_network_config.tftpl", {
  ip = "10.1.55.34"
})
.......
</code></pre>
<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ddelnano" aria-label="Profile: ddelnano">@<bdi>ddelnano</bdi></a> for your help!</p>
]]></description><link>https://xcp-ng.org/forum/post/45641</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45641</guid><dc:creator><![CDATA[m4xm0rris]]></dc:creator><pubDate>Tue, 11 Jan 2022 19:34:43 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Tue, 11 Jan 2022 07:05:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m4xm0rris" aria-label="Profile: m4xm0rris">@<bdi>m4xm0rris</bdi></a> it looks like there is a builtin function to do templating now (<a href="https://www.terraform.io/language/functions/templatefile" target="_blank" rel="noopener noreferrer nofollow ugc">templatefile</a>). Apologies, it's been a while since I've written any new templated terraform code.</p>
]]></description><link>https://xcp-ng.org/forum/post/45620</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45620</guid><dc:creator><![CDATA[ddelnano]]></dc:creator><pubDate>Tue, 11 Jan 2022 07:05:12 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 09 Jan 2022 11:30:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ddelnano" aria-label="Profile: ddelnano">@<bdi>ddelnano</bdi></a> Yeah, I only found it as template_file is deprecated apparently and as it hasn't seen any updates, I couldn't use the code you posted from my M1 Macbook <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--disappointed" style="height:23px;width:auto;vertical-align:middle" title=":(" alt="😞" /></p>
<p dir="auto">Anyways, thanks for the help!</p>
]]></description><link>https://xcp-ng.org/forum/post/45571</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45571</guid><dc:creator><![CDATA[m4xm0rris]]></dc:creator><pubDate>Sun, 09 Jan 2022 11:30:13 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Thu, 06 Jan 2022 06:12:44 GMT]]></title><description><![CDATA[<p dir="auto">I created <a href="https://github.com/terra-farm/terraform-provider-xenorchestra/issues/181" target="_blank" rel="noopener noreferrer nofollow ugc">terraform-provider-xenorchestra #181</a> to track updating the docs.</p>
<p dir="auto">Cool, I didn't realize that there was a cloudinit terraform provider :). I'll be giving that a try and may use that in the examples if its better than using <code>template_file</code> directly.</p>
]]></description><link>https://xcp-ng.org/forum/post/45500</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45500</guid><dc:creator><![CDATA[ddelnano]]></dc:creator><pubDate>Thu, 06 Jan 2022 06:12:44 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Tue, 04 Jan 2022 18:37:46 GMT]]></title><description><![CDATA[<p dir="auto">Just stumbled upon this provider too which may offer a more streamlined approach, not that I am familiar enough with Terraform yet to say this for sure: <a href="https://github.com/hashicorp/terraform-provider-cloudinit" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/hashicorp/terraform-provider-cloudinit</a></p>
]]></description><link>https://xcp-ng.org/forum/post/45455</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45455</guid><dc:creator><![CDATA[m4xm0rris]]></dc:creator><pubDate>Tue, 04 Jan 2022 18:37:46 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Tue, 04 Jan 2022 17:28:49 GMT]]></title><description><![CDATA[<p dir="auto">Interesting indeed, we should probably document this <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /> If you have time <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ddelnano" aria-label="Profile: ddelnano">@<bdi>ddelnano</bdi></a> obviously <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:23px;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://xcp-ng.org/forum/post/45452</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45452</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Tue, 04 Jan 2022 17:28:49 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Tue, 04 Jan 2022 17:15:19 GMT]]></title><description><![CDATA[<p dir="auto">Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ddelnano" aria-label="Profile: ddelnano">@<bdi>ddelnano</bdi></a> , that worked perfectly!</p>
<p dir="auto">Appreciate the help!</p>
]]></description><link>https://xcp-ng.org/forum/post/45451</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45451</guid><dc:creator><![CDATA[m4xm0rris]]></dc:creator><pubDate>Tue, 04 Jan 2022 17:15:19 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sun, 02 Jan 2022 07:06:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/m4xm0rris" aria-label="Profile: m4xm0rris">@<bdi>m4xm0rris</bdi></a> Xen Orchestra's web application is doing this templating on the client side (<a href="https://github.com/vatesfr/xen-orchestra/blob/d307134d228fa8791b073c04ebb333e38a5783c9/packages/xo-web/src/xo-app/new-vm/index.js#L395" target="_blank" rel="noopener noreferrer nofollow ugc">reference</a>). Since terraform already has a nice interface for templating (using its <code>template_file</code> <a href="https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file" target="_blank" rel="noopener noreferrer nofollow ugc">data source</a>), you can do the substitution yourself.</p>
<p dir="auto">Here is an example below. Note: this code is not tested but was pulled from an internal project I have.</p>
<pre><code># template_file.tpl
#cloud-config

hostname: ${name}

# any other cloud-config you need


# vm.tf
data "template_file" "cloud_config" {
  template = file("${path.module}/template_file.tpl")
  vars = {
    name = "your_hostname_value"
  }
}

resource "xenorchestra_cloud_config" "cloud_config" {
  name = "cloud_config"
  # This performs the templating
  template = data.template_file.cloud_config.rendered
}

resource "xenorchestra_vm" "vm" {
  [ ... ]
  cloud_config = xenorchestra_cloud_config.cloud_config.template
  
}

</code></pre>
<p dir="auto">Please share your terraform code if you would like more specific advice on how to recreate exactly what you are trying to do.</p>
]]></description><link>https://xcp-ng.org/forum/post/45357</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45357</guid><dc:creator><![CDATA[ddelnano]]></dc:creator><pubDate>Sun, 02 Jan 2022 07:06:04 GMT</pubDate></item><item><title><![CDATA[Reply to Terraform with cloud-init on Sat, 01 Jan 2022 10:34:03 GMT]]></title><description><![CDATA[<p dir="auto">Hello!</p>
<p dir="auto">Hmm likely a question for <a class="plugin-mentions-user plugin-mentions-a" href="/forum/user/ddelnano" aria-label="Profile: ddelnano">@<bdi>ddelnano</bdi></a> <img src="https://xcp-ng.org/forum/assets/plugins/nodebb-plugin-emoji/emoji/android/1f914.png?v=1e2d7c4c493" class="not-responsive emoji emoji-android emoji--thinking_face" style="height:23px;width:auto;vertical-align:middle" title=":thinking_face:" alt="🤔" /></p>
]]></description><link>https://xcp-ng.org/forum/post/45347</link><guid isPermaLink="true">https://xcp-ng.org/forum/post/45347</guid><dc:creator><![CDATA[olivierlambert]]></dc:creator><pubDate>Sat, 01 Jan 2022 10:34:03 GMT</pubDate></item></channel></rss>