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

postgresql_psql failes with "no parameter named 'instance' #1601

Open
absld opened this issue Jul 1, 2024 · 5 comments
Open

postgresql_psql failes with "no parameter named 'instance' #1601

absld opened this issue Jul 1, 2024 · 5 comments

Comments

@absld
Copy link

absld commented Jul 1, 2024

Describe the Bug

I'm using puppetlabs-postgresql 10.3.0 together with puppetlabs-puppetdb 8.1.0.
In database/postgresql.pp manifest of puppetlabs-puppetdb, postgresql::server::extension class is called:

postgresql::server::extension { 'pg_trgm':
        database => $database_name,
        require  => Postgresql::Server::Db[$database_name],
        port     => $port,
      }

Within postgresql::server::extension, $instance has a default set to 'main'.
Then, postgresql_psql type is called the following way:

case $ensure {
    'present': {
      $command = "CREATE EXTENSION \"${extension}\""
      $unless_mod = undef
      $psql_cmd_require = $package_name ? {
        undef   => $default_psql_require,
        default => [$default_psql_require, Package[$package_name]],
      }
      $psql_cmd_before = []
    }

    'absent': {
      $command = "DROP EXTENSION \"${extension}\""
      $unless_mod = 'NOT '
      $psql_cmd_require = $default_psql_require
      $psql_cmd_before = $package_name ? {
        undef   => [],
        default => Package[$package_name],
      }
    }

    default: {
      fail("Unknown value for ensure '${ensure}'.")
    }
  }

  $port_override = pick($connect_settings['PGPORT'], $port)

  postgresql_psql { "${database}: ${command}":
    psql_user        => $user,
    psql_group       => $group,
    psql_path        => $psql_path,
    connect_settings => $connect_settings,
    db               => $database,
    port             => $port_override,
    command          => $command,
    instance         => $instance,
    unless           => "SELECT 1 WHERE ${unless_mod}EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extension}')",
    require          => $psql_cmd_require,
    before           => $psql_cmd_before,
  }

Unfortunately, this results in the following error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: no parameter named 'instance' (file: /data/puppet/code/environments/testing/modules/postgresql/manifests/server/extension.pp, line: 83) on Postgresql_psql[puppetdb: CREATE EXTENSION "pg_trgm"] (file: /data/puppet/code/environments/testing/modules/postgresql/manifests/server/extension.pp, line: 83) on node *****.***.lan

My guess is that this fails due to quoting problems. A string containing double quotes is assigned to $command variable.
Maybe they break the double quotes in postgresql_psql { "${database}: ${command}":.

Expected Behavior

No mysterious error complaining about missing parameters which are acutally properly defined.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Update PuppetDB OS from Ubuntu 20.04 to 22.04
  2. Update Puppet Modules
    2.1 mod 'puppet-puppetboard', '9.0.0' => mod 'puppet-puppetboard', '10.0.0'
    2.2 mod 'puppetlabs-puppetdb', '7.13.0' => mod 'puppetlabs-puppetdb', '8.1.0'
    2.3 mod 'puppetlabs-postgresql', '9.0.3' => mod 'puppetlabs-postgresql', '10.3.0'
  3. Run Puppet @ PuppetDB server

Environment

  • Puppet Server Version [8.6.0]
  • Puppet Agent Version [8.7.0]
  • Platform [Ubuntu 22.04]
@waldman
Copy link

waldman commented Jul 9, 2024

I'm having exactly the same issue... Any clue on how to mitigate it?

(And I really mean exactly the same... also triggered by PuppetDB module)

@flepoutre
Copy link

Hello, same here ...
Any news please ?
Thanks.

@ekohl
Copy link
Collaborator

ekohl commented Jul 18, 2024

When you deploy your environment, do you generate types? https://www.puppet.com/docs/puppet/8/environment_isolation.html

@flepoutre
Copy link

When you deploy your environment, do you generate types? https://www.puppet.com/docs/puppet/8/environment_isolation.html

yes

@absld
Copy link
Author

absld commented Sep 6, 2024

Hello all,

just gave that another try. After generating types like recommended by @ekohl, I was able to successfully run puppet.
@flepoutre please check whether you really generate types as this solved the issue for me.

For all who also use the puppetboard module of voxpupuli: There is a issue within the puppet-python module in its current version. You need to use the latest git commit from the repository instead of the latest tag at the moment. Stumbled upon this problem after I got the puppetlabs-postgresql module working.

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

No branches or pull requests

5 participants