postgresql icon indicating copy to clipboard operation
postgresql copied to clipboard

postgresql_extension install fails - NoMethodError: undefined method `[]' for nil:NilClass

Open noellowry opened this issue 4 years ago • 0 comments

:ghost: Brief Description

Trying to install extension but fails with NoMethodError: undefined method `[]' for nil:NilClass

:pancakes: Cookbook version

9.0.3

:woman_cook: Chef-Infra Version

17.4.38

:tophat: Platform details

vSphere

:police_car: Expected behavior

Expect that extension gets installed but it ends in error

postgresql_extension 'pg_stat_statements' do
    database 'postgres'
end

17:43:52  [0;32m    vsphere-iso:   * postgresql_extension[pg_stat_statements] action create[0m
17:43:52  [0;32m    vsphere-iso:     * bash[CREATE EXTENSION pg_stat_statements] action run[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:       ================================================================================[0m
17:43:52  [0;32m    vsphere-iso:       Error executing action `run` on resource 'bash[CREATE EXTENSION pg_stat_statements]'[0m
17:43:52  [0;32m    vsphere-iso:       ================================================================================[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:       NoMethodError[0m
17:43:52  [0;32m    vsphere-iso:       -------------[0m
17:43:52  [0;32m    vsphere-iso:       undefined method `[]' for nil:NilClass[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:       Cookbook Trace: (most recent call first)[0m
17:43:52  [0;32m    vsphere-iso:       ----------------------------------------[0m
17:43:52  [0;32m    vsphere-iso:       /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/libraries/helpers.rb:147:in `data_dir'[0m
17:43:52  [0;32m    vsphere-iso:       /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/libraries/helpers.rb:175:in `follower?'[0m
17:43:52  [0;32m    vsphere-iso:       /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/resources/extension.rb:36:in `block (3 levels) in class_from_file'[0m
17:43:52  [0;32m    vsphere-iso:       /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/resources/extension.rb:31:in `block in class_from_file'[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:       Resource Declaration:[0m
17:43:52  [0;32m    vsphere-iso:       ---------------------[0m
17:43:52  [0;32m    vsphere-iso:       # In /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/resources/extension.rb[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:        31:   bash "CREATE EXTENSION #{new_resource.name}" do[0m
17:43:52  [0;32m    vsphere-iso:        32:     code create_extension_sql(new_resource)[0m
17:43:52  [0;32m    vsphere-iso:        33:     user 'postgres'[0m
17:43:52  [0;32m    vsphere-iso:        34:     action :run[0m
17:43:52  [0;32m    vsphere-iso:        35:     environment(psql_environment)[0m
17:43:52  [0;32m    vsphere-iso:        36:     not_if { follower? || extension_installed?(new_resource) }[0m
17:43:52  [0;32m    vsphere-iso:        37:   end[0m
17:43:52  [0;32m    vsphere-iso:        38: end[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:       Compiled Resource:[0m
17:43:52  [0;32m    vsphere-iso:       ------------------[0m
17:43:52  [0;32m    vsphere-iso:       # Declared in /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/resources/extension.rb:31:in `block in class_from_file'[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:       bash("CREATE EXTENSION pg_stat_statements") do[0m
17:43:52  [0;32m    vsphere-iso:         action [:run][0m
17:43:52  [0;32m    vsphere-iso:         default_guard_interpreter :default[0m
17:43:52  [0;32m    vsphere-iso:         interpreter "bash"[0m
17:43:52  [0;32m    vsphere-iso:         declared_type :bash[0m
17:43:52  [0;32m    vsphere-iso:         cookbook_name "resilient-app-packer"[0m
17:43:52  [0;32m    vsphere-iso:         code "/usr/bin/psql -c \"CREATE EXTENSION IF NOT EXISTS \\\"pg_stat_statements\\\"\" -d postgres -U postgres --port 5432"[0m
17:43:52  [0;32m    vsphere-iso:         domain nil[0m
17:43:52  [0;32m    vsphere-iso:         user "postgres"[0m
17:43:52  [0;32m    vsphere-iso:         environment {}[0m
17:43:52  [0;32m    vsphere-iso:         not_if { #code block }[0m
17:43:52  [0;32m    vsphere-iso:       end[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:       System Info:[0m
17:43:52  [0;32m    vsphere-iso:       ------------[0m
17:43:52  [0;32m    vsphere-iso:       chef_version=17.4.38[0m
17:43:52  [0;32m    vsphere-iso:       platform=redhat[0m
17:43:52  [0;32m    vsphere-iso:       platform_version=7.8[0m
17:43:52  [0;32m    vsphere-iso:       ruby=ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux][0m
17:43:52  [0;32m    vsphere-iso:       program_name=/bin/chef-solo[0m
17:43:52  [0;32m    vsphere-iso:       executable=/opt/chef/bin/chef-solo[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:     ================================================================================[0m
17:43:52  [0;32m    vsphere-iso:     Error executing action `create` on resource 'postgresql_extension[pg_stat_statements]'[0m
17:43:52  [0;32m    vsphere-iso:     ================================================================================[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:     NoMethodError[0m
17:43:52  [0;32m    vsphere-iso:     -------------[0m
17:43:52  [0;32m    vsphere-iso:     bash[CREATE EXTENSION pg_stat_statements] (/tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/resources/extension.rb line 31) had an error: NoMethodError: undefined method `[]' for nil:NilClass[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:     Cookbook Trace: (most recent call first)[0m
17:43:52  [0;32m    vsphere-iso:     ----------------------------------------[0m
17:43:52  [0;32m    vsphere-iso:     /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/libraries/helpers.rb:147:in `data_dir'[0m
17:43:52  [0;32m    vsphere-iso:     /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/libraries/helpers.rb:175:in `follower?'[0m
17:43:52  [0;32m    vsphere-iso:     /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/resources/extension.rb:36:in `block (3 levels) in class_from_file'[0m
17:43:52  [0;32m    vsphere-iso:     /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/resources/extension.rb:31:in `block in class_from_file'[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:     Resource Declaration:[0m
17:43:52  [0;32m    vsphere-iso:     ---------------------[0m
17:43:52  [0;32m    vsphere-iso:     # In /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/resilient-app-packer/recipes/default.rb[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:       1: postgresql_extension 'pg_stat_statements' do[0m
17:43:52  [0;32m    vsphere-iso:       2:     database 'postgres'[0m
17:43:52  [0;32m    vsphere-iso:       3: end[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:     Compiled Resource:[0m
17:43:52  [0;32m    vsphere-iso:     ------------------[0m
17:43:52  [0;32m    vsphere-iso:     # Declared in /tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/resilient-app-packer/recipes/default.rb:1:in `from_file'[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:     postgresql_extension("pg_stat_statements") do[0m
17:43:52  [0;32m    vsphere-iso:       action [:create][0m
17:43:52  [0;32m    vsphere-iso:       default_guard_interpreter :default[0m
17:43:52  [0;32m    vsphere-iso:       declared_type :postgresql_extension[0m
17:43:52  [0;32m    vsphere-iso:       cookbook_name "resilient-app-packer"[0m
17:43:52  [0;32m    vsphere-iso:       recipe_name "default"[0m
17:43:52  [0;32m    vsphere-iso:       database "postgres"[0m
17:43:52  [0;32m    vsphere-iso:       extension "pg_stat_statements"[0m
17:43:52  [0;32m    vsphere-iso:       user "postgres"[0m
17:43:52  [0;32m    vsphere-iso:     end[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso:     System Info:[0m
17:43:52  [0;32m    vsphere-iso:     ------------[0m
17:43:52  [0;32m    vsphere-iso:     chef_version=17.4.38[0m
17:43:52  [0;32m    vsphere-iso:     platform=redhat[0m
17:43:52  [0;32m    vsphere-iso:     platform_version=7.8[0m
17:43:52  [0;32m    vsphere-iso:     ruby=ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux][0m
17:43:52  [0;32m    vsphere-iso:     program_name=/bin/chef-solo[0m
17:43:52  [0;32m    vsphere-iso:     executable=/opt/chef/bin/chef-solo[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso: Recipe: timezone_iii::rhel7[0m
17:43:52  [0;32m    vsphere-iso:   * execute[tzdata-update] action run (skipped due to only_if)[0m
17:43:52  [0;32m    vsphere-iso:[0m
17:43:52  [0;32m    vsphere-iso: Running handlers:[0m
17:43:52  [0;32m    vsphere-iso: [2021-09-03T16:43:52+00:00] ERROR: Running exception handlers[0m
17:43:52  [0;32m    vsphere-iso: Running handlers complete[0m
17:43:52  [0;32m    vsphere-iso: [2021-09-03T16:43:52+00:00] ERROR: Exception handlers complete[0m
17:43:52  2021/09/03 16:43:52 [INFO] 0 bytes written for 'stderr'
17:43:52  2021/09/03 16:43:52 packer-builder-vsphere-iso plugin: [ERROR] Remote command exited with '1': sudo chef-solo --no-color -c /tmp/packer-chef-solo/solo.rb -j /tmp/packer-chef-solo/node.json
17:43:52  2021/09/03 16:43:52 packer-builder-vsphere-iso plugin: [INFO] RPC endpoint: Communicator ended with: 1
17:43:52  2021/09/03 16:43:52 [INFO] 14219 bytes written for 'stdout'
17:43:52  2021/09/03 16:43:52 [INFO] RPC client: Communicator ended with: 1
17:43:52  2021/09/03 16:43:52 [INFO] RPC endpoint: Communicator ended with: 1
17:43:52  2021/09/03 16:43:52 packer-provisioner-chef-solo plugin: [INFO] 14219 bytes written for 'stdout'
17:43:52  2021/09/03 16:43:52 packer-provisioner-chef-solo plugin: [INFO] 0 bytes written for 'stderr'
17:43:52  2021/09/03 16:43:52 packer-provisioner-chef-solo plugin: [INFO] RPC client: Communicator ended with: 1
17:43:52  [0;32m    vsphere-iso: Infra Phase failed. 49 resources updated in 08 minutes 30 seconds[0m
17:43:52  [0;32m    vsphere-iso: [2021-09-03T16:43:52+00:00] FATAL: Stacktrace dumped to /tmp/packer-chef-solo/local-mode-cache/cache/chef-stacktrace.out[0m
17:43:52  [0;32m    vsphere-iso: [2021-09-03T16:43:52+00:00] FATAL: ---------------------------------------------------------------------------------------[0m
17:43:52  [0;32m    vsphere-iso: [2021-09-03T16:43:52+00:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT[0m
17:43:52  [0;32m    vsphere-iso: [2021-09-03T16:43:52+00:00] FATAL: ---------------------------------------------------------------------------------------[0m
17:43:52  [0;32m    vsphere-iso: [2021-09-03T16:43:52+00:00] FATAL: NoMethodError: postgresql_extension[pg_stat_statements] (resilient-app-packer::default line 1) had an error: NoMethodError: bash[CREATE EXTENSION adminpack] (/tmp/packer-chef-solo/local-mode-cache/cache/cookbooks/postgresql/resources/extension.rb line 31) had an error: NoMethodError: undefined method `[]' for nil:NilClass[0m

:heavy_plus_sign: Additional context

Is postgresql_extension working as described in readme?

noellowry avatar Sep 07 '21 11:09 noellowry