【问题标题】:Not able to execute embedded Saltstack state using gitfs无法使用 gitfs 执行嵌入式 Saltstack 状态
【发布时间】:2016-10-06 10:17:49
【问题描述】:

我正在使用 SaltStack 的“gitfs”功能来执行状态文件。 状态文件使用“包含”功能嵌入存储库中的其他两个状态文件。

我的存储库具有以下层次结构:

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

我的主文件如下:

. . .
fileserver_backend:
  - git

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

salt/dir1/dir3/init.sls 包含以下内容:

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

重启 salt-master 然后执行 salt-run fileserver.file_list saltenv=base backend=git 向我显示存储库中的所有文件。 但在跑步时 salt '' state.apply salt.dir1.dir3 -l debug 我收到以下错误:

[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']}

我的系统配置如下:

$ 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

在重新启动 salt-master 时,存储库会缓存到“/var/cache/salt/master/gitfs/refs/base/salt”路径中。 但我发现“dir2/dir5/init/sls”而不是“dir2/dir5/init.sls”

此问题的原因可能是什么?

【问题讨论】:

    标签: salt-stack gitfs


    【解决方案1】:

    问题很可能出现在您的include 声明中。 Salt 的 include 模块将 SLS 文件视为类似于 Python 模块。例如,您可以将 SLS 文件 foo/bar/baz.sls 引用为 foo.bar.baz

    此外,init.sls 文件会受到特殊处理,使您能够将整个目录视为一个模块。例如,foo.bar.baz 将包括 foo/bar/baz.slsfoo/bar/baz/init.sls(取决于它们中的哪一个实际存在)。

    总之,您的include 语句应如下所示:

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

    【讨论】:

    • 谢谢,赫尔伯特。我应该如何访问文件 dir2/dir5/abc.conf?应该是dir2.dir5.abc.conf
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-07
    • 2017-02-20
    • 1970-01-01
    相关资源
    最近更新 更多