Yohan460 / terraform-provider-jamf

Other
14 stars 10 forks source link

Fix policy resource #4

Closed kenchan0130 closed 1 year ago

kenchan0130 commented 1 year ago

Description

Drop the netboot_server of override_default_settings in policy

The attribute netboot_server in override_default_settings in policy does not exist as a Jamf API strict. I have therefore removed the relevant attribute.

スクリーンショット 2023-02-27 2 03 12

Ref: https://developer.jamf.com/jamf-pro/reference/findpoliciesbyid

Some objects in policy have different default values, corrected

When we run terraform plan against the policy, we may get differences every time.

resource "jamf_category" "category1" {
  name     = "category1"
  priority = 9
}

resource "jamf_category" "category2" {
  name    = "category2"
  priority = 9
}

resource "jamf_policy" "test" {
  general {
    name      = "[terraform] Test Policy 1"
    enabled   = true
    frequency = "Ongoing"

    category {
      id   = jamf_category.category1.id
      name = jamf_category.category1.name
    }
    network_limitations {}
    override_default_settings {}
    site {}
  }

  self_service {
    self_service_category {
      id = jamf_category.category1.id
    }
    self_service_category {
      id = jamf_category.category2.id
    }
    self_service_icon {}
  }

  scope {}
  reboot {}
}

The cause of this phenomenon is that the default values are different from those expected by this provider. The response of Jamf API at this time is as follows

{
  "policy": {
    "general": {
      "id": 54,
      "name": "[terraform] Test Policy 1",
      "enabled": true,
      "trigger": "EVENT",
      "trigger_checkin": false,
      "trigger_enrollment_complete": false,
      "trigger_login": false,
      "trigger_network_state_changed": false,
      "trigger_startup": false,
      "trigger_other": "",
      "frequency": "Ongoing",
      "retry_event": "none",
      "retry_attempts": -1,
      "notify_on_each_failed_retry": false,
      "location_user_only": false,
      "target_drive": "/",
      "offline": false,
      "category": {
        "id": 16,
        "name": "category1"
      },
      "date_time_limitations": {
        "activation_date": "",
        "activation_date_epoch": 0,
        "activation_date_utc": "",
        "expiration_date": "",
        "expiration_date_epoch": 0,
        "expiration_date_utc": "",
        "no_execute_on": {},
        "no_execute_start": "",
        "no_execute_end": ""
      },
      "network_limitations": {
        "minimum_network_connection": "No Minimum",
        "any_ip_address": true,
        "network_segments": []
      },
      "override_default_settings": {
        "target_drive": "/",
        "distribution_point": "default",
        "force_afp_smb": false,
        "sus": "default"
      },
      "network_requirements": "Any",
      "site": {
        "id": -1,
        "name": "None"
      }
    },
    "scope": {
      "all_computers": true,
      "computers": [],
      "computer_groups": [],
      "buildings": [],
      "departments": [],
      "limit_to_users": {
        "user_groups": []
      },
      "limitations": {
        "users": [],
        "user_groups": [],
        "network_segments": [],
        "ibeacons": []
      },
      "exclusions": {
        "computers": [],
        "computer_groups": [],
        "buildings": [],
        "departments": [],
        "users": [],
        "user_groups": [],
        "network_segments": [],
        "ibeacons": []
      }
    },
    "self_service": {
      "use_for_self_service": false,
      "self_service_display_name": "",
      "install_button_text": "Install",
      "reinstall_button_text": "Reinstall",
      "self_service_description": "",
      "force_users_to_view_description": false,
      "self_service_icon": {},
      "feature_on_main_page": false,
      "self_service_categories": [
        {
          "id": 16,
          "name": "category1",
          "display_in": true,
          "feature_in": false
        },
        {
          "id": 17,
          "name": "category2",
          "display_in": true,
          "feature_in": false
        }
      ],
      "notification": "Self Service",
      "notification_subject": "",
      "notification_message": ""
    },
    "package_configuration": {
      "packages": [],
      "distribution_point": "default"
    },
    "scripts": [],
    "printers": [
      ""
    ],
    "dock_items": [],
    "account_maintenance": {
      "accounts": [],
      "directory_bindings": [],
      "management_account": {
        "action": "doNotChange"
      },
      "open_firmware_efi_password": {
        "of_mode": "none",
        "of_password_sha256": ""
      }
    },
    "reboot": {
      "message": "",
      "startup_disk": "Current Startup Disk",
      "specify_startup": "",
      "no_user_logged_in": "Do not restart",
      "user_logged_in": "Do not restart",
      "minutes_until_reboot": 5,
      "start_reboot_timer_immediately": false,
      "file_vault_2_reboot": false
    },
    "maintenance": {
      "recon": false,
      "reset_name": false,
      "install_all_cached_packages": false,
      "heal": false,
      "prebindings": false,
      "permissions": false,
      "byhost": false,
      "system_cache": false,
      "user_cache": false,
      "verify": false
    },
    "files_processes": {
      "search_by_path": "",
      "delete_file": false,
      "locate_file": "",
      "update_locate_database": false,
      "spotlight_search": "",
      "search_for_process": "",
      "kill_process": false,
      "run_command": ""
    },
    "user_interaction": {
      "message_start": "",
      "allow_users_to_defer": false,
      "allow_deferral_until_utc": "",
      "allow_deferral_minutes": 0,
      "message_finish": ""
    },
    "disk_encryption": {
      "action": "none"
    }
  }
}

Therefore, to the best of my knowledge and influence, I have modified the default values of the jamf_policy resource.