【问题标题】:salt-ssh No matching sls found for 'copy.sls' in env 'base'salt-ssh 在环境“base”中找不到“copy.sls”的匹配 sls
【发布时间】:2018-10-03 17:14:07
【问题描述】:

我正在尝试使用 salt-ssh 将文件从我的 salt master 复制到 minon 带有file.managed 模块。但它给出了以下错误......

[salt]# pwd
/srv/salt
[salt]# ls -l
total 20
-rw-r--r-- 1 root root  80 Sep  4 21:37 copy.sls
-rw-r--r-- 1 root root  47 Sep  3 04:52 lftp_install.sls
-rw-r--r-- 1 root root  44 Sep  3 04:52 lftp_remove.sls
-rw-r--r-- 1 root root 124 Sep  3 04:50 lftp.sls
-rw-r--r-- 1 root root  65 Sep  3 04:53 Service_check.sls
[salt]# cat copy.sls
add script:
    file.managed:
    - name: testSalt
    - source: /root/testSalt
    - dest: /tmp/testSalt

来自/etc/salt/master的条目

file_roots:
  base:
    - /srv/salt

[salt]# salt-ssh 'KK' state.apply copy.sls

KK:
    - No matching sls found for 'copy.sls' in env 'base'


When i ran this into the debug mode, it gives as follows..

[DEBUG   ] Could not find file from saltenv 'base', 'salt://copy/sls.sls'
[DEBUG   ] Could not find file from saltenv 'base', 'salt://copy/sls/init.sls'
[DEBUG   ] LazyLoaded nested.output
KK:
    - No matching sls found for 'copy.sls' in env 'base'

【问题讨论】:

  • 始终使用 yaml lint 检查器来验证缩进中没有混合制表符和空格。 Saltstack 在遇到不正确的 yaml 语法时并不总是显示正确的异常错误。
  • 我检查了,我没有看到任何缩进或制表符空间!
  • 嘿,你的 top.sls 在哪里?
  • @mootmoot,我没有 top.sls。但我得到了它的工作。

标签: salt-stack


【解决方案1】:

我注意到,如果我将要复制的文件放入 copy.sls 退出的同一目录中,即在我的情况下为 /srv/salt,那么它可以工作。

# cat copy.sls
add script:
    file.managed:
    - name: /opt/testSalt
    - source: salt://testSalt
    - user: root
    - mode: 644

salt-ssh '*' state.sls 复制

KK:
----------
          ID: add script
    Function: file.managed
        Name: /opt/testSalt
      Result: True
     Comment: File /opt/testSalt updated
     Started: 07:19:44.332582
    Duration: 20.366 ms
     Changes:
              ----------
              diff:
                  ---
                  +++
                  @@ -1,1 +1,2 @@
                   salt copy test
                  +second commit

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-11
    • 2019-03-08
    • 1970-01-01
    • 2021-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多