Why is my host attach script triggering a state change in Terraform?

Resolve issues where an updated host attach script triggers an unwanted state change in your Terraform configuration.

You download an updated host script for your location, which you must do yearly or else the script expires. If you use Terraform scripts to manage your Satellite location and hosts, the updated host script requires you to update all your existing hosts, forcing you to replace them with new hosts.

Your attach-host script requires an update at least once a year. The updated script qualifies as a state change for Terraform and triggers an update requirement for all hosts, even those hosts that are attached to a cluster or the location control plane. For more information about your attach-host script updates, see Why do my unassigned hosts have an Unresponsive status?.

To resolve this issue, update your Terraform script to include the following argument in the script that creates or modifies your host instances. Replace <host-script> with the field name that you used to supply the attach-host script to the host instances.

  lifecycle {
    ignore_changes = [
      <host-script>,
    ]
  }

For example, in the Azure Terraform scripts, edit the instance.tf file and replace <host-script> with custom_data, which is the name of the field defined by the azurerm_linux_virtual_machine resource.

  lifecycle {
    ignore_changes = [
      custom_data,
    ]
  }

After you add this code, any hosts that are currently attached to your location, including hosts in an unassigned state, are ignored by the Terraform script. Any new hosts that you attach to your location use the updated attach script.