【问题标题】:SaltStack: file.managed returning result: noneSaltStack:file.managed 返回结果:无
【发布时间】:2021-12-18 10:02:10
【问题描述】:

我是盐堆的新手。我只是想使用以下工作区结构将配置文件从 saltmaster 复制到 minion:

[root@saltmaster-xyz]# pwd
/srv/salt
[root@saltmaster-xyz]# ls
minion-file-copy  top.sls
[root@saltmaster-xyz]# ls minion-file-copy/
init.sls

[root@saltmaster-xyz]# cat top.sls
base:
  'minion001':
    - minion-file-copy


[root@saltmaster-xyz]# cat minion-file-copy/init.sls
file_copy:
  file.managed:
    - name: /tmp/content.cfg
    - source: salt://content.cfg
    - makedirs: True
    - force: true
    - template: jinja

[root@saltmaster-xyz]# salt 'minion001' state.apply minion-file-copy

minion001:
----------
          ID: file_copy
    Function: file.managed
        Name: /tmp/content.cfg
      Result: None
     Comment: The file /tmp/content.cfg is set to be changed
              Note: No changes made, actual changes may
              be different due to other states.
     Started: 20:58:14.008169
    Duration: 101.709 ms
     Changes:
              ----------
              newfile:
                  /tmp/ompal/content.cfg

Summary for minion001
------------
Succeeded: 1 (unchanged=1, changed=1)
Failed:    0
------------
Total states run:     1
Total run time: 101.709 ms

这里的结果是在输出中显示 none,并且在 minion 中没有在 /tmp 目录中创建带有 content.cfg 名称的文件。

【问题讨论】:

  • 好像创建了/tmp/ompal/content.cfg。另外,您可以尝试运行state.sls minion-file-copy 看看它的行为是否不同?
  • 不是它没有创建,我也尝试了 state.sls minion-file-copy 但这也不起作用。
  • 源文件在哪里?源文件必须存在于 /srv/salt 中。
  • 是的,它只在 /srv/salt 目录中。
  • Jinja 模板中有什么?该模板中有什么逻辑吗?

标签: salt-stack


【解决方案1】:

输出表明state.apply 在其配置中的某处得到test=truetest=true 可以来自很多地方,比如柱子。它不必只在命令行上发送。

请参阅https://docs.saltproject.io/en/latest/ref/states/testing.html#default-test 了解有关状态如何处理配置中的测试的更多信息。

请注意,支柱设置也计入 minion 的大多数配置信息。

【讨论】:

    猜你喜欢
    • 2014-03-01
    • 2016-08-23
    • 2021-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-21
    • 2019-02-06
    相关资源
    最近更新 更多