Ian Littman
Ian Littman
Fleet v4.58.0 introduces the ability to execute scripts on hosts automatically based on predefined policy failures. This guide will walk you through configuring Fleet to automatically execute scripts on hosts using uploaded scripts based on programmed policies.
Fleet allows users to upload scripts executed on macOS, Windows, and Linux hosts to remediate issues with those hosts. These scripts can now be automated to run when a policy fails. Learn more about scripts here.
fleetd
deployed with the --enable-scripts
flag. If you're using MDM features, scripts are enabled by default.When a host fails the selected policy, this will trigger the script to run on the host.
If the script fails, you can reset a script automation and trigger the script to run on all targeted hosts again. To do this, deselect the policy in the Policies > Manage automations modal, select Save, and then reselect the policy. This will reset the policy's host passing and failing host counts and retrigger the script automation.
When script automation on a policy is added or switched to a different script, the policy's status will reset for associated hosts. This allows the newly attached script to run on hosts that had previously failed the policy.
Script policy automation can be managed by setting the script_id
field on the Fleet REST API's Add team policy or Edit team policy endpoints.
To configure script policy automation via GitOps, nest a run_script
entry under the policy
you want to automate, then make sure you have the same path
field both there and in the same team's controls > scripts
section. See the GitOps reference documentation for an example.
Fleet now supports running scripts on hosts that fail a policy check. We showed how to set up these automations via the Fleet admin UI, our REST API, and GitOps.
Host condition-related issues can be resolved by running a script on those hosts. You can now automate those resolutions inside Fleet, allowing zero-touch remediation of policy failures on hosts running fleetd.