0

我正在努力学习 Salt。证明很麻烦。甚至无法绕过主配置。下面的行有什么问题?

#/etc/salt/master
file_roots:
   base:
      - /home/ubuntu/workspace/salt/states/base

salt-key -L
[ERROR   ] Error parsing configuration file: /etc/salt/master - expected '<document start>', but found '<block mapping start>'
  in "<string>", line 298, column 1:
    file_roots:
    ^




#####      File Server settings      #####
##########################################
# Salt runs a lightweight file server written in zeromq to deliver files to
# minions. This file server is built into the master daemon and does not
# require a dedicated port.

# The file server works on environments passed to the master, each environment
# can have multiple root directories, the subdirectories in the multiple file
# roots cannot match, otherwise the downloaded files will not be able to be
# reliably ensured. A base environment is required to house the top file.
# Example:
file_roots:
  base:
   - /home/ubuntu/workspace/salt/states/base
#    development:
#     - /home/ubuntu/workspace/salt/states/dev
#   dev:
#     - /srv/salt/dev/services
#     - /srv/salt/dev/states
#   prod:
#     - /srv/salt/prod/services
#     - /srv/salt/prod/states

#file_roots:
#  base:
#    - /srv/salt
4

2 回答 2

2

这是问题所在:

在 YAML 中,间距和缩进非常重要。每个级别应该有两个空格。虽然你有 2 个空格base:,但你应该有 4 个空格

- /home/ubuntu/workspace/salt/states/base

这是正确的:

file_roots:
  base:
    - /home/ubuntu/workspace/salt/states/base
于 2014-05-22T18:47:11.510 回答
1

如果不查看 /etc/salt/master 的更多相关部分,很难为您提供问题的确切答案,但您会看到格式错误的 yaml 错误。您的 file_roots 部分应类似于以下内容:

file_roots:
  base:
    - /srv/salt

这里有更多信息:http: //docs.saltstack.com/en/latest/ref/file_server/file_roots.html#directory-overlay

此外,您显示的 yaml 上方可能存在错误。如果您要发布更多配置(当然是经过消毒的),我们可以更好地帮助您。

于 2014-04-18T16:32:50.703 回答