Salt: file.serialize no longer indents/pretty-prints in 2016.3

Created on 26 May 2016  路  5Comments  路  Source: saltstack/salt

Upgrading to 2016.3, running state.apply showed that file.serialize states with formatter: json now produces a harder to read format with no whitespace.

Guessing this is the cause: 53dd9ae13822e181febfad66647cea9024096562 - https://github.com/saltstack/salt/pull/28906

Bug Core P3 Regression ZRELEASED - 2016.3.4 fixed-pending-your-verification severity-critical severity-medium

Most helpful comment

This not only happens with the JSON serializer but also with the YAML serializer (possible others as well):

/etc/salt/minion.d/minion.conf:
  file.serialize:
    - formatter: yaml
    - dataset_pillar: salt:minion

Now produces:

          ID: /etc/salt/minion.d/minion.conf
    Function: file.serialize
      Result: True
     Comment: File /etc/salt/minion.d/minion.conf updated
     Started: 08:58:29.165454
    Duration: 118.816 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -1,4 +1 @@
                  -log_level: warn
                  -master: master
                  -mine_interval: 10
                  -minion_id: minion
                  +{log_level: warn, master: master, mine_interval: 10, minion_id: minion}

Although the changes are still valid JSON or YAML data, this is really bad as:

  • it triggers lot of changes during highstates, although the configuration hasn't changed (which requires careful reading of what is going on)
  • those changes are very difficult to read as everything is now serialized on one line
  • it triggers additional changes as often watch statements are connected to the changes of configuration files, which is going to reload/restart daemons, etc.

All 5 comments

I can think of two possible solutions here:

  • add a readable argument to every serializer function
  • pass a serializer_options argument from the state to the serializer function

Thanks @anlutro !

This not only happens with the JSON serializer but also with the YAML serializer (possible others as well):

/etc/salt/minion.d/minion.conf:
  file.serialize:
    - formatter: yaml
    - dataset_pillar: salt:minion

Now produces:

          ID: /etc/salt/minion.d/minion.conf
    Function: file.serialize
      Result: True
     Comment: File /etc/salt/minion.d/minion.conf updated
     Started: 08:58:29.165454
    Duration: 118.816 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -1,4 +1 @@
                  -log_level: warn
                  -master: master
                  -mine_interval: 10
                  -minion_id: minion
                  +{log_level: warn, master: master, mine_interval: 10, minion_id: minion}

Although the changes are still valid JSON or YAML data, this is really bad as:

  • it triggers lot of changes during highstates, although the configuration hasn't changed (which requires careful reading of what is going on)
  • those changes are very difficult to read as everything is now serialized on one line
  • it triggers additional changes as often watch statements are connected to the changes of configuration files, which is going to reload/restart daemons, etc.

Any updates? This single issue is preventing me from upgrading.

OK, please give #35688 a whirl. Thanks.

Was this page helpful?
0 / 5 - 0 ratings