Browse Source

Merge pull request #152 from bbinet/file.serialize

Add support file.serialize in linux:system:file
pull/153/head
Filip Pytloun 6 years ago
parent
commit
41b86940bb
No account linked to committer's email address
2 changed files with 29 additions and 5 deletions
  1. +14
    -0
      README.rst
  2. +15
    -5
      linux/system/file.sls

+ 14
- 0
README.rst View File

/tmp/test.txt: /tmp/test.txt:
contents_grains: motd 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 Kernel
~~~~~~ ~~~~~~



+ 15
- 5
linux/system/file.sls View File

{%- for file_name, file in system.file.items() %} {%- for file_name, file in system.file.items() %}


linux_file_{{ file_name }}: 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: file.managed:
{%- if file.name is defined %}
- name: {{ file.name }}
{%- else %}
- name: {{ file_name }}
{%- endif %}
{%- if file.source is defined %} {%- if file.source is defined %}
- source: {{ file.source }} - source: {{ file.source }}
{%- if file.hash is defined %} {%- if file.hash is defined %}
{%- elif file.contents_grains is defined %} {%- elif file.contents_grains is defined %}
- contents_grains: {{ file.contents_grains }} - contents_grains: {{ file.contents_grains }}
{%- endif %} {%- endif %}
{%- endif %}
{%- if file.name is defined %}
- name: {{ file.name }}
{%- else %}
- name: {{ file_name }}
{%- endif %}
- makedirs: {{ file.get('makedirs', 'True') }} - makedirs: {{ file.get('makedirs', 'True') }}
- user: {{ file.get('user', 'root') }} - user: {{ file.get('user', 'root') }}
- group: {{ file.get('group', 'root') }} - group: {{ file.get('group', 'root') }}

Loading…
Cancel
Save