cloud-init Cloud Config use of {name}
-
I'm starting to work with cloud-init and Cloud Configs. Setting the hostname is straighforward via:
hostname: {name}This looks somewhat like a jinja template. Is the standard...
## template: jinja...implicit here, or is this a special implementation? Can
{name}, for example, be used elsewhere? Does it require the jinja format of{{ ref }}or not? If jinja is needed, I assume both python and jinja need to be installed in when the template is created, correct? I need to write a simple config file with the hostname in it.What is the recommended approach? Thanks!
-
@bug-meister Nope. This is not Jinja nor any other kind of templating engine. This is a simple search-and-replace kind of implementation and is limited to
nameand%, the later being VM index. From the docs:Xen Orchestra offers the ability to insert variables such as the virtual machine name {name} or a virtual machine index %. However, the expressive power is limited to the graphical interface. For instance, it is not possible to build a series of virtual machines with complex values or from external data.
Reference:
In other words, there is no advanced templating of cloud-init configuration but you could probably template it outside XenOrchestra and apply it via Terraform:
-
@bvitnik Thank you! I was hoping not to go so far as Terraform/OpenTofu or Ansible. I found this post from @dj423 suggesting that I may be able to accomplish what I'm hoping by installing jinja into the VM before I convert it to a template. However, it does NOT appear that I need to modify my template to install python or jinja -- they appear to be in place, perhaps as dependencies of
cloud-inititself. I will test further! -
@bug-meister Ah. That's cloud-init's support for templating user-data. The issue is that with these templates you only have access to the info available inside the VM itself. No outside data can be used for templating unless it is somehow passed to the VM (inject a file, set xenstore values...)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login