SaltStack:调用sls文件的单个状态


12

我无法调用sls文件的单个状态。

整个sls文件有效

这有效:

salt-ssh w123 state.sls monitoring

这有效:

salt-ssh w123 state.show_sls monitoring

以上输出的一项:

monitoring_packages:
    ----------
    __env__:
        base
    __sls__:
        monitoring.packages
    pkg:
        |_
          ----------
          pkgs:
              - python-psutil
        - installed
        |_
          ----------
          order:
              10000

我尝试了什么

现在,我只想调用monitoring_packages,而不是整个sls文件:

失败:

salt:/srv # salt-ssh w123 state.sls_id monitoring_packages  monitoring
w123:
    Data failed to compile:
----------
    No matching sls found for 'monitoring' in env 'base'

失败:

salt:/srv # salt-ssh w123 state.single monitoring.monitoring_packages
w123:
    TypeError encountered executing state.single: single() takes at least 2 arguments (1 given)

如何称呼我的单身状态monitoring_packages

salt:/srv # salt-ssh --version
salt-ssh 2015.8.3 (Beryllium)

Answers:


11

我碰到了这篇文章,同时也试图弄清楚如何通过常规的Salt调用(例如,不是salt-ssh)来做到这一点。

如果您具有以下SLS文件(foo.sls):

bar:
   file.managed:
       - source: salt://some/file

您可以运行以下命令以仅在状态文件中执行该条目:

salt '*' state.sls_id bar foo

再说一次,我也不知道。我在Google小组讨论的评论中找到了答案,该评论指向此处的提交。



0
salt '*target*' state.sls  monitoring.<sls_file_name> <task name> -l debug

示例:假设我有一个名为ssettings.sls的sls文件,并且处于Elasticserach状态,并且在该文件中,假设我有任务restart_elastic_search,现在我要调用此特定任务。

salt '*elastic*' state.sls  elasticsearch.settings restart_elastic_search -l debug
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.