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

Chef fails when installing PostgreSQL extensions #221

Open
dvalfre opened this issue Sep 18, 2023 · 1 comment
Open

Chef fails when installing PostgreSQL extensions #221

dvalfre opened this issue Sep 18, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dvalfre
Copy link
Contributor

dvalfre commented Sep 18, 2023

Steps to reproduce:

  1. Create file /db/postgreql/entensions.json with the following structure:
{
  "<dbname>": ["hstore"]
}
  1. Run Chef on the instance.

Desired output:

  • Chef finalizes successfully and the extension is installed on Postgresql. It can be checked by connecting to the engine and running \dx.

Current behavior:

  • Chef fails with the following error:
================================================================================
Error executing action `run` on resource 'ruby_block[process extensions.json]'
================================================================================

NameError
---------
uninitialized constant Chef::Resource::PostgresqlPgExtension

Cookbook Trace: (most recent call first)
----------------------------------------
/etc/chef/recipes/cookbooks/ey-postgresql/recipes/server_configure.rb:280:in `block (3 levels) in from_file'
/etc/chef/recipes/cookbooks/ey-postgresql/recipes/server_configure.rb:279:in `each'
/etc/chef/recipes/cookbooks/ey-postgresql/recipes/server_configure.rb:279:in `block (2 levels) in from_file'

Resource Declaration:
---------------------
# In /etc/chef/recipes/cookbooks/ey-postgresql/recipes/server_configure.rb

275: ruby_block "process extensions.json" do
276: block do
277: # run_context = Chef::RunContext.new(node, {})
278: exts = JSON.parse(::File.read(node["pg_extensions_file"]))
279: exts.each do |db_name, exts|
280: run_context.resource_collection << r = Chef::Resource::PostgresqlPgExtension.new("install #{exts.join(',')} in database #{db_name}", run_context)
281: r.db_name = db_name
282: r.ext_name = exts
283: end
284: end
285: only_if { ::File.exist?(node["pg_extensions_file"]) }
286: end
287:
@dvalfre dvalfre added the bug Something isn't working label Sep 18, 2023
@dvalfre
Copy link
Contributor Author

dvalfre commented Sep 18, 2023

Workaround: add the extensions by:

  1. Connecting to the db engine;
  2. Installing the desired extension(s) by running CREATE EXTENSION <extension_name>;
  3. Checking the status by running \dx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants