postgres_database module does not work with non-English locale #2866

rhertzog opened this Issue Dec 11, 2012 · 1 comment

2 participants


I was wondering why postgres_database kept telling me that it did not manage to create the database. In truth, the database had been correctly created once but the subsequent calls fail while trying to recreate the database.

And the reason the code tries to recreate the database is that db_exists fails to identify the existing database because db_list returns a structure with localized field names:

$ sudo salt librement postgres.db_list runas=postgres
{'librement': [[['Nom', 'librement'],
                ['Propri\xc3\xa9taire', 'librement'],
                ['Encodage', 'UTF8'],
                ['Collationnement', 'fr_FR.UTF-8'],
                ['Type caract.', 'fr_FR.UTF-8']],

And this just mimicks the output of psql -l:

$ sudo -u postgres psql -l
                                  Liste des bases de données
    Nom    | Propriétaire | Encodage | Collationnement | Type caract. |    Droits d'accès     
 librement | librement    | UTF8     | fr_FR.UTF-8     | fr_FR.UTF-8  | 

The code should really set LC_ALL=C when calling "psql -l" (easy to do with the env parameter of Or maybe it should use something more low level than "psql -l" because the end-user output formatting of psql -l is really a misfeature in salt's context.

Salt Stack member

Thanks for the heads up here. Right now the postgress modules need some more attention to bring them up to a higher level. They have been completely contributed and we are planning to audit them in the next few weeks. Any help will be appreciated and we will get this issue sorted out.

@thatch45 thatch45 pushed a commit that closed this issue Dec 17, 2012
@slafs slafs db_list now runs a query instead of `psql -l`
this should fix #2866
@thatch45 thatch45 closed this in f51d1ec Dec 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment