Use global init scripts

Important

Global init scripts only run on clusters configured with single user or legacy no-isolation shared access mode, so Databricks recommends configuring all init scripts as cluster-scoped init scripts and managing them across your workspace using cluster policies.

A global init script runs on every cluster created in your workspace. Global init scripts are useful when you want to enforce organization-wide library configurations or security screens. Only workpace admins can create global init scripts. You can create them using either the UI or REST API.

Important

Because global init scripts run on all clusters, consider potential impacts such as the following:

  • It is easy to add libraries or make other modifications that cause unexpected impacts. Whenever possible, use cluster-scoped init scripts instead.
  • Any user who creates a cluster and enables cluster log delivery can view the stderr and stdout output from global init scripts. You should ensure that your global init scripts do not output any sensitive information.

You can troubleshoot global init scripts by configuring cluster log delivery and examining the init script log. See Init script logging.

Note

Global init scripts are not run on model serving clusters .

Add a global init script using the UI

To configure global init scripts using the admin settings:

  1. Go to the admin settings and click the Compute tab.

  2. Click Manage next to Global init scripts.

  3. Click + Add.

  4. Name the script and enter it by typing, pasting, or dragging a text file into the Script field.

    Note

    The init script cannot be larger than 64KB. If a script exceeds that size, an error message appears when you try to save.

  5. If you have more than one global init script configured for your workspace, set the order in which the new script will run.

  6. If you want the script to be enabled for all new and restarted clusters after you save, toggle Enabled.

    Important

    When you add a global init script or make changes to the name, run order, or enablement of init scripts, those changes do not take effect until you restart the cluster.

  7. Click Add.

Add a global init script using Terraform

You can add a global init script by using the Databricks Terraform provider and databricks_global_init_script.

Edit a global init script using the UI

  1. Go to the admin settings and click the Compute tab.
  2. Click Manage next to Global init scripts.
  3. Click a script.
  4. Edit the script.
  5. Click Confirm.

Configure a global init script using the API

Workspace admins can add, delete, re-order, and get information about the global init scripts in your workspace using the Global Init Scripts API.