执行模块和状态模块之间的最大区别是什么 [英] what's the big difference between execution modules and state modules

查看:38
本文介绍了执行模块和状态模块之间的最大区别是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我正在从它的文档中学习 salt.但是,我对执行模块和状态模块很困惑.为什么有两种类型的模块?为什么不能统一?如果我们只有一种可以在命令行和 sls 文件中使用的模块,不是更简单更好吗?

Recently, I'm learning salt from its doc. However, I'm quite confused about execution modules and state modules. Why there are two types of module? Why they can't unify? If we have just one type of module that can be used both on command line and in sls file, isn't it simpler and better?

推荐答案

简而言之:

  • 执行模块:执行任务
  • 状态模块:尝试进入某个状态/配置.
  • 它们被设计用来在仆从上执行任务.例如: mysql.query 将查询指定的数据库.执行模块不检查是否需要查询数据库.它只是执行它的任务.
    查看完整的模块列表,您将看到它们只会为您执行任务.https://docs.saltstack.com/en/latest/ref/modules/all/index.html

    They are designed to perform tasks on a minion. For example: mysql.query will query a specified database. The execution module does not check if the database needs to be queried or not. It just executes its task.
    Have a look at the complete list of modules and you will see that they will just execute a task for you. https://docs.saltstack.com/en/latest/ref/modules/all/index.html

    它被称为状态模块.
    状态模块也是一个模块.但这是一个特殊的.使用状态模块,您可以为小黄人创建状态(/srv/salt 下的 sls 文件).
    例如,您可以创建一个状态以确保 Minion 具有为 www.example.com 配置的 Web 服务器.

    It's called THE states module.
    The states module is a module too. But it's a special one. With the states module you can create states (the sls files under /srv/salt ) for your Minions.
    You could for example create a state that ensures the Minion has a web server configured for www.example.com.

    创建状态后,您可以使用状态模块应用它:salt state.apply example_webserver

    After you have created your state you can apply it with the states module: salt <minion> state.apply example_webserver

    example_webserver 状态指定 Minion 需要具备的内容.如果 Minion 已经处于正确状态,则它什么都不做.如果 Minion 未处于正确状态,它将尝试到达那里.
    状态模块可以在这里找到:https://docs.saltstack.com/en/latest/ref/states/all/salt.states.module.html

    The example_webserver state specifies what the Minion needs to have. If the Minion is already in the correct state, it does nothing. If the Minion is not in the correct state it will try to get there.
    The states module can be found here: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.module.html

    这篇关于执行模块和状态模块之间的最大区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆