salt-stack - Saltstack : ignoring result of cmd.运行

标签 salt-stack

我正在尝试通过Saltstack调配命令。如果命令失败,那么我将获得状态失败,并且我不希望这样做(命令的重新编码无关紧要)。

目前,我有以下解决方法:

Run something:
  cmd.run:
    - name: command_which_can_fail || true

有什么方法可以使用Salt功能使这种状态忽略retcode?或者也许我可以从日志中排除此状态?

最佳答案

使用 check_cmd :

fails:
  cmd.run:
    - name: /bin/false

succeeds:
  cmd.run:
    - name: /bin/false
    - check_cmd:
      - /bin/true

输出:
local:
----------
          ID: fails
    Function: cmd.run
        Name: /bin/false
      Result: False
     Comment: Command "/bin/false" run
     Started: 16:04:40.189840
    Duration: 7.347 ms
     Changes:
              ----------
              pid:
                  4021
              retcode:
                  1
              stderr:

              stdout:

----------
          ID: succeeds
    Function: cmd.run
        Name: /bin/false
      Result: True
     Comment: check_cmd determined the state succeeded
     Started: 16:04:40.197672
    Duration: 13.293 ms
     Changes:
              ----------
              pid:
                  4022
              retcode:
                  1
              stderr:

              stdout:


Summary
------------
Succeeded: 1 (changed=2)
Failed:    1
------------
Total states run:     2

关于salt-stack - Saltstack : ignoring result of cmd.运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27917557/

相关文章:

salt-stack - 引用支柱本身的支柱值

python - 在 salt-stack 状态下编写 python 函数

salt-stack - 尝试登录远程系统时 salt-ssh 权限被拒绝

linux - saltstack : is there a way to stop updating cron files every time state. highstate 运行

ssh - 使用 saltstack ssh

mysql - 使用SaltStack创建Mysql数据库

command-line - 如何使用 salt 来测试神社的功能?

docker - 从 SaltStack 中的私有(private) Docker 注册表中提取图像

salt-stack - saltstack动态更新等主机

yaml - SLS 文件中的状态未形成为列表