Improve GitOps dry-run output
customer-fairbank: Gong snippet.customer-cisneros-a: https://us-65885.app.gong.io/call?id=5813872062845986590&highlights=%5B%7B%22type%22%3A%22SHARE%22%2C%22from%22%3A3076%2C%22to%22%3A3468%7D%5D
- @noahtalerman:
customer-eponymrequested this because the currentfleetctl gitops --dry-rundoesn't provide a full plan of changes. Specifically,eponymsaw that their bootstrap package was removed from Fleet when it wasn't specified in YAML. The dry run didn't warn them.customer-eponym: "For example, when we first adopted GitOps, we omitted the macos_setup keys from our configuration. The dry run gave no indication that our existing bootstrap package assignments would be removed. We only noticed the problem after the changes were applied, when test enrollments started failing."- @noahtalerman: In the interim teams must manually reconcile UI state with Git-defined configurations before running GitOps, relying on visual inspection or ad hoc scripts to prevent accidental deletions. Some teams may delay GitOps adoption or disable auto-apply workflows out of caution.
- @noahtalerman: Eventually
fleetctl gitops --dry-runcould output a diff-style execution plan akin toterraform plan, highlighting creations (+), updates (~), and deletions (-) of resources.
customer-gispen: Gong snippet
Problem
The fleetctl gitops --dry-run command does not provide a comprehensive preview of the changes it will apply to the Fleet instance. Currently, it primarily serves as a validator for the YAML configuration files. It fails to report which existing resources configured in the Fleet UI will be deleted or modified because they are not declared in the Git repository.
This lack of visibility creates a significant risk of accidental and destructive changes. As one user put it, “There’s no good way to tell you if something is in the GUI that’s going to get removed.” Without a reliable preview, administrators cannot be fully confident that a GitOps run won't unintentionally undo work done in the UI or remove critical configurations.
What have you tried?
We use the --dry-run flag before applying GitOps changes, with the expectation that it will show us a complete plan of action. However, we've discovered that it doesn't warn about destructive actions.
For example, when we first adopted GitOps, we omitted the macos_setup keys from our configuration. The dry run gave no indication that our existing bootstrap package assignments would be removed. We only noticed the problem after the changes were applied, when test enrollments started failing. The same issue occurs if a security team member adds a query via the UI during a threat hunt; the dry run gives no warning that the query will be deleted on the next run. This forces us to perform manual, error-prone comparisons between our Git repository and the Fleet UI to avoid unintended changes, which undermines the purpose of an automated preview.
Potential solutions
The fleetctl gitops --dry-run command should be enhanced to function like terraform plan. It should perform a state comparison between the configuration defined in the Git repository and the actual state of the Fleet instance.
The output should be a clear and detailed execution plan that explicitly lists all proposed changes:
- Creations: Resources that will be added.
- Modifications: Resources that will be updated, ideally showing the specific fields that will change.
- Deletions: Resources that exist in Fleet but are absent from the Git configuration and will therefore be removed.
The output format should be easy to parse, potentially using color-coding or symbols (+, ~, -) to clearly distinguish between additions, updates, and deletions. This "Terraform-like" preview would give administrators a trustworthy way to review the exact impact of their changes before applying them.
What is the expected workflow as a result of your proposal?
- A user modifies the GitOps YAML files or, alternatively, a drift is introduced by a change made directly in the Fleet UI.
- The user runs
fleetctl gitops --dry-runlocally or as part of a CI/CD pipeline. - The command generates a detailed execution plan that shows exactly what will be created, updated, and deleted. For example:
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
~ update
- destroy
Fleet will perform the following actions:
- resource "fleet_query" "incident_response_query" {
- name = "Suspicious Process Activity"
- query = "SELECT * FROM unexpected_processes;"
# (other attributes hidden)
}
~ resource "fleet_agent_options" "global" {
~ spec.config.osquery.pack_delimiter = "/" -> "_"
}
Plan: 0 to add, 1 to change, 1 to destroy.
- The user reviews the plan and immediately sees that a manually-added query ("incident_response_query") is scheduled for deletion.
- If this change is unexpected, the user can cancel the workflow and take corrective action (e.g., add the query to the Git repository).
- If the plan accurately reflects the desired state, the user proceeds to apply the changes with confidence, knowing there will be no surprises.
I built https://github.com/TsekNet/fleet-plan as a potential gap filler for what's described as missing in this issue. Feel free to try it and report issues.
Particularly important for fairbank is that the names of the things that are being created/updated/destroyed also be listed in the output.
I have run into a similar dry-run problem: the dry-run says the operation looks fine, but the real apply contains a destructive state transition that was not surfaced. I built a small free and open-source tool called Flow-Guard to model workflow/apply logic before implementation.
Flow-Guard uses a finite-state mathematical model. It is not prompt-only and not an LLM wrapper; the AI agent is mainly a helper for installing it and running the first model.
For this GitOps flow, I would model:
- YAML key present vs absent
- current live bootstrap package assignment
- dry-run plan output
- apply behavior: no-op / update / delete
- user-visible warning requirements
The counterexample I would want to eliminate is: live state contains an assignment, YAML omission implies deletion, apply deletes it, but dry-run output does not show that destructive change.
Repo: https://github.com/liuyingxuvka/FlowGuard Feedback: https://github.com/liuyingxuvka/FlowGuard/discussions/1
This seems like a good design-time model because the meaning of "absent from YAML" is the critical state transition.
@noahtalerman could we potentially integrate https://github.com/TsekNet/fleet-plan into the gitops dry-run?
could we potentially integrate https://github.com/TsekNet/fleet-plan into the gitops dry-run?
@kitzy that's not a bad idea...
I think let's try dogfooding it first to see how it feels. @allenhouchins have we tried dogfooding Dan's output yet? https://github.com/fleetdm/fleet/issues/40052
What do you think?
A Fleet Premium customer recently brought up that GitOps dry run does not output profile changes. This specific use case is for objects in windows_settings, but I imagine the same is true for Apple profiles as well.
customer-cisneros-a: TODO
@pintomi1989 can you please help us with this?
Hey @noahtalerman - Gong snippet has been added for customer-cisneros-a
FYI the open source tool fleet-plan was recently taken over by another community member who has revived/fixed some of the functionality: https://github.com/CampusTech/fleet-plan
Gong snippet added for customer-gispen
Additional confirmation from cisneros: on a recent call, they walked through live examples where GitOps-driven activity log entries show generic actions ("edited reports," "edited policies") with no indication of which specific item changed, contrasted directly against UI-triggered changes which already show that detail. Reinforces the ask for something like a terraform plan-style diff, extended to also summarize what was actually applied on a real run, not just at dry-run.
Gong snippet: https://us-65885.app.gong.io/call?id=5121533613337969445&highlights=%5B%7B%22type%22%3A%22SHARE%22%2C%22from%22%3A213%2C%22to%22%3A1700%7D%5D
Note: customer-cisneros-l would like to see the associated fleet when a software package is missing from a fleet. Would that fall under the scope of this issue?