deploymenttheory / terraform-provider-jamfpro

Jamf Pro Terraform Provider/Plugin written with the TF Provider SDK v2. Written in go
Mozilla Public License 2.0
24 stars 9 forks source link

Unable to manage Computer Groups created with provider v0.0.49 and prior #204

Closed smithjw closed 1 month ago

smithjw commented 2 months ago

Receiving an error about being unable to update Computer Groups created with older versions of the provider. The error message refers to not being able to have the computers dict when is_smart is true, but I'm wondering if this is actually to do with a new check introduced to look at groups with associated sites?

Terraform config (v0.0.49):

resource "jamfpro_computer_group" "config_scope_managed_devices" {
  name     = "Config Scope - Managed macOS Devices (tf)"
  is_smart = true
  criteria {
    name        = "MDM Capability"
    priority    = 0
    search_type = "is"
    value       = "Yes"
  }
  criteria {
    and_or      = "and"
    name        = "Model"
    priority    = 1
    search_type = "like"
    value       = "Mac"
  }
}

I don't use sites, but there is reference to site in the state (namely an id of -1 and name of None) Output of terraform state show 'jamfpro_computer_group.config_scope_managed_devices'

# jamfpro_computer_group.config_scope_managed_devices:
resource "jamfpro_computer_group" "config_scope_managed_devices" {
    id       = "3"
    is_smart = true
    name     = "Config Scope - Managed macOS Devices (tf)"

    criteria {
        and_or        = "and"
        closing_paren = false
        name          = "MDM Capability"
        opening_paren = false
        priority      = 0
        search_type   = "is"
        value         = "Yes"
    }
    criteria {
        and_or        = "and"
        closing_paren = false
        name          = "Model"
        opening_paren = false
        priority      = 1
        search_type   = "like"
        value         = "Mac"
    }

    site {
        id   = -1
        name = "None"
    }
}

Proceed to update provider to v0.0.52, run the command terraform plan -target='jamfpro_computer_group.config_scope_managed_devices', then receive the error:

jamfpro_computer_group.config_scope_managed_devices: Refreshing state... [id=3]
Planning failed. Terraform encountered an error while generating this plan.

│ Error: 'computers' field is not allowed when 'is_smart' is true
│ 
│   with jamfpro_computer_group.config_scope_managed_devices,
│   on computer_groups-general.tf line 1, in resource "jamfpro_computer_group" "config_scope_managed_devices":
│    1: resource "jamfpro_computer_group" "config_scope_managed_devices" {
smithjw commented 1 month ago

Any chance that the PR listed here (https://github.com/deploymenttheory/terraform-provider-jamfpro/pull/214), will resolve the issue I'm seeing above?

ShocOne commented 1 month ago

hi there, yes it should include the fix for your issue. it's part of the latest release v0.0.53. thanks

smithjw commented 1 month ago

I don't believe the Computer Groups issue has been resolved, while slightly different to the above, I'm now seeing the plugin crash on 0.0.53 @ShocOne.

Simple config

resource "jamfpro_computer_group" "config_scope_managed_vm" {
  name     = "Config Scope - Managed VMs (tf)"
  is_smart = true

  criteria {
    name        = "Model"
    priority    = 0
    search_type = "like"
    value       = "VirtualMac"
  }
}

Error when I try to run a plan (this group is already in my state)

Error: Plugin did not respond
│   with jamfpro_computer_group.config_scope_managed_vm,
│   on computer_groups-general.tf line 19, in resource "jamfpro_computer_group" "config_scope_managed_vm":
│   19: resource "jamfpro_computer_group" "config_scope_managed_vm" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).PlanResourceChange call. The plugin logs may contain
│ more details.

By adding a site of -1 to the resource, the plan completes

site {
  id = "-1"
}