即使文件中沒有更新,我在每次運行狀態時都會寫入托管文件時遇到了一些麻煩。奇怪的是,我似乎無法找到任何有關通過谷歌或鹽文檔阻止這種情況發生的事情。SaltStack - 每次運行都會寫入受管理的文件,如果只有更新文件才寫入文件?
我的狀態被分成init.sls來部署軟件包,config.sls來配置軟件包,默認和環境特定的配置值被分成一個支柱。示例如下。
Config State Example:
{% from "amq/map.jinja" import amq with context %}
camelxml_conf:
file.managed:
- name: {{ amq.camelxml }}
- source: salt://amq/conf/camel.xml.tmpl
- template: jinja
- user: omapp
- group: omapp
- mkdirs: True
- recurse:
- user
- group
Pillar Example:
default_routes:
Route1:
from_uri: 'activemq:inputqueue1'
process_ref: 'myprocessor1'
to_uri: 'activemq:outputqueue1'
Route2:
from_uri: 'activemq:inputqueue2'
process_ref: 'myprocessor2'
to_uri: 'activemq:outputqueue2'
{% if 'qa' in grains['env'] %}
env_routes:
route1:
from_uri: 'activemq:inputqueue3'
process_ref: 'myprocessor3'
to_uri: 'activemq:outputqueue3'
{% endif %}
Camel.xml Template Example:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- routes common across all environments -->
{% for route, args in pillar.get('default_routes', {}).items() %}
<route>
<from uri="{{ args.from_uri }}"/>
<process ref="{{ args.process_ref }}"/>
<to uri="{{ args.to_uri }}"/>
</route>
{% endfor %}
<!-- routes unique to this environment -->
{% for env_route, args in pillar.get('env_routes', {}).items() %}
<route>
<from uri="{{ args.from_uri }}"/>
<process ref="{{ args.process_ref }}"/>
<to uri="{{ args.to_uri }}"/>
</route>
{% endfor %}
我做什麼完全錯了嗎?我不應該在我的支柱上動態設置數值嗎?我在想這可能是爲什麼每個州運行時都會寫一個新文件,但我不確定。
你是什麼意思?舊文件和新文件沒有區別,即使是行順序?每次在沒有其他修改的情況下運行狀態時,文件的修改時間會更新?你有跑步的輸出嗎?你使用什麼版本?鹽的行爲是不更新未修改的文件,所以如果它不斷更新它,它可能是一個錯誤。 –