Open device management
Find a file
Scott Gress d716265641
Add "generate-gitops" command (#28555)
For #27476

# Checklist for submitter

- [X] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files)
for more information.
- [X] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)

# Details

This PR adds a new command `generate-gitops` to the `fleetctl` tool. The
purpose of this command is to output GitOps-ready files that can then be
used with `fleetctl-gitops`.

The general usage of the command is:

```
fleectl generate-gitops --dir /path/to/dir/to/add/files/to
```

By default, the outputted files will not contain sensitive data, but
will instead add comments where the data needs to be replaced by a user.
In cases where sensitive data is redacted, the tool outputs warnings to
the user indicating which keys need to be updated.

The tool uses existing APIs to gather data for use in generating
configuration files. In some cases new API client methods needed to be
added to support the tool:

* ListConfigurationProfiles
* GetProfileContents
* GetScriptContents
* GetSoftwareTitleByID

Additionally, the response for the /api/latest/fleet/software/batch
endpoint was updated slightly to return `HashSHA256` for the software
installers. This allows policies that automatically install software to
refer to that software by hash.

Other options that we may or may not choose to document at this time:

* `--insecure`: outputs sensitive data in plaintext instead of leaving
comments
* `--print`: prints the output to stdout instead of writing files
* `--key`: outputs the value at a keypath to stdout, e.g. `--key
agent_options.config`
* `--team`: only generates config for the specified team name
* `--force`: overwrites files in the given directory (defaults to false,
which errors if the dir is not empty)

# Technical notes

The command is implemented using a `GenerateGitopsCommand` type which
holds some state (like a list of software and scripts encountered) as
well as a Fleet client instance (which may be a mock instance for tests)
and the CLI context (containing things like flags and output writers).
The actual "action" of the CLI command calls the `Run()` method of the
`GenerateGitopsCommand` var, which delegates most of the work to other
methods like `generateOrgSettings()`, `generateControls()`, etc.

Wherever possible, the subroutines use reflection to translate Go struct
fields into JSON property names. This guarantees that the correct keys
are written to config files, and protects against the unlikely event of
keys changing.

When sensitive data is encountered, the subroutines call `AddComment()`
to get a new token to add to the config files. These tokens are replaced
with comments like `# TODO - Add your enrollment secrets here` in the
final output.

# Known issues / TODOs:

* The `macos_setup` configuration is not output by this tool yet. More
planning is required for this. In the meantime, if the tool detects that
`macos_setup` is configured on the server, it outputs a key with an
invalid value and prints a warning to the user that they'll need to
configure it themselves.
* `yara_rules` are not output yet. The tool adds a warning that if you
have Yara rules (which you can only upload via GitOps right now) that
you'll have to migrate them manually. Supporting this will require a new
API that we'll have to discuss the authz for, so punting on it for now.
* Fleet maintained apps are not supported by GitOps yet (coming in
https://github.com/fleetdm/fleet/issues/24469). In the meantime, this
tool will output a `fleet_maintained_apps` key and trigger a warning,
and GitOps will fail if that key is present.

---------

Co-authored-by: Lucas Manuel Rodriguez <lucas@fleetdm.com>
Co-authored-by: Noah Talerman <47070608+noahtalerman@users.noreply.github.com>
2025-05-06 15:25:44 -05:00
.github Fix detected CVEs and docker scout exit code to fail the Github Action (#28836) 2025-05-06 13:35:27 -03:00
.storybook Fleet Design: Add software icons into storybook (#27238) 2025-03-19 09:22:12 -04:00
.vscode Update policies page empty state (#25726) 2025-01-29 11:12:28 -06:00
articles Update foreign vitals guide (IdP) (#28630) 2025-05-02 09:30:53 -04:00
assets Fleet UI: Add Self-service categories key and filtering (#28506) 2025-05-02 12:11:48 -04:00
changes Add "generate-gitops" command (#28555) 2025-05-06 15:25:44 -05:00
charts Add imagePullSecrets option to Helm Chart (#28783) 2025-05-02 17:56:42 -05:00
cmd Add "generate-gitops" command (#28555) 2025-05-06 15:25:44 -05:00
docs Bumping MySQL 8.4.3->8.4.5 and 9.1.0->9.3.0 in tests. (#28767) 2025-05-02 13:40:11 -05:00
ee Only allow distribution packages for bootstrap package (#28787) 2025-05-06 11:02:13 -05:00
frontend Test RunScriptBatchPaginatedList (#28839) 2025-05-06 11:42:04 -07:00
git-hooks Auto-generate and check Android schema.sql (#26720) 2025-02-28 16:30:40 -06:00
handbook Update software engineer role to be more general purpose (#28852) 2025-05-06 09:55:44 -05:00
infrastructure Fix detected CVEs and docker scout exit code to fail the Github Action (#28836) 2025-05-06 13:35:27 -03:00
it-and-security Update santa-test-devices.yml (#28804) 2025-05-05 11:27:27 -05:00
orbit Fix detected CVEs and docker scout exit code to fail the Github Action (#28836) 2025-05-06 13:35:27 -03:00
pkg Add "generate-gitops" command (#28555) 2025-05-06 15:25:44 -05:00
proposals Remove proposals (unused) (#26646) 2025-02-27 10:37:07 -06:00
schema managed_policies table docs (#28650) 2025-04-30 17:44:14 -04:00
security Fix detected CVEs and docker scout exit code to fail the Github Action (#28836) 2025-05-06 13:35:27 -03:00
server Add "generate-gitops" command (#28555) 2025-05-06 15:25:44 -05:00
terraform Remove terraform modules from the Fleet repo to reduce confusion (#26201) 2025-02-10 18:42:39 -06:00
test/upgrade Simplify DB test/upgrade tool (#27141) 2025-03-14 17:07:41 -03:00
tools Fix detected CVEs and docker scout exit code to fail the Github Action (#28836) 2025-05-06 13:35:27 -03:00
website Website: update enrichment helper to use new API routes (#28867) 2025-05-06 12:19:25 -05:00
.dockerignore Added support to read jwt and mysql password from a file (#141) 2021-01-04 07:58:43 -08:00
.eslintrc.js update storybook to 8.4.7 (#25451) 2025-01-20 16:17:33 +00:00
.gitattributes Windows friendly changes after walking through getting started guide (#1441) 2021-07-21 20:49:44 -04:00
.gitignore Ignore .swp files (#23755) 2024-11-13 09:08:47 -08:00
.gitpod.yml Add gitpod yml (#2915) 2021-11-19 10:03:56 -03:00
.golangci.yml Enable staticcheck Go linter. (#23487) 2024-11-05 11:16:24 -06:00
.goreleaser-snapshot.yml Use goreleaser v2 in CI (#23748) 2024-12-03 16:15:31 -06:00
.goreleaser.yml Fix tagging of fleetdm/fleet and fleetdm/fleetctl when releasing (#28251) 2025-04-16 15:48:47 -03:00
.npmignore Move fleetdm.com into main Fleet repo (#83) 2020-12-02 14:48:03 -06:00
.pre-commit-config.yaml bump golangci-lint to 1.55.2 (#18604) 2024-04-30 08:59:14 -06:00
.prettierignore Fix verify fleetd-base files > verify-fleetd-base-msi powershell script (#25064) 2025-01-02 10:24:25 -08:00
.prettierrc.json add prettier and have it format all fleet application code (#625) 2021-04-12 14:32:25 +01:00
.yarnrc New yarn configuration: Sets installing a dependency to a specific semantic versioning instead of latest stable (#17938) 2024-03-29 10:39:20 -04:00
babel.config.json Fleet Frontend: Create integration tests QuerySidePanel.tests.tsx (#12179) 2023-06-07 12:01:59 -04:00
CHANGELOG.md Catch up 4.67.2 (#28780) 2025-05-02 15:48:29 -05:00
CODE_OF_CONDUCT.md Remove @fleetdm.com emails from fleetdm/fleet repo (#882) 2021-05-27 17:19:14 -04:00
codecov.yml Added migration test. 2024-09-09 15:28:15 -05:00
CODEOWNERS Update CODEOWNERS (#28809) 2025-05-05 13:06:55 -05:00
docker-compose-redis-cluster.yml Move Redis cluster docker yml to separate file (#11162) 2023-04-12 15:14:28 -04:00
docker-compose.yml Optimize software_titles query to use indexes (#25722) 2025-01-23 15:48:21 -03:00
Dockerfile-desktop-linux Fix detected CVEs and docker scout exit code to fail the Github Action (#28836) 2025-05-06 13:35:27 -03:00
go.mod Fix detected CVEs and docker scout exit code to fail the Github Action (#28836) 2025-05-06 13:35:27 -03:00
go.sum Fleetd: Update the Registry DisplayVersion when fleetd auto-updates (#28183) 2025-04-17 11:04:02 -07:00
LICENSE Update LICENSE (#10) 2020-11-04 19:57:51 -06:00
Makefile Fix make so that it builds both binaries again (#28538) 2025-04-24 16:03:21 -05:00
manifest.yml.cloudgov.example cloud.gov deployment (#7611) 2022-09-07 13:30:06 -05:00
osv-scanner.toml Waive 3 Go code scanning vulnerability alerts. (#18007) 2024-04-03 16:04:01 -05:00
package.json Update SQL parser to handle more modern syntax (#28211) 2025-04-16 10:10:52 -05:00
postcss.config.js Upgrade Bourbon to 5.1.0 and fix deprecation warnings (#1973) 2019-01-03 12:46:55 -08:00
README.md Update README.md (#27751) 2025-04-02 10:23:40 -05:00
render.yaml Use Render Redis service (#23056) 2025-01-02 10:07:54 -06:00
SECURITY.md Add scanning to released images and process to track vulnerabilities (#28087) 2025-04-16 11:50:10 -03:00
tsconfig.json Fleet UI: Fix policy software automation fail to report as failing (#26044) 2025-02-28 08:45:33 -05:00
webpack.config.js Update SQL parser to handle more modern syntax (#28211) 2025-04-16 10:10:52 -05:00
yarn.lock Update SQL parser to handle more modern syntax (#28211) 2025-04-16 10:10:52 -05:00

Fleet logo, landscape, dark text, transparent background

News   ·   Report a bug   ·   Handbook   ·   Why open source?   ·   Art

Open-source platform for IT and security teams with thousands of computers. Designed for APIs, GitOps, webhooks, YAML, and humans.

A glass city in the clouds

What's it for?

Organizations like Fastly and Gusto use Fleet for vulnerability reporting, detection engineering, device management (MDM), device health monitoring, posture-based access control, managing unused software licenses, and more.

Explore data

To see what kind of data you can use Fleet to gather, check out the table reference documentation.

Out-of-the-box policies

Fleet includes out-of-the box support for all CIS benchmarks for macOS and Windows, as well as many simpler queries.

Take as much or as little as you need for your organization.

Supported platforms

Here are the platforms Fleet currently supports:

  • Linux (all distros)
  • macOS
  • Windows
  • Chromebooks
  • Amazon Web Services (AWS)
  • Google Cloud (GCP)
  • Azure (Microsoft cloud)
  • Data centers
  • Containers (kube, etc)
  • Linux-based IoT devices

Lighter than air

Fleet is lightweight and modular. You can use it for security without using it for MDM, and vice versa. You can turn off features you are not using.

Openness

Fleet is dedicated to flexibility, accessibility, and clarity. We think everyone can contribute and that tools should be as easy as possible for everyone to understand.

Good neighbors

Fleet has no ambition to replace all of your other tools. (Though it might replace some, if you want it to.) Ready-to-use, enterprise-friendly integrations exist for Snowflake, Splunk, GitHub Actions, Vanta, Elastic Jira, Zendesk, and more.

Fleet plays well with Munki, Chef, Puppet, and Ansible, as well as with security tools like Crowdstrike and SentinelOne. For example, you can use the free version of Fleet to quickly report on what hosts are actually running your EDR agent.

Free as in free

The free version of Fleet will always be free. Fleet is independently backed and actively maintained with the help of many amazing contributors.

Longevity

The company behind Fleet is founded (and majority-owned) by true believers in open source. The company's business model is influenced by GitLab (NYSE: GTLB), with great investors, happy customers, and the capacity to become profitable at any time.

In keeping with Fleet's value of openness, Fleet Device Management's company handbook is public and open source. You can read about the history of Fleet and osquery and our commitment to improving the product.

Is it any good?

Fleet is used in production by IT and security teams with thousands of laptops and servers. Many deployments support tens of thousands of hosts, and a few large organizations manage deployments as large as 400,000+ hosts.

Chat

Please join us in MacAdmins Slack or in osquery Slack.

The Fleet community is full of kind and helpful people. Whether or not you are a paying customer, if you need help, just ask.

Contributing   Run Tests   Go Report Card   CII Best Practices   Twitter Follow  

The landscape of cybersecurity and IT is too complex. Let's open it up.

Contributions are welcome, whether you answer questions on Slack / GitHub / StackOverflow / LinkedIn / Twitter, improve the documentation or website, write a tutorial, give a talk at a conference or local meetup, give an interview on a podcast, troubleshoot reported issues, or submit a patch. The Fleet code of conduct is on GitHub.

What's next?

To see what Fleet can do, head over to fleetdm.com and try it out for yourself, grab time with one of the maintainers to discuss, or visit the docs and roll it out to your organization.

Production deployment

Fleet is simple enough to spin up for yourself. Or you can have us host it for you. Premium features are available either way.

Documentation

Complete documentation for Fleet can be found at https://fleetdm.com/docs.

License

The free version of Fleet is available under the MIT license. The commercial license is also designed to allow contributions to paid features for users whose employment agreements allow them to contribute to open source projects. (See LICENSE.md for details.)

Fleet is built on osquery, nanoMDM, Nudge, and swiftDialog.