Κοινή χρήση μέσω


Cluster Policies CLI (legacy)

Important

This documentation has been retired and might not be updated.

This information applies to legacy Databricks CLI versions 0.18 and below. Databricks recommends that you use newer Databricks CLI version 0.205 or above instead. See What is the Databricks CLI?. To find your version of the Databricks CLI, run databricks -v.

To migrate from Databricks CLI version 0.18 or below to Databricks CLI version 0.205 or above, see Databricks CLI migration.

Only workspace admin users can create, edit, and delete policies. Workspace admin users also have access to all policies.

For requirements and limitations on cluster policies, see Create and manage compute policies.

You run Databricks Cluster Policies CLI subcommands by appending them to databricks cluster-policies. These subcommands call the Cluster Policies API.

databricks cluster-policies --help
Usage: databricks cluster-policies [OPTIONS] COMMAND [ARGS]...

  Utility to interact with Databricks cluster policies.

Options:
  -v, --version   [VERSION]
  --debug         Debug mode. Shows full stack trace on error.
  --profile TEXT  CLI connection profile to use. The default profile is
                  "DEFAULT".

  -h, --help      Show this message and exit.

Commands:
  create  Creates a Databricks cluster policy.
  delete  Removes a Databricks cluster policy given its ID.
  edit    Edits a Databricks cluster policy.
  get     Retrieves metadata about a Databricks cluster policy.
  list    Lists Databricks cluster policies.

Create a cluster policy

To display usage documentation, run databricks cluster-policies create --help.

databricks cluster-policies create --json-file create-cluster-policy.json

create-cluster-policy.json:

{
  "name": "Example Policy",
  "definition": "{\"spark_version\":{\"type\":\"fixed\",\"value\":\"next-major-version-scala2.12\",\"hidden\":true}}"
}
{
  "policy_id": "1A234567B890123C"
}

Delete a cluster policy

To view help, run databricks cluster-policies delete --help.

databricks cluster-policies delete --policy-id 1A234567B890123C

On success, this command displays nothing.

Change a cluster policy

To display usage documentation, run databricks cluster-policies edit --help.

databricks cluster-policies edit --json-file edit-cluster-policy.json

edit-cluster-policy.json:

{
  "policy_id": "1A234567B890123C",
  "name": "Example Policy",
  "definition": "{\"spark_version\":{\"type\":\"fixed\",\"value\":\"next-major-version-scala2.12\",\"hidden\":false}}",
  "created_at_timestamp": 1619477108000
}

On success, this command displays nothing.

List information about a cluster policy

To display usage documentation, run databricks cluster-policies get --help.

databricks cluster-policies get --policy-id A123456BCD789012
{
  "policy_id": "A123456BCD789012",
  "name": "Cluster Policy Demo",
  "definition": "{\n  \"spark_env_vars.PYSPARK_PYTHON\": {\n    \"type\": \"fixed\",\n    \"value\": \"/databricks/python3/bin/python27\"\n  }\n}",
  "created_at_timestamp": 1615504519000
}

List information about available cluster policies

To display usage documentation, run databricks cluster-policies list --help.

databricks cluster-policies list --output JSON
{
  "policies": [
    {
      "policy_id": "A123456BCD789012",
      "name": "Cluster Policy Demo",
      "definition": "{\n  \"spark_env_vars.PYSPARK_PYTHON\": {\n    \"type\": \"fixed\",\n    \"value\": \"/databricks/python3/bin/python27\"\n  }\n}",
      "created_at_timestamp": 1615504519000
    },
    ...
  ],
  "total_count": 16
}