saltstack / saltstack/salt

file.managed contents yaml output inconsistent

Open
#55,764 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug documentation severity-low time-estimate-sprint
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue
Setup

(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)

%> cat pillar/test.sls 
test:
  level1:
    level2: "foo"
Steps to Reproduce Issue

My goal is to read a yaml pillar and output yaml into a file.

The pipe method produces a valid YAML string as output:

%> cat salt/test.sls 
/tmp/repro.yml:
  file.managed:
    - contents: |
        {{salt['pillar.get']('test')}}
% cat /tmp/repro.yml
{'level1': {'level2': 'foo'}}

Or even pretty printed:

%> cat salt/test.sls
/tmp/repro.yml:
  file.managed:
    - contents: |
        {{salt['pillar.get']('test') | yaml(False) | indent(8)}}
%> cat /tmp/repro.yml
level1:
  level2: foo

And even without the pipe:

%> cat salt/test.sls
/tmp/repro.yml:
  file.managed:
    - contents: {{salt['pillar.get']('test') | yaml(False) | indent(8)}}
%> cat /tmp/repro.yml
level1:
  level2: foo

However many others don't work in weird ways and produce literal OrderedDict output:

%> cat salt/test.sls                 
/tmp/repro.yml:
  file.managed:
    - contents: {{salt['pillar.get']('test')}}
%> cat /tmp/repro.yml 
OrderedDict([('level1', OrderedDict([('level2', 'foo')]))])
%> cat salt/test.sls
/tmp/repro.yml:
  file.managed:
    - contents: {{salt['pillar.get']('test') | yaml}}
%>  cat /tmp/repro.yml
OrderedDict([('level1', OrderedDict([('level2', 'foo')]))])

%> cat salt/test.sls
/tmp/repro.yml:
  file.managed:
    - contents: {{salt['pillar.get']('test') | yaml(False)}}
%>  cat /tmp/repro.yml
OrderedDict([('level1', OrderedDict([('level2', 'foo')]))])

Even tojson produces Python:

%> cat salt/test.sls
/tmp/repro.yml:
  file.managed:
    - contents: {{salt['pillar.get']('test') | tojson}}
%>  cat /tmp/repro.yml
OrderedDict([('level1', OrderedDict([('level2', 'foo')]))])
Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

Salt Version:
           Salt: 2019.2.2

Dependency Versions:
           cffi: 1.11.5
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.3
      gitpython: 2.1.8
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: 0.26.0
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.26.2
         Python: 3.6.9 (default, Nov  7 2019, 10:44:02)
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.3
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.5

System Versions:
           dist: Ubuntu 18.04 bionic
         locale: UTF-8
        machine: x86_64
        release: 4.15.0-72-generic
         system: Linux
        version: Ubuntu 18.04 bionic

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided pillar/test.sls and salt/test.sls examples with file.managed on the reported Salt 2019.2.2 environment, then trace the file.managed contents entry point and its Jinja serialization behavior. Done means equivalent pillar data renders consistently as valid YAML rather than an OrderedDict representation, with regression coverage for the shown cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.