【发布时间】: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