# 开源配置管理软件比较

开源配置管理软件通过用代码描述每台机器的期望状态，并在主机集群中强制执行该状态，从而实现服务器设置与维护的自动化。最常被拿来比较的工具是 [Ansible](https://www.edgepedia.org/zh/ansible-software)、Chef、[Puppet](https://www.edgepedia.org/zh/puppet-software)、Salt 和 CFEngine，其中最后一个是该品类的开创者：[奥斯陆大学](https://www.edgepedia.org/zh/university-of-oslo)（University of Oslo）理论物理学家马克·伯吉斯（Mark Burgess）于 1993 年将其开源发布<sup>[1](https://link.springer.com/chapter/10.1007/978-981-19-2476-7_6)</sup>。

| 关键事实 | 详情 |
|---|---|
| 首次发布 | CFEngine 1993，Puppet 2005，Chef 2009，Ansible 2012<sup>[1](https://link.springer.com/chapter/10.1007/978-981-19-2476-7_6)</sup> |
| 架构 | Ansible 通过 SSH 实现无代理；Chef、Puppet、Salt 和 CFEngine 使用代理，并配有中央服务器或主控端<sup>[2](https://docs.ansible.com/projects/ansible-core/devel/playbook_guide/playbooks_intro.html)</sup><sup> • </sup><sup>[3](https://docs.chef.io/client/18/overview/chef_overview/)</sup><sup> • </sup><sup>[4](https://help.puppet.com/core/current/Content/PuppetCore/architecture.htm)</sup><sup> • </sup><sup>[5](https://docs.saltproject.io/en/master/topics/salt_system_architecture.html)</sup> |
| 编写语言 | Ansible 和 Salt 使用 YAML；Chef 使用 Ruby；Puppet 和 CFEngine 使用自有的声明式领域特定语言<sup>[2](https://docs.ansible.com/projects/ansible-core/devel/playbook_guide/playbooks_intro.html)</sup><sup> • </sup><sup>[5](https://docs.saltproject.io/en/master/topics/salt_system_architecture.html)</sup><sup> • </sup><sup>[3](https://docs.chef.io/client/18/overview/chef_overview/)</sup><sup> • </sup><sup>[6](https://help.puppet.com/core/media/pdf/puppet-8.10.0.pdf)</sup> |
| 社区内容（2026 年） | Ansible Galaxy 10,000+ 个角色、Puppet Forge 7,000+ 个模块、Chef Supermarket 3,800+ 本烹饪书、Salt Formulas 200+<sup>[7](https://computingforgeeks.com/ansible-vs-chef-puppet-salt/)</sup> |
| 近期版本 | Ansible 13.5.0（ansible-core 2.20.4）、Chef Infra Client 19.2.12、Puppet 8.18.0、Salt 3007.13<sup>[7](https://computingforgeeks.com/ansible-vs-chef-puppet-salt/)</sup> |
| 执行模型 | CFEngine 的 cf-agent 默认每 5 分钟重新评估策略并持续修复漂移；Puppet 代理在计划运行时应用目录<sup>[8](https://docs.cfengine.com/docs/master/examples/tutorials/policy-writing/introduction-to-policy-writing/)</sup><sup> • </sup><sup>[4](https://help.puppet.com/core/current/Content/PuppetCore/architecture.htm)</sup> |
| 许可变化 | Puppet 于 2025 年初将加固后的二进制文件改为受最终用户许可协议约束，同时保留 Apache 2.0 源码；CFEngine Enterprise 最多 25 台主机免费<sup>[9](https://www.puppet.com/blog/open-source-puppet-updates-2025)</sup><sup> • </sup><sup>[10](https://cfengine.com/blog/2026/cfengine-3-27-lts-released-exploration/)</sup> |

## 架构

**Ansible** 是无代理方案。用 YAML 编写的 Playbook 描述任务，Ansible 通过 SSH 连接在目标机器上执行这些任务；Playbook 可纳入源代码管理并复用，以推送配置或确认远程系统的状态<sup>[2](https://docs.ansible.com/projects/ansible-core/devel/playbook_guide/playbooks_intro.html)</sup>。该架构也可通过 `ansible-pull` 反转：节点从 git 检出配置指令仓库，并在本地针对该内容运行 `ansible-playbook`；文档指出，若检出位置采用负载均衡，这种模式可扩展而不受固定的中心节点上限限制<sup>[2](https://docs.ansible.com/projects/ansible-core/devel/playbook_guide/playbooks_intro.html)</sup>。

**Chef** 通过三个组件将基础设施转化为代码。用户在 Chef Workstation 上使用 Test Kitchen、knife 命令行工具和 chef 命令等工具编写并测试烹饪书；烹饪书被上传到 Chef Infra Server，后者充当配置数据、策略和节点元数据的枢纽；Chef Infra Client 在每个受管节点上运行，按计划执行，将系统配置到其期望状态，并在每次运行期间从服务器拉取所需的配置数据<sup>[3](https://docs.chef.io/client/18/overview/chef_overview/)</sup>。烹饪书是配置与策略分发的基本单位，包含配方、属性值、自定义资源、文件与模板，以及描述该烹饪书及其依赖项的 `metadata.rb` 文件<sup>[3](https://docs.chef.io/client/18/overview/chef_overview/)</sup>。

Puppet 基于代理—服务器模型构建，其中一台中央主服务器管理其控制下的一大组代理节点的配置数据。代理将事实（facts）发送给主服务器并请求目录（catalog）；服务器编译并返回目录；代理通过检查每个资源并纠正任何不处于期望状态的内容来应用该目录，或在 no-op 模式下评估所需变更；随后代理发回报告<sup>[4](https://help.puppet.com/core/current/Content/PuppetCore/architecture.htm)</sup>。Puppet 代码是声明式的：你描述系统的期望状态，而不是达到该状态所需的步骤<sup>[6](https://help.puppet.com/core/media/pdf/puppet-8.10.0.pdf)</sup>。较早的独立配置模式——代理使用 `puppet apply` 自行编译目录——已不再被推荐，因为这类模式难以维护和保障安全<sup>[4](https://help.puppet.com/core/current/Content/PuppetCore/architecture.htm)</sup>。

**Salt** 是一个基于 Python 的远程执行框架，用于[配置管理](https://www.edgepedia.org/zh/configuration-management)、自动化、置备和编排。它采用主控—客户端模型：运行 `salt-master` 服务的 Salt Master 向运行 `salt-minion` 服务的 Salt Minion 发出命令；同样也可以把它描述为一个发布—订阅系统，构建在可插拔事件总线之上，默认传输层为 ZeroMQ，Tornado 则是基于 TCP 的替代方案<sup>[5](https://docs.saltproject.io/en/master/topics/salt_system_architecture.html)</sup>。配置管理通过 Salt 状态实现，这些状态使用简单的 YAML 文件声明某个 minion 应处于的状态<sup>[5](https://docs.saltproject.io/en/master/topics/salt_system_architecture.html)</sup>。Minion 还可以用 `salt-call --local` 完全绕过主控端；文档推荐用这种方式调试配置管理等复杂操作<sup>[11](https://docs.saltproject.io/salt/user-guide/en/latest/topics/execution-architecture.html)</sup>。

**CFEngine** 是一个分布式系统，每台受管机器都运行组件应用，这些应用解释用声明式 CFEngine 策略语言编写的策略文件。原子单位是承诺（promises），它们被组织成束（bundles）；`cf-agent` 进程负责执行策略，默认每 5 分钟运行一次，评估 `/var/cfengine/inputs` 中的文件<sup>[8](https://docs.cfengine.com/docs/master/examples/tutorials/policy-writing/introduction-to-policy-writing/)</sup><sup> • </sup><sup>[12](https://docs.cfengine.com/docs/lts/overview/)</sup>。与一次性推送镜像的工具不同，CFEngine 持续验证每一个承诺并修复偏差，文档将这一自修复过程称为收敛（convergence）<sup>[12](https://docs.cfengine.com/docs/lts/overview/)</sup>。主机自治是指导性的架构原则：代理在功能上相互独立，因此系统对网络故障保持稳健，每台主机维护自己的状态<sup>[13](https://docs.cfengine.com/docs/archive/manuals/st-security.html)</sup>。

## 语言与编写风格

编写语言塑造日常工作。Ansible 的 Playbook 和 Salt 状态都是 YAML 文件，这使入门成本较低；Salt 状态扩展了 Salt 的执行模块，因此不再执行一次性的命令，而是一次定义系统状态后持续确保该状态得到落实<sup>[5](https://docs.saltproject.io/en/master/topics/salt_system_architecture.html)</sup><sup> • </sup><sup>[14](https://docs.saltproject.io/en/latest/ref/states/index.html)</sup>。Chef 使用 [Ruby](https://www.edgepedia.org/zh/ruby-programming-language) 作为烹饪书的参考语言，大多数配方以简单的资源模式编写，而在需要编程语言时可使用 Ruby 的全部能力<sup>[3](https://docs.chef.io/client/18/overview/chef_overview/)</sup>。Puppet 和 CFEngine 各自提供自己的声明式领域特定语言；Puppet 的 DSL 包括用户自定义资源类型、带有某种继承形式的类，以及依赖管理<sup>[6](https://help.puppet.com/core/media/pdf/puppet-8.10.0.pdf)</sup><sup> • </sup><sup>[15](https://arxiv.org/abs/1608.04999)</sup>；而 CFEngine 的承诺类型（如 `files`、`packages`、`users` 和 `services`）提供了一种可跨操作系统工作的语法<sup>[8](https://docs.cfengine.com/docs/master/examples/tutorials/policy-writing/introduction-to-policy-writing/)</sup>。

一项对 Chef、Ansible、SaltStack 和 Puppet 的比较分析总结了这些取舍：Chef 以大规模环境中的灵活性和集成能力著称，但学习曲线陡峭；Ansible 因简单性和无代理架构而受到称赞，对初学者友好；SaltStack 在速度与可扩展性方面表现出色；Puppet 成熟的生态系统为复杂配置提供了广泛支持<sup>[16](https://easychair.org/publications/preprint/sbfH/open)</sup>。

## 社区生态系统

可复用内容的规模差异显著。截至 2026 年，Ansible Galaxy 托管超过 10,000 个角色，Puppet Forge 超过 7,000 个模块，Chef Supermarket 超过 3,800 本烹饪书，Salt 生态系统约有 200 个或更多配置配方<sup>[7](https://computingforgeeks.com/ansible-vs-chef-puppet-salt/)</sup>。同一来源报告称，截至 2026 年，Ansible 是新项目采用最多的配置管理工具<sup>[7](https://computingforgeeks.com/ansible-vs-chef-puppet-salt/)</sup>。

安全研究给出了共同警示：一项对来自 813 个开源仓库的 50,323 个 Ansible 和 Chef 脚本进行的实证研究发现，安全异味（security smells）出现 46,600 次，其中包括 7,849 个硬编码密码，并得出结论：这类异味在 Ansible 和 Chef 脚本中普遍存在，程度与 Puppet 脚本类似<sup>[17](https://arxiv.org/abs/1907.07159)</sup>。

## 许可与近期可用性

开源格局已转向由供应商控制的发行方式。2025 年初，Puppet 开始将新的二进制文件和软件包发布到私有的加固位置；社区贡献者可根据最终用户许可协议（EULA）免费访问，用于开发用途；超过 25 个节点的容量需要商业许可证；但源代码仍完全按 Apache 2.0 许可证提供，Puppet Forge 也仍然免费开放<sup>[9](https://www.puppet.com/blog/open-source-puppet-updates-2025)</sup>。

CFEngine 延续长期支持（LTS）节奏：2026 年 1 月 9 日发布的 3.27.0 版开启了支持 3 年的 3.27 LTS 系列，CFEngine Enterprise 最多 25 台主机免费<sup>[10](https://cfengine.com/blog/2026/cfengine-3-27-lts-released-exploration/)</sup>。Salt 继续活跃开发，其 GitHub 仓库中出现了 3008 系列和 3006 长期支持版本<sup>[18](https://github.com/saltstack/salt/releases)</sup>。

## 如何在它们之间选择

结构差异对应着运维需求。像 Ansible 这样的无代理工具不需要在目标上安装任何东西，适合临时部署和较简单的环境，但缺少一个在两次运行之间持续维持期望状态的常驻代理。基于代理的工具（如 Puppet、Chef、Salt 和 CFEngine）会按计划持续执行配置：Puppet 代理在周期性运行中应用目录<sup>[4](https://help.puppet.com/core/current/Content/PuppetCore/architecture.htm)</sup>，Chef Infra Client 按计划执行<sup>[3](https://docs.chef.io/client/18/overview/chef_overview/)</sup>，CFEngine 的代理默认每 5 分钟重新检查策略<sup>[8](https://docs.cfengine.com/docs/master/examples/tutorials/policy-writing/introduction-to-policy-writing/)</sup>。Salt 占据中间位置，在快速消息总线传输之上，将基于推送的远程执行与声明式状态结合起来<sup>[5](https://docs.saltproject.io/en/master/topics/salt_system_architecture.html)</sup>。CFEngine 是该组中最古老的工具，仍然面向大规模、自修复的部署：策略从中央服务器分发，并在每台主机上自主执行<sup>[12](https://docs.cfengine.com/docs/lts/overview/)</sup><sup> • </sup><sup>[13](https://docs.cfengine.com/docs/archive/manuals/st-security.html)</sup>。

## References

1. [Engines, Puppets, Promises: The Figurations of Configuration Management, Springer Nature](https://link.springer.com/chapter/10.1007/978-981-19-2476-7_6)
2. [Ansible Playbooks, Ansible Core Documentation](https://docs.ansible.com/projects/ansible-core/devel/playbook_guide/playbooks_intro.html)
3. [Chef Infra overview, Chef Documentation](https://docs.chef.io/client/18/overview/chef_overview/)
4. [Overview of Puppet's architecture, Puppet Core 9.1.0](https://help.puppet.com/core/current/Content/PuppetCore/architecture.htm)
5. [Salt system architecture, Salt Project Documentation](https://docs.saltproject.io/en/master/topics/salt_system_architecture.html)
6. [Open source Puppet 8.10.0 reference manual](https://help.puppet.com/core/media/pdf/puppet-8.10.0.pdf)
7. [Ansible vs Chef vs Puppet vs Salt: Comparison [2026], ComputingForGeeks](https://computingforgeeks.com/ansible-vs-chef-puppet-salt/)
8. [Introduction to policy writing, CFEngine docs](https://docs.cfengine.com/docs/master/examples/tutorials/policy-writing/introduction-to-policy-writing/)
9. [Our Plans for Open Source Puppet in 2025, Puppet blog](https://www.puppet.com/blog/open-source-puppet-updates-2025)
10. [CFEngine 3.27 LTS released, CFEngine blog](https://cfengine.com/blog/2026/cfengine-3-27-lts-released-exploration/)
11. [Execution architecture, Salt user guide](https://docs.saltproject.io/salt/user-guide/en/latest/topics/execution-architecture.html)
12. [Overview, CFEngine docs](https://docs.cfengine.com/docs/lts/overview/)
13. [Architecture and Security, CFEngine docs archive](https://docs.cfengine.com/docs/archive/manuals/st-security.html)
14. [State System Reference, Salt Project Documentation](https://docs.saltproject.io/en/latest/ref/states/index.html)
15. [μPuppet: A Declarative Subset of the Puppet Configuration Language, arXiv](https://arxiv.org/abs/1608.04999)
16. [Comparative Analysis of Configuration Management Tools, EasyChair preprint](https://easychair.org/publications/preprint/sbfH/open)
17. [Security Smells in Ansible and Chef Scripts: A Replication Study, arXiv](https://arxiv.org/abs/1907.07159)
18. [Releases, saltstack/salt, GitHub](https://github.com/saltstack/salt/releases)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Development tools and collaboration infrastructure › Build, deployment, and development tooling

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/comparison-of-open-source-configuration-management-software

English original: https://www.edgepedia.org/comparison-of-open-source-configuration-management-software
