deploymenttheory / terraform-provider-jamfpro

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

Added maintenance to policies payload #291

Closed danjamf closed 3 days ago

thejoeker12 commented 1 week ago

@danjamf have you tested this in all directions?

Can you remove the log after the return please, it's upsetting the static checker.

danjamf commented 1 week ago

Sorry about that - bad VSCode! Yes tested CRUD with the example in #271 - works with the occasional read issue on release 0.0.56-58. No read issue on new stagingv2 or <0.0.56.

dan.cuddeford@C02FP4QSQ05PMBP:~/Downloads/concepts/tfscratchtesting/policymaintenacetesting|⇒  terraform apply  
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp/terratest in /Users/dan.cuddeford/Downloads/concepts/gogogo
│  - hashicorp/protecttf in /Users/dan.cuddeford/Downloads/concepts/protecttf
│  - hashicorp/jsctf in /Users/dan.cuddeford/Downloads/concepts/jsctfprovider
│  - hashicorp/jamfpro in /Users/dan.cuddeford/Documents/GitHub/terraform-provider-jamfpro
│  - hashicorp.com/edu/hashicups in /Users/dan.cuddeford/go/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # jamfpro_policy.test will be created
  + resource "jamfpro_policy" "test" {
      + enabled                       = true
      + frequency                     = "Once per computer"
      + id                            = (known after apply)
      + name                          = "p_test_terraform"
      + notify_on_each_failed_retry   = false
      + offline                       = false
      + package_distribution_point    = "default"
      + retry_attempts                = -1
      + retry_event                   = "none"
      + target_drive                  = "/"
      + trigger_checkin               = false
      + trigger_enrollment_complete   = false
      + trigger_login                 = false
      + trigger_network_state_changed = false
      + trigger_startup               = false

      + payloads {
          + maintenance {
              + byhost                      = false
              + heal                        = false
              + install_all_cached_packages = false
              + permissions                 = false
              + prebindings                 = false
              + recon                       = true
              + reset_name                  = false
              + system_cache                = false
              + user_cache                  = false
              + verify                      = false
            }
        }

      + scope {
          + all_computers = false
          + all_jss_users = false
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

jamfpro_policy.test: Creating...
jamfpro_policy.test: Creation complete after 3s [id=28]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
dan.cuddeford@C02FP4QSQ05PMBP:~/Downloads/concepts/tfscratchtesting/policymaintenacetesting|⇒  terraform state refresh                   
Usage: terraform [global options] state <subcommand> [options] [args]

  This command has subcommands for advanced state management.

  These subcommands can be used to slice and dice the Terraform state.
  This is sometimes necessary in advanced cases. For your safety, all
  state management commands that modify the state create a timestamped
  backup of the state prior to making modifications.

  The structure and output of the commands is specifically tailored to work
  well with the common Unix utilities such as grep, awk, etc. We recommend
  using those tools to perform more advanced state tasks.

Subcommands:
    list                List resources in the state
    mv                  Move an item in the state
    pull                Pull current state and output to stdout
    push                Update remote state from a local state file
    replace-provider    Replace provider in the state
    rm                  Remove instances from the state
    show                Show a resource in the state
dan.cuddeford@C02FP4QSQ05PMBP:~/Downloads/concepts/tfscratchtesting/policymaintenacetesting|⇒  terraform refresh      
jamfpro_policy.test: Refreshing state... [id=28]
dan.cuddeford@C02FP4QSQ05PMBP:~/Downloads/concepts/tfscratchtesting/policymaintenacetesting|⇒  terraform apply  
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp/terratest in /Users/dan.cuddeford/Downloads/concepts/gogogo
│  - hashicorp/protecttf in /Users/dan.cuddeford/Downloads/concepts/protecttf
│  - hashicorp/jsctf in /Users/dan.cuddeford/Downloads/concepts/jsctfprovider
│  - hashicorp/jamfpro in /Users/dan.cuddeford/Documents/GitHub/terraform-provider-jamfpro
│  - hashicorp.com/edu/hashicups in /Users/dan.cuddeford/go/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
jamfpro_policy.test: Refreshing state... [id=28]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # jamfpro_policy.test will be updated in-place
  ~ resource "jamfpro_policy" "test" {
        id                            = "28"
        name                          = "p_test_terraform"
        # (13 unchanged attributes hidden)

      ~ payloads {
          - disk_encryption {
              - action                                     = "none" -> null
              - auth_restart                               = false -> null
              - disk_encryption_configuration_id           = 0 -> null
              - remediate_disk_encryption_configuration_id = 0 -> null
            }
          ~ maintenance {
              ~ system_cache                = false -> true
                # (9 unchanged attributes hidden)
            }
        }

      - self_service {
          - feature_on_main_page            = false -> null
          - force_users_to_view_description = false -> null
          - install_button_text             = "Install" -> null
          - use_for_self_service            = false -> null
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

jamfpro_policy.test: Modifying... [id=28]
jamfpro_policy.test: Modifications complete after 1s [id=28]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
dan.cuddeford@C02FP4QSQ05PMBP:~/Downloads/concepts/tfscratchtesting/policymaintenacetesting|⇒  terraform destroy
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp.com/edu/hashicups in /Users/dan.cuddeford/go/bin
│  - hashicorp/terratest in /Users/dan.cuddeford/Downloads/concepts/gogogo
│  - hashicorp/protecttf in /Users/dan.cuddeford/Downloads/concepts/protecttf
│  - hashicorp/jsctf in /Users/dan.cuddeford/Downloads/concepts/jsctfprovider
│  - hashicorp/jamfpro in /Users/dan.cuddeford/Documents/GitHub/terraform-provider-jamfpro
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
jamfpro_policy.test: Refreshing state... [id=28]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # jamfpro_policy.test will be destroyed
  - resource "jamfpro_policy" "test" {
      - enabled                       = true -> null
      - frequency                     = "Once per computer" -> null
      - id                            = "28" -> null
      - name                          = "p_test_terraform" -> null
      - notify_on_each_failed_retry   = false -> null
      - offline                       = false -> null
      - package_distribution_point    = "default" -> null
      - retry_attempts                = -1 -> null
      - retry_event                   = "none" -> null
      - target_drive                  = "/" -> null
      - trigger_checkin               = false -> null
      - trigger_enrollment_complete   = false -> null
      - trigger_login                 = false -> null
      - trigger_network_state_changed = false -> null
      - trigger_startup               = false -> null

      - payloads {
          - disk_encryption {
              - action                                     = "none" -> null
              - auth_restart                               = false -> null
              - disk_encryption_configuration_id           = 0 -> null
              - remediate_disk_encryption_configuration_id = 0 -> null
            }
          - maintenance {
              - byhost                      = false -> null
              - heal                        = false -> null
              - install_all_cached_packages = false -> null
              - permissions                 = false -> null
              - prebindings                 = false -> null
              - recon                       = true -> null
              - reset_name                  = false -> null
              - system_cache                = true -> null
              - user_cache                  = false -> null
              - verify                      = false -> null
            }
        }

      - scope {
          - all_computers      = false -> null
          - all_jss_users      = false -> null
          - building_ids       = [] -> null
          - computer_group_ids = [] -> null
          - computer_ids       = [] -> null
          - department_ids     = [] -> null
          - jss_user_group_ids = [] -> null
          - jss_user_ids       = [] -> null
        }

      - self_service {
          - feature_on_main_page            = false -> null
          - force_users_to_view_description = false -> null
          - install_button_text             = "Install" -> null
          - use_for_self_service            = false -> null
        }
    }

Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

jamfpro_policy.test: Destroying... [id=28]
jamfpro_policy.test: Destruction complete after 0s

Destroy complete! Resources: 1 destroyed.
ShocOne commented 3 days ago

Hi there, i've added additional coverage within policies for all payload types including maintenance, management accounts, printers, local accounts, file processes and dock items. it's in main post v0.1.0 release. thanks