瀏覽代碼

Add support file.serialize in linux:system:file

Ensure presence of file to be serialized through one of the serializer modules
(see: https://docs.saltstack.com/en/latest/ref/serializers/all/index.html):
pull/152/head
Bruno Binet 6 年之前
父節點
當前提交
9c2fe220a8
共有 2 個文件被更改,包括 29 次插入5 次删除
  1. +14
    -0
      README.rst
  2. +15
    -5
      linux/system/file.sls

+ 14
- 0
README.rst 查看文件

@@ -389,6 +389,20 @@ Ensure presence of file by specifying it's contents:
/tmp/test.txt:
contents_grains: motd

Ensure presence of file to be serialized through one of the serializer modules
(see: https://docs.saltstack.com/en/latest/ref/serializers/all/index.html):

.. code-block:: yaml

linux:
system:
file:
/tmp/test.json:
serialize: json
contents:
foo: 1
bar: 'bar'

Kernel
~~~~~~


+ 15
- 5
linux/system/file.sls 查看文件

@@ -4,12 +4,16 @@
{%- for file_name, file in system.file.items() %}

linux_file_{{ file_name }}:
{%- if file.serialize is defined %}
file.serialize:
- formatter: {{ file.serialize }}
{%- if file.contents is defined %}
- dataset: {{ file.contents|yaml }}
{%- elif file.contents_pillar is defined %}
- dataset_pillar: {{ file.contents_pillar }}
{%- endif %}
{%- else %}
file.managed:
{%- if file.name is defined %}
- name: {{ file.name }}
{%- else %}
- name: {{ file_name }}
{%- endif %}
{%- if file.source is defined %}
- source: {{ file.source }}
{%- if file.hash is defined %}
@@ -24,6 +28,12 @@ linux_file_{{ file_name }}:
{%- elif file.contents_grains is defined %}
- contents_grains: {{ file.contents_grains }}
{%- endif %}
{%- endif %}
{%- if file.name is defined %}
- name: {{ file.name }}
{%- else %}
- name: {{ file_name }}
{%- endif %}
- makedirs: {{ file.get('makedirs', 'True') }}
- user: {{ file.get('user', 'root') }}
- group: {{ file.get('group', 'root') }}

Loading…
取消
儲存