• DevOps Megathread: what you need and how we can help!

    Pinned
    32
    4 Votes
    32 Posts
    3k Views
    CyrilleC
    Pulumi Xen Orchestra Provider - Release v2.1.0 This new version brings improvement on the VM disks lifecycle made on the Terraform Provider. https://github.com/vatesfr/pulumi-xenorchestra/releases/tag/v2.1.0
  • XEN Orchestra JSON-RPC automation questions

    Unsolved json-rps powershell 5 websocket automation deploy clone
    10
    0 Votes
    10 Posts
    441 Views
    I
    @olivierlambert @nathanael-h @Team-DevOps Please let me know if you have answers for any of the flollowing questions: Why JSON-RPC over websocket regularly returns not expected result for calls and what could be done with it? examples: method xo.getAllObjects sometimes returns empty result, but following: jsonrpc method params ------- ------ ------ 2.0 all @{type=enter; items=} On retry - everything is fine and we have all data jsonrpc result ------- ------ 2.0 @{bbdb1ed0-4c86-24ec-...=;..... method vm.copy sometimes returns only task with name_label host.get_server_certificate and no task async.vm.copy. Meanwhile copy operation is started in XEN Orchestra, so we have to separately search for the task currently running in all objects and if it is not there anymore suggest that it completed successfully. Afterwards we need to check if vm was copied and appeared in all objects. That is really frustrating as we have no info about successfully completed tasks in XEN - records just removed as nothing happen. most likely this happens due to other tasks being popped up in tasks at the same time and websocket call recives not its own responce, is it possible to workaround? What is correct syntax for JSON to run job.create method? Are there any article with supported methods for JSON-RPC calls and examples to use them? Calling for "system.getMethodsInfo" I can see "job.create": { "description": "Creates a new job from description object", "params": { "job": { "type": "object", "properties": { "userId": { "type": "string", "optional": true }, "name": { "type": "string", "optional": true }, "timeout": { "type": "number", "optional": true }, "type": { "type": "string" }, "key": { "type": "string" }, "method": { "type": "string" }, "paramsVector": { "type": "object", "properties": { "type": { "type": "string" }, "items": { "type": "array", "items": { "type": "object" } } }, "optional": true } } } }, "permission": "admin" }, But it is unclear what values should I provide to paramsVector and looking into the job created manually (in web interface) with method job.getall I can see 2 jobs [ { "type": "call", "name": "copyvm", "key": "generictask", "method": "vm.copy", "paramsvector": { "type": "crossproduct", "items": [ { "type": "set", "values": [ { "name": "nevm", "vm": "GUID", "sr": "GUID" } ] } ] }, "userid": "GUID", "id": "GUID" }, { "method": "vm.copy", "key": "vm.copy", "name": "copyvmjob", "type": "call", "userid": "GUID", "id": "GUID" } ] How can I create similar job myself if it is not possible to find out why vm.copy does not return async.vm.copy task info?
  • 0 Votes
    6 Posts
    109 Views
    B
    @BSmithITGuy said in Ubuntu 22.04.5 custom template - additional steps missing from documentation: If you are trying to create an Ubuntu template and are having trouble on XCP-NG 8.3 (some or all probably applies to previous versions), keep reading. Very nice. Very thorough. This inspired me to share a relevant part of my cleanup script. Maybe it will be of some additional help to everyone: echo "Resetting machine ID..." > /etc/machine-id rm -f /etc/machine-info echo "Cleaning APT cache..." apt-get clean echo "Removing netplan configuration..." # Ubuntu < 24.04 rm -f /etc/netplan/00-installer-config.yaml # Ubuntu >= 24.04 rm -f /etc/netplan/50-cloud-init.yaml echo "Cloud-init cleanup..." if [[ -f "/etc/cloud/clean.d/99-installer" ]]; then chmod a-x /etc/cloud/clean.d/99-installer fi # Ubuntu < 24.04 rm -f /etc/cloud/cloud.cfg.d/99-installer.cfg /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg # Ubuntu >= 24.04 rm -f /etc/cloud/cloud.cfg.d/90-installer-network.cfg if [[ -x "$(command -v cloud-init)" ]]; then cloud-init clean --logs --seed else echo " No cloud-init detected. Skipping cloud-init cleanup!" fi echo "Removing SSH host keys..." find /etc/ssh/ -type f -name 'ssh_host_*' -delete The code is self explanatory but here are some additional tips: It's nice to do cleanup of APT cache. This will free up some space but also force the user to update APT cache on first run after VM has been provisioned. If APT cache is not cleaned, it will grow stale over time inside a template and, after some time, package installation in new VMs will start to break. Doing apt update before any package installation is good practice but people tend to easily forget it. This will force them to do it. Ubuntu installer relies on some cloud-init config for some first boot setup which has to be removed if cloud-init is to be used once again for provisioning VMs. You correctly identified these files for removal but there is a difference in Ubuntu older than 24.04 and Ubuntu 24.04 and newer. The reason I do chmod a-x /etc/cloud/clean.d/99-installer is to prevent cloud-init from removing /etc/cloud/ds-identify.cfg when doing cloud-init clean (default behavior). Because I override the default /etc/cloud/ds-identify.cfg, I don't want cloud-init clean to remove it. I remove all the other files explicitly. Additional note, /etc/cloud/clean.d/99-installer should not be removed. It should just be chmoded because it is part of the cloud-init package and will reappear on cloud-init package update. It's better to use cloud-init clean --logs --seed command to clean any runtime cloud-init leftovers and logs instead of removing them explicitly like rm -rf /var/lib/cloud/instance. SSH host keys should be removed so that they can be regenerated on first boot of newly provisioned VM. If you don't do it, all your VMs will have same host keys which could be considered as security issue.
  • Pulumi Xen Orchestra - News

    9
    1
    1 Votes
    9 Posts
    559 Views
    CyrilleC
    Release v2.1.0 This new version builds on the improvements to the Terraform Provider regarding the disk lifecycle of a VM (TF provider release). Full Release Note: https://github.com/vatesfr/pulumi-xenorchestra/releases/tag/v2.1.0
  • How to build a golden image for Windows template ?

    2
    2
    0 Votes
    2 Posts
    163 Views
    olivierlambertO
    Question for @dinhngtu
  • Automating VM builds on XO with Redhat AAP (Ansible)

    Solved
    6
    0 Votes
    6 Posts
    368 Views
    nathanael-hN
    Hello, I suggest you look also for Packer to build ready to use VM templates, with cloud-init, guest tools, and the softwares you'd need. There's a blog post for this https://xcp-ng.org/blog/2024/02/22/using-packer-with-xcp-ng/.
  • Kubernetes Recipe

    5
    0 Votes
    5 Posts
    238 Views
    abreauxA
    @Cyrille said in Kubernetes Recipe: @abreaux said in Kubernetes Recipe: Is there any way to get the cloud-init used in the Hub Kubernetes recipe? Looking to customize the deployment using Terraform and I want to make sure I include all the same tasks. What do you want to do actually? Do you want to "edit" a VM that has been deployed with the recipe (1), or do you want to deploy a new cluster that will copy the hub recipe (2)? In case of (1), you can find the cloud-init content inside the VM itself: /var/lib/cloud/instance/cloud-config.txt In the case of (2), the current version (5.105) of the k8s recipe is not really stable and is not intended to be used with Terraform. I can only recommend to find another solution (you can find some examples in the DevOps mega thread, like using Rancher). In the next release of XOA, we have updated the Kubernetes recipe to use MicroK8s, which provides a light, open-source, scalable and production-ready Kubernetes distribution. Actually, I didn't realize it was on the VM after deployment, so #1 is fine.
  • Oracle 8.10 cloud.init template creation

    5
    0 Votes
    5 Posts
    186 Views
    B
    @irtaza9 I have the main characteristics of such a temple: Minimal install is the basis root fs: ext4 and minimum 10G disk IP: DHCP ssh login: cloud-user login, ssh public key only. If you are interested I can make it available for download.
  • packer template Vdisk issue

    16
    0 Votes
    16 Posts
    611 Views
    W
    @AtaxyaNetwork Glad i can help and give back to the community
  • ACL security issue with ansible

    Moved
    10
    0 Votes
    10 Posts
    329 Views
    olivierlambertO
    @nathanael-h will
  • User credentials with xo-cli

    6
    0 Votes
    6 Posts
    238 Views
    H
    Ok, using a LDAP authenticated user is the problem. It works fine with a native XO account. Is there any way around this?
  • XO and terraform

    6
    0 Votes
    6 Posts
    537 Views
    CyrilleC
    @wezke you are welcome. let us know if you find the explanation for the problem with the template
  • User self-service creation automation

    9
    0 Votes
    9 Posts
    441 Views
    K
    Thanx ! I will check out with your team at the start of the new year for subscription, maybe we will discuss about it. @olivierlambert said in User self-service creation automation: I don't think it's possible to treat that "automatically" as it's a very specific use case. However, it should be possible to script that using our API. I don't think so. It's definetivly not an hypervisor must-have feature, but cloud yes. If you are a cloud provider and providing compute to customers, you will want to build "plans" for subscritpion and assign it automatically when user create his account and choose is plan. It is the same thing here, instead of not having bilings and several plans. Have a nice Christmas !
  • What does the "core_os" setting do in vm terraform?

    3
    0 Votes
    3 Posts
    160 Views
    S
    @olivierlambert if that’s the case, great! I’m developing some modules for the xenorchestra terraform provider, and want to understand all the options.
  • 0 Votes
    1 Posts
    161 Views
    No one has replied
  • % characters in cloud-init configs render as 0 in instance

    Solved
    11
    0 Votes
    11 Posts
    597 Views
    olivierlambertO
  • Ansible with Xen Orchestra

    Moved
    26
    2 Votes
    26 Posts
    10k Views
    olivierlambertO
    Yes, we created the DevOps team so we'll have more bandwidth coming with it.
  • Unable to clone my template's disk

    Solved
    7
    0 Votes
    7 Posts
    404 Views
    AtaxyaNetworkA
    @bvivi57 Ah yes, good catch, I didn't think of that !
  • Terraform Creating VM from my Windows Templates No Bootable Device

    5
    1
    0 Votes
    5 Posts
    606 Views
    O
    I was having this problem with my Debian 12 template when using terraform as well. I can confirm that rebuilding the template using "Other installation media" also fixed the problem for me. Thanks @SethNY .
  • Packer Created VMs Failing to Boot

    Moved
    28
    0 Votes
    28 Posts
    4k Views
    M
    Edit: Just had a thought, no idea if it's another potential workaround. In the builder you specify a template to clone that is used to create the VM. I'm on Xenserver 8, and there is no way through the GUI, but I think it might be possible to add an extra DVD-drive to a template? If that gets brought over to the packer vm, then that might be an option. Might need to do an eject from within the vm in order to dismount the dvd in order to not have it be part of the artifact though. @olivierlambert Sounds like the best way forward would be to add the equivalent of the Hyper-V builder's secondary_iso that mounts a second iso-file, or even better cd_files which creates a temporary iso for you and mounts it. For anyone who wants to test building eufi machines until this is solved, I have a Powershell script that takes a Windows ISO and generates a new one with files added (in my case autounattend.xml, bootstrap.ps1 and the management agent msi. Though I should change it to just download the msi instead to avoid rebuilding it.) Since I was building a new ISO anyway, I also changed the boot loader to the noprompt one in order to avoid the timing issues with boot_commands and "Press any key to boot from DVD...." The script uses oscdimg.exe that's included in the Windows ADK, which can be found here: https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install # Settings $Architecture = "amd64" # Or x86 $InputISOfile = "D:\Deploy\ISO\Windows Server 2022 Eval.iso" $OutputISOfile = "D:\Deploy\ISO\Windows Server 2022 Eval XenServer.iso" $TempFolder = "E:\Temp\Win2022XenServer" $AdditionalFiles = @( "C:\files\Autounattend.xml", "C:\files\bootstrap.ps1", "C:\\managementagentx64.msi" ) $OSCDIMG_Path = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools" + "\$Architecture\Oscdimg" # Check environment If (!(Test-path $InputISOfile)){ Write-Warning "Input ISO file not found. Exiting";Break} If (!(Test-path $OSCDIMG_Path)){ Write-Warning "OSCDIMG Path not found. Exiting";Break} if((Test-Path $TempFolder)){ Write-Warning "Temp folder $TempFolder exists. Exiting.";Break} foreach($file in $AdditionalFiles) { if(!(Test-Path $$file)){ Write-Warning "Additional file $file does not exists. Exiting.";Break} } # Mount the original Windows ISO and figure out the drive-letter Mount-DiskImage -ImagePath $InputISOfile $ISOImage = Get-DiskImage -ImagePath $InputISOfile | Get-Volume $ISODrive = [string]$ISOImage.DriveLetter+":" # Copy ISO contents to temp dir and add additional files New-Item -Path $TempFolder -ItemType Directory -Force Copy-Item "$ISODrive\*" $TempFolder -Recurse if(($AdditionalFiles) -and $AdditionalFiles.Length -gt 0) { Copy-Item $AdditionalFiles $TempFolder } # Dismount the Original ISO Dismount-DiskImage -ImagePath $InputISOfile # Create a new bootable Windows ISO file, based on the Original ISO, but using efisys_noprompt.bin instead $BootData='2#p0,e,b"{0}"#pEF,e,b"{1}"' -f "$TempFolder\boot\etfsboot.com","$TempFolder\efi\microsoft\boot\efisys_noprompt.bin" $Proc = Start-Process -FilePath "$OSCDIMG_Path\oscdimg.exe" -ArgumentList @("-m","-o","-bootdata:$BootData",'-u2','-udfver102',"$TempFolder\","`"$OutputISOfile`"") -PassThru -Wait -NoNewWindow if($Proc.ExitCode -ne 0) { Throw "Failed to generate ISO with exitcode: $($Proc.ExitCode)" } Get-FileHash -Path $OutputISOfile -Algorithm SHA256 Remove-Item $TempFolder -recurse -force