saltstack-formulas / nginx-formula

Nginx Salt Formula
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
163 stars 420 forks source link

[BUG] if directive #295

Open hegyre opened 2 years ago

hegyre commented 2 years ago

Your setup

Formula commit hash / release tag

2.4.0

Versions reports (master & minion)

Salt Version: Salt: 3000.3

Pillar / config used

            - location ^~ /var/_cron/:
              - include:
                - /etc/nginx/fastcgi_params
              - fastcgi_param:
                - SCRIPT_FILENAME $document_root$fastcgi_script_name
              - fastcgi_pass:
                - 127.0.0.1:9001
              - fastcgi_connect_timeout:
                - 3m
              - fastcgi_read_timeout:
                - 3m
              - if: ($exclusion_cron = "0") { return 403; }
              - fastcgi_send_timeout:
                - 3m

Bug details

Describe the bug

When migrating formula from 0.56.x to 2.4.0, I had to do small pillar updates (that's ok). However, for the if directive, the behavior is a bit special: The next directive - or the location closing bracket - is now on the same line as the if directive...

@@ -193,8 +192,8 @@
                           fastcgi_pass 127.0.0.1:9001;
                           fastcgi_connect_timeout 3m;
                           fastcgi_read_timeout 3m;
                  -        fastcgi_send_timeout 3m;
                  -        if ($exclusion_cron = "0") { return 403; }
                  +
                  +        if ($exclusion_cron = "0") { return 403; }        fastcgi_send_timeout 3m;
                       }

Expected behaviour

Next directive (or the location closing bracket) must be on a new line

Attempts to fix the bug

I found a workaround:

              - if: |
                  ($exclusion_cron = "0") { return 403; }

With that pipe, the next directive is on the new line, but it's a bit ugly and it adds an additional blank newline...

Additional context

This pillar code worked fine with this formula before 1.0.0. I've upgraded the formula to 2.4.0, and after fixing small other things, this is the only remaining one...