Why is my host attach script triggering a state change in Terraform?
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 example argument to the script that creates or modifies your host instances. Replace <host-script>
with the field name 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, included 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.