Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] citrix_machine_catalog support managing static machine in MC #203

Open
osmosBe opened this issue Feb 18, 2025 · 6 comments
Open
Labels
enhancement New feature or request 🔧

Comments

@osmosBe
Copy link

osmosBe commented Feb 18, 2025

Describe the bug

Summary of the issue
If I reduce number_of_total_machines in a static deployment the error is reproducable. I guess this logic is not jet implemented this also corresponds to this feature request: #202
The Case that needs to be implemented is, if I add a static machine I need a mechanism to also delete these created machines without manually changing it through Citrix Cloud.

Terraform command (import, apply, etc): terraform apply
Resource impacted: citrix_machine_catalog.oebb-catalog

Versions

Use the terraform -v command to find the Terraform and Citrix Provider versions.
Terraform: 1.10.5
citrix/citrix provider: 1.0.10
Operation system: Citrix Cloud / TF executed on Windows

Terraform configuration files

resource "citrix_machine_catalog" "oebb-catalog" {
    name                        = var.machine_catalog_name
    description                 = var.machine_catalog_description
    minimum_functional_level    = "L7_34" #Functional Level 2206 - https://verticalagetechnologies.com/index.php/2022/11/10/fun-with-citrix-functional-levels
    allocation_type             = "Static" #Denotes how the machines in the catalog are allocated to a user. 
    session_support             = "SingleSession" #Session support type Single or Multi
	  provisioning_type 			    = "MCS"
    persist_user_changes        = "OnLocal"
    vda_upgrade_type            = "LTSR"
    scopes                      = [] #Is here as a placeholder
    zone                        = citrix_zone.oebb-zone.id

    provisioning_scheme = {
    azure_machine_config = {
        azure_master_image = {
          master_image   = var.azure_master_image #"azoebbctximg01-osDisk"
          resource_group = var.azure_master_machine_profile_rg #"rg-vms-oebb-test-eun-001"
        }
      license_type = "Windows_Client"
      machine_profile = {
        machine_profile_resource_group = var.azure_master_machine_profile_rg #"rg-vms-oebb-test-eun-001"
        machine_profile_vm_name        = var.azure_master_image_profile_name #"azoebbctximg01"
      }
      service_offering   = var.azure_service_offering #"Standard_D2d_v4"
      storage_type       = var.azure_storage_type #"StandardSSD_LRS"
      use_managed_disks  = true
      vda_resource_group = var.vda_azure_resource_group #"rg-vms-oebb-test-eun-001"
    }
    hypervisor               = citrix_azure_hypervisor.oebb-azure-hypervisor.id #should be: "b2f3eb50-6e6a-4b28-9b88-421cbd38c409"
    hypervisor_resource_pool = citrix_azure_hypervisor_resource_pool.oebb-azure-rp.id #should be: "d29640da-e0c4-4c8e-8f03-f26a8af76f47"
    identity_type            = "AzureAD"
    network_mapping = [{
      network = var.machine_catalog_nw_name #required for azure AD
      network_device = "0" #required for azure AD and is just the index apperently
    }, ]
    machine_account_creation_rules = {
      naming_scheme      = var.machine_catalog_naming_scheme #"oebb-poc-man###"
      naming_scheme_type = "Numeric"
    }
    number_of_total_machines = var.machine_catalog_vm_count ##Get Variable from Count Members of AD Group
  }
}

Terraform console output

Error: Error updating Machine Catalog OEBB-TF-azure-catalog

with citrix_machine_catalog.oebb-catalog,
on machine_catalogs.tf line 1, in resource "citrix_machine_catalog" "oebb-catalog":
1: resource "citrix_machine_catalog" "oebb-catalog" {

Deleting machine(s) is supported for machine catalogs with Random allocation type only.

CitrixIssueId: 61135

@osmosBe osmosBe added the bug Something isn't working label Feb 18, 2025
@osmosBe osmosBe changed the title [Bug] [Bug] citrix_machine_catalog static MC cannot be deleted. Feb 18, 2025
@osmosBe osmosBe changed the title [Bug] citrix_machine_catalog static MC cannot be deleted. [Bug] citrix_machine_catalog static machine in MC cannot be deleted. Feb 18, 2025
@zhuolun-citrix
Copy link
Collaborator

Hi @osmosBe ,

Just to clarify, the machine deletion use case only supports Random allocation type machine catalogs only. So the "error" is actually by design.

I think you are asking for a new feature where you are allowed to manage each MCS static machines in your Citrix terraform. I will change this to enhancement.

Thank you,
Zhuolun

@zhuolun-citrix zhuolun-citrix added enhancement New feature or request and removed bug Something isn't working labels Feb 18, 2025
@zhuolun-citrix zhuolun-citrix changed the title [Bug] citrix_machine_catalog static machine in MC cannot be deleted. [Feature] citrix_machine_catalog support managing static machine in MC Feb 18, 2025
@aneeshk-citrix
Copy link
Collaborator

aneeshk-citrix commented Feb 20, 2025

Hi @osmosBe,

To understand this requirement better, I wanted to get something clarified:
Are you looking to simply reduce the number of machines (i.e. remove any unused machine(s)) or do you want to be able to remove a specific machine?

Thanks,
Aneesh

@osmosBe
Copy link
Author

osmosBe commented Feb 20, 2025

Hi @aneeshk-citrix,
I think the best way would be to have only the 'number_of_total_machines' in the 'citrix_machine_catalog' resource and the assigment in the 'citrix_delivery_group' resource.
So if I wan't to delete a machine I would first have to delete the user in the 'citrix_delivery_group' resource and could then decrease the count in 'citrix_machine_catalog'.
This would also be the same procedure in the GUI if you have users assigned to the static vdi machines.

Thanks
Oskar

@aneeshk-citrix
Copy link
Collaborator

Ok so there's still an assumption that the other machines would have assigned users and when you reduce the count for number_of_total_machines, you expect the machine with no assigned user to be deleted?

@osmosBe
Copy link
Author

osmosBe commented Feb 21, 2025

That would be my idea yes.
But I the issue still is how to assign users since the machine names will just be generated after the run and you would then have to update the 'delivery_group' with the machine names.
Maybe the better soution would be to actually delare the wanted names of the machines in this case so you know how the machines will be named and are then able to configure die 'citrix_delivery_group' accrodingly.

@aneeshk-citrix
Copy link
Collaborator

We use a naming scheme for machines in machine catalog. But I don't think we can be absolutely sure about the name of the machines getting created since they depend on several factors (eg existing machine accounts with same naming scheme).

So you would have to manually get the machine names and update the delivery group like you already suggested.

I'm discussing with the team internally and trying to come up with something that doesn't require manual intervention or extra terraform apply steps. Will keep you posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🔧
Projects
None yet
Development

No branches or pull requests

4 participants