(SaltStack) SLS dog 中的 ID dog 不是字典

(SaltStack) ID dog in SLS dog is not a dictionary

我一直在尝试在 /etc/modules 文件中找到一个模式 (bcm2708_wdog),如果不存在,请将其添加到底部。每次尝试此操作时,我都会得到 "ID dog in SLS dog is not a dictionary"。我不知道这是什么意思。 这是文件:

dog:
  - file.replace:
    - name: /etc/modules
    - pattern: 'bcm2708_wdog'
    - append_if_not_found: True

大概应该是这样的:

dog:
  file.replace:    # <--------this line was your problem.
    - name: /etc/modules
    - pattern: 'bcm2708_wdog'
    - append_if_not_found: True

以“-”开头的行表示列表中的项目。在您的版本中,您已将顶级 "dog" 元素定义为包含字典的列表。 Salt 期望它是一个直接的字典,因此错误。

根据您的版本,2018 年

如果只用 'file.replace' 写状态而顶部没有 "dog",您将收到该消息。

file.replace: - 姓名:/etc/modules - 图案:'bcm2708_wdog' - append_if_not_found:正确