Ver código fonte

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 anos atrás
pai
commit
9c2fe220a8
2 arquivos alterados com 29 adições e 5 exclusões
  1. +14
    -0
      README.rst
  2. +15
    -5
      linux/system/file.sls

+ 14
- 0
README.rst Ver arquivo

@@ -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 Ver arquivo

@@ -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') }}

Carregando…
Cancelar
Salvar