Allow managing empty files

Without this patch, specifying an empty file like this:

empty-file:
    file.managed:
        - name: /tmp/empty
        - contents: ''

Did not actually ensure that the file was empty, since the check for content
sources didn't separate between unset values and the empty string.
This commit is contained in:
Tarjei Husøy 2016-01-29 21:54:24 -08:00
parent 4008e1719a
commit c6244b46ac

View file

@ -1385,8 +1385,9 @@ def managed(name,
'name': name,
'result': True}
content_sources = (contents, contents_pillar, contents_grains)
contents_count = len(
[x for x in (contents, contents_pillar, contents_grains) if x]
[x for x in content_sources if x is not None]
)
if source and contents_count > 0: