Search code examples
salt-projectgitfs

Not able to execute embedded Saltstack state using gitfs


I am working with the "gitfs" feature of SaltStack in order to execute a state file. The state file uses the "include" feature to embed other two state files from the repository.

My repository has the following hierarchy:

salt 
    - dir1
             - dir3 / init.sls
             - dir4 / init.sls
    - dir2
             - dir5 / init.sls

My master file is as below:

. . .
fileserver_backend:
  - git

gitfs_remotes:
  - https://username@bitbucket.org/path/to/repo.git
. . .

The salt/dir1/dir3/init.sls contains the following:

include:
  - salt/dir2/dir5/init.sls
  - salt/dir1/dir4/init.sls
. . .

On restarting salt-master and then executing salt-run fileserver.file_list saltenv=base backend=git shows me all the files from the repository. But on running salt '' state.apply salt.dir1.dir3 -l debug I am getting the following error:

[ERROR   ] Data passed to highstate outputter is not a valid highstate return: {'<minion-id>': ['Specified SLS salt/dir2/dir5/init.sls in saltenv base is not available on the salt master or through a configured fileserver', 'Specified SLS salt/dir1/dir4/init.sls in saltenv base is not available on the salt master or through a configured fileserver']}

My system configurations are as follows:

$ salt --versions-report

Salt Version:
           Salt: 2016.3.3

Dependency Versions:
           cffi: Not Installed
       cherrypy: 3.2.2
       dateutil: 1.5
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 0.9.1
   msgpack-pure: Not Installed
 msgpack-python: 0.3.0
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.6 (default, Jun 22 2015, 17:58:13)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.0.1
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 3.13.0-91-generic
         system: Linux
        version: Ubuntu 14.04 trusty

The repository gets cached into the "/var/cache/salt/master/gitfs/refs/base/salt" path on restarting salt-master. But I found "dir2/dir5/init/sls" instead of "dir2/dir5/init.sls"

What could be the reason for this issue?


Solution

  • The issue is most likely in your include declaration. Salt's include module treats SLS files similar to Python modules. For example, you would reference a SLS file foo/bar/baz.sls as foo.bar.baz.

    Also, the init.sls file receives special treatment and enables you to treat an entire directory as a module. For example, foo.bar.baz would include either foo/bar/baz.sls or foo/bar/baz/init.sls (depending on which of them actually exists).

    In conclusion, your include statement should look like this:

    include:
      - salt.dir2.dir5
      - salt.dir1.dir4