Salt: postgres_database.present with encoding fails on consecutive runs

Created on 17 Feb 2016  路  6Comments  路  Source: saltstack/salt

Using

postgres_database_test:
  postgres_database.present:
    - name: test
    - encoding: UTF-8
    - owner: test

the provisiong works as expected. However, running state.highstate afterwards throws an error:

[INFO    ] Executing command '/usr/bin/psql --no-align --no-readline --no-password --dbname test -v datestyle=ISO,MDY -c \'COPY (SELECT datname as "Name", pga.rolname as "Owner", pg_encoding_to_char(encoding) as "Encoding", datcollate as "Collate", datctype as "Ctype", datacl as "Access privileges", spcname as "Tablespace" FROM pg_database pgd, pg_roles pga, pg_tablespace pgts WHERE pga.oid = pgd.datdba AND pgts.oid = pgd.dattablespace) TO STDOUT WITH CSV HEADER\'' as user 'postgres' in directory '/var/lib/postgresql'
[ERROR   ] Database test has wrong parameters which couldn't be changed on fly.

Checking the database the column Encoding (from table pg_database column encoding is 6 = UTF-8) is already UTF-8 so it shouldn鈥檛 even try to change anything.

Is this a bug or am I doing something wrong here?

Bug P3 Platform State Module severity-medium stale

Most helpful comment

Problem seems to be the - in the encoding: UTF-8

removing the - and setting encoding: UTF8 fixes the problem.

All 6 comments

@hacfi, running any state twice should not succeed first and fail second, so this is likely a bug. What version of salt are you using?

Version is 2015.8.5 (Beryllium). Need any additional information?

@hacfi, I think this is enough to establish and identify the problem, thanks.

I am facing same issue:

postgres_database.present:
   - user: pgsql
   - name: test
   - encoding: UTF-8                                                                                                                                                                                                                                                           
   - lc_collate: en_US.UTF-8                                                                                                                                                                                                                                                   
   - lc_ctype: en_US.UTF-8                                                                                                                                                                                                                                                     
   - template: template0 

First time creates the database, second time I get an error:

   Comment: Database test has wrong parameters which couldn't be changed on fly.
> salt --versions
Salt Version:
           Salt: 2016.3.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.5.0
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.11 (default, Jun  5 2016, 01:18:51)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.3
            ZMQ: 4.1.4

System Versions:
           dist:   
        machine: amd64
        release: 10.3-STABLE
         system: FreeBSD
        version: Not Installed

Problem seems to be the - in the encoding: UTF-8

removing the - and setting encoding: UTF8 fixes the problem.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

Was this page helpful?
0 / 5 - 0 ratings