1

My collegues are maintaining a configuration file, which is deployed to production/test/staging environments by SaltStack. I am maintaining this file by using diff to see what has changed and code the appropriate jinja snippet.

The file name is program.conf and the SaltStack version is program.conf.jinja.

program.conf has lines of the form:

variable = "value"

program.conf.jinja is:

variable = "{{ value }}"

From diff's point of view, these are different. But from my point of view, they are same. I am looking for a pragma-like feature where I can say mark the jinja file as following so that I won't get that in the output of diff:

variable = "{{ value }}" # pragma-same: variable = "value"

I will also be using that utility to generate alerts to force people to update the jinja file for any missing variable.

variable = "value" sometimes resolve to more complex stanzas like:

{% if pillar.get(...) %}
variable = {{ value }}
{% else %}
variable = {{ value + 2 }}
{% endif %}
  • Well, now it looks even more like the thing to do is to find and/or develop some sort of compiler/validator that reads the files, checks whether they are correct, and reduces/minimizes them to a bare-bones format that can be compared directly. But I’m not sure your question still makes sense. If program.conf.jinja says that oblongness might be 17 and might be 19, what can program.conf say to avoid being flagged as different? – Scott - Слава Україні Jul 15 '14 at 21:13
  • Think about the process. When someone makes a change X in program.conf, it actually means "translate change X to program.conf.jinja". When I make the change X', I am done.

    When a change Y comes in, until I make Y', I want diff to show me that I still need to translate Y to Y'.

    I can wrap a relevant change in .jinja with and hope diff to detect that and if any line around those line numbers is equal to X, it will show "no change". I am aware that this won't be as simple as that for sure.

    – Can Burak Çilingir Jul 16 '14 at 15:51

1 Answers1

1

Would you be willing to create a normalized temporary file, and compare against that?

sed 's/{{ \(.*\) }}/\1/' program.conf.jinja > temp  &&  diff program.conf temp