saltstack-formulas/postgres-formula

State postgres_extension-uuid-ossp fails

noelmcloughlin opened this issue · 6 comments

Needs investigation. Pillars based on defaults in pillar.example. OpenSUSE Leap 42

[INFO  ]  Failed to create ext: uuid-ossp
[ERROR] Failed to install extension uuid-ossp

This was a formula rerun.

The root cause may be pillar related. @vutny

Using these Pillars gives mixed results on opensuse. Might need to rerun formula to look for pattern.

  # databases to be created
  databases:
    db1:
      owner: 'localUser'
      template: 'template0'
      lc_ctype: 'en_US.UTF-8'
      lc_collate: 'en_US.UTF-8'
    db2:
      owner: 'remoteUser'
      template: 'template0'
      lc_ctype: 'en_US.UTF-8'
      lc_collate: 'en_US.UTF-8'
      tablespace: 'my_space'
      # set custom schema
      schemas:
        public:
          owner: 'localUser'
      # enable per-db extension
      extensions:
        uuid-ossp:
          schema: 'public'


  # optional schemas to enable on database
  schemas:
    uuid_ossp:
      dbname: db1
      owner: localUser

  # optional extensions to install in schema
  extensions:
    uuid-ossp:
      schema: uuid_ossp
      maintenance_db: db1
    #postgis: {}

Upstream Postgresql-9.6 STATE FAILED

 ID: postgres_database-db2
    Function: postgres_database.present
        Name: db2
      Result: True
     Comment: The database db2 has been created
     Started: 23:55:15.653317
    Duration: 563.336 ms
     Changes:
              ----------
              db2:
                  Present
    Warnings: 'extensions' and 'schemas' are invalid keyword arguments for
              'postgres_database.present'. If you were trying to pass additional
              data to be used in a template context, please populate 'context'
              with 'key: value' pairs. Your approach will work until Salt Oxygen
              is out. Please update your state files.
----------
          ID: postgres_schema-uuid_ossp
    Function: postgres_schema.present
        Name: uuid_ossp
      Result: True
     Comment: Schema uuid_ossp has been created in database db1
     Started: 23:55:16.217597
    Duration: 188.469 ms
     Changes:
              ----------
              uuid_ossp:
                  Present
----------
          ID: postgres_extension-uuid-ossp
    Function: postgres_extension.present
        Name: uuid-ossp
      Result: False
     Comment: Failed to install extension uuid-ossp
     Started: 23:55:16.407367
    Duration: 234.97 ms

Upstream Postgresql-10 STATE SUCCEEDED

      ID: postgres_database-db2
    Function: postgres_database.present
        Name: db2
      Result: True
     Comment: The database db2 has been created
     Started: 20:35:12.027197
    Duration: 634.164 ms
     Changes:  
              ----------
              db2:
                  Present
    Warnings: 'extensions' and 'schemas' are invalid keyword arguments for
              'postgres_database.present'. If you were trying to pass additional
              data to be used in a template context, please populate 'context'
              with 'key: value' pairs. Your approach will work until Salt Oxygen
              is out. Please update your state files.
----------
          ID: postgres_schema-uuid_ossp
    Function: postgres_schema.present
        Name: uuid_ossp
      Result: True
     Comment: Schema uuid_ossp has been created in database db1
     Started: 20:35:12.662412
    Duration: 220.195 ms
     Changes:
              ----------
              uuid_ossp:
                  Present
----------
          ID: postgres_extension-uuid-ossp
    Function: postgres_extension.present
        Name: uuid-ossp
      Result: True
     Comment: The extension uuid-ossp has been installed
     Started: 20:35:12.883997
    Duration: 380.634 ms
     Changes:

Caused by missing postgresql-contrib package. See #176

Here is one solution - only install postgres-contrib - when extensions are defined. This package contains "extensions and addons not part of core" according to packaging info.

{%- if postgres.extensions %}
  {%- set pkgs = [postgres.pkg] + [postgres.pkg_contrib] + postgres.pkgs_extra %}
{%- else %}
  {%- set pkgs = [postgres.pkg] + postgres.pkgs_extra %}
{% endif %}

Other solution suggestions welcome.

The issue described in this ticket concerns one extension (uuid-ossp) that failed on PG 9.6 but worked on PG 10. Possibly uuid-ossp moved from contrib to core in 10 release.
PG has many extensions.

No time to look at this issue. closing for now.