【问题标题】:Is it possible to do test state.apply through salt-api?是否可以通过 salt-api 进行测试 state.apply?
【发布时间】:2020-04-05 22:16:42
【问题描述】:

有没有办法:

salt '*' state.apply nginx test=True

通过salt-api?

我正在这样做:

curl -sSk http://salt:8000
-H 'Accept: application/x-yaml'     
-H 'X-Auth-Token: token'    
-d client=local     
-d tgt='*'     
-d fun=state.apply    
-d arg=nginx    
-d test=True

但它实际上应用了新状态。

提前致谢!

【问题讨论】:

    标签: api curl salt-stack salt


    【解决方案1】:

    curl -sSk http://salt:8000/run 而不是 curl -sSk http://salt:8000

    您是否在每个选项的末尾使用\

    否则看起来不错,你运行的是什么版本的盐?

    https://salt-sproxy.readthedocs.io/en/latest/salt_api.html

    【讨论】:

      【解决方案2】:

      最后,我找到了一种使用测试选项通过salt-api 执行state.apply 的方法。

      我只需要:-d arg='test='true''

      完整请求示例:

      curl -sSk http://salt:8000 \ 
      -H 'Accept: application/x-yaml' \    
      -H 'X-Auth-Token: token' \ 
      -d client=local \ 
      -d tgt='*' \ 
      -d fun='state.apply' \ 
      -d arg='nginx' \ 
      -d arg='test='true'' 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-09
        • 2016-05-15
        • 1970-01-01
        • 2014-01-29
        相关资源
        最近更新 更多