Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jinja strip white spaces option in salt master config causes a broken pg_hba.conf #241

Closed
bebosudo opened this issue Oct 1, 2018 · 2 comments

Comments

@bebosudo
Copy link
Contributor

bebosudo commented Oct 1, 2018

Hi,
I'm using this formula, along with the following lines in my salt master configuration:

jinja_env:
  trim_blocks: True
  lstrip_blocks: True

to strip empty lines in my salt states. This causes the following pg_hba.conf file:

          ID: postgresql-pg_hba
    Function: file.managed
        Name: /var/lib/pgsql/data/pg_hba.conf
      Result: True
     Comment: File /var/lib/pgsql/data/pg_hba.conf updated
     Started: 10:18:10.901757
    Duration: 6342.325 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -18,6 +18,4 @@
                   # Database administrative login by Unix domain socket
                   local   all             postgres                                peer
                   
                  -# TYPE  DATABASE        USER            ADDRESS                 METHOD
                  -host    all             all             127.0.0.1/32            md5
                  -host    all             all             ::1/128                 md5
                  +# TYPE  DATABASE        USER            ADDRESS                 METHODhost    all             all             127.0.0.1/32            md5host    all             all             ::1/128                 md5

Which is caused by lines

{{ '{0:<7} {1:<15} {2:<15} {3:<23} {4}'.format(*acl) -}}
and L23.
Do you think a pull request to remove the line strip in jinja could be feasible?

@bebosudo bebosudo changed the title jinja stripping in salt master config causes a broken pg_hba.conf jinja strip white spaces option in salt master config causes a broken pg_hba.conf Oct 1, 2018
@javierbertoli
Copy link
Member

Fixed on #244

@myii
Copy link
Member

myii commented Jan 16, 2019

#244 results in a side effect for those running with the default values of False for the Jinja block trimming/stripping environment variables:

 # TYPE  DATABASE        USER            ADDRESS                 METHOD
+
+
 local   all             all                                     peer
+
 host    all             all             127.0.0.1/32            md5
+
 host    all             all             ::1/128                 md5
+
 local   replication     all                                     peer
+
 host    replication     all             127.0.0.1/32            md5
+
 host    replication     all             ::1/128                 md5
  • Blank lines are inserted for all existing pg_hba.conf files.

Of course, the situation resolved by #244 is critical; but this side effect is an annoyance. Is there any way (similar to config.get) to check for these Jinja values and apply the fix for either setting?

CC: @vutny.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants