remove modify yaml constructor

which will modify the default behavior of yaml load.

Foe example, for following example (t.sls), it will cause the difference
between the content of file testa and testb, but it should be identical!

$ cat t
{%- load_yaml as vars %}
toaddr:
  - test@test.com
{%- endload -%}
{{ vars.toaddr }}
$ cat t.sls
/tmp/testa:
  file.managed:
    - source: salt://t
    - user: root
    - group: root
    - mode: "0755"
    - template: jinja

sys-power/acpid:
  pkg.installed:
    - refresh: False

/tmp/testb:
  file.managed:
    - source: salt://t
    - user: root
    - group: root
    - mode: "0755"
    - template: jinja
$ touch /tmp/test{a,b}
$ salt-call state.sls t
local:
----------
          ID: /tmp/testa
    Function: file.managed
      Result: None
     Comment: The file /tmp/testa is set to be changed
     Changes:
              ----------
              diff:
                  ---
                  +++
                  @@ -0,0 +1 @@
                  +['test@test.com']
----------
          ID: /tmp/testb
    Function: file.managed
      Result: None
     Comment: The file /tmp/testb is set to be changed
     Changes:
              ----------
              diff:
                  ---
                  +++
                  @@ -0,0 +1 @@
                  +[u'test@test.com']
This commit is contained in:
Z. Liu 2017-09-22 23:25:21 +08:00
parent e6dc4d64df
commit da15658304
2 changed files with 0 additions and 4 deletions

View file

@ -102,8 +102,6 @@ def _construct_yaml_str(self, node):
Construct for yaml
'''
return self.construct_scalar(node)
YamlLoader.add_constructor(u'tag:yaml.org,2002:str',
_construct_yaml_str)
YamlLoader.add_constructor(u'tag:yaml.org,2002:timestamp',
_construct_yaml_str)

View file

@ -80,8 +80,6 @@ def _construct_yaml_str(self, node):
Construct for yaml
'''
return self.construct_scalar(node)
YamlLoader.add_constructor(u'tag:yaml.org,2002:str',
_construct_yaml_str)
YamlLoader.add_constructor(u'tag:yaml.org,2002:timestamp',
_construct_yaml_str)