Search code examples
salt-project

salt-ssh No matching sls found for 'copy.sls' in env 'base'


I am trying to copy the files from my salt master to the minon using salt-ssh with file.managed module. but it is giving the below error...

[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

Entries from /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'

Solution

  • I noticed that, if i'll put the file to copied into the same Directory where copy.sls exits ie in my case /srv/salt then it works.

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

    salt-ssh '*' state.sls copy

    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