postgresql icon indicating copy to clipboard operation
postgresql copied to clipboard

NoMethodError when separately running postgresql_server_conf or postgresql_database

Open louraz opened this issue 5 years ago • 0 comments

:speaking_head: Foreword

Attempting to run postgresql_server_conf or postgresql_database without running postgresql_server_install (install / create) gives an error

:ghost: Brief Description

I have my install code and my config code in 2 separate cookbooks. If I try to run my config recipe by itself I get errors related to data_dir referencing helper.rb

NoMethodError undefined method `[]' for nil:NilClass

:woman_cook: Workaround

https://github.com/sous-chefs/postgresql/issues/538 saw the same issue but that one was resolved and closed out. I can also workaround it using the same method - adding this code into my recipe

ruby_block 'fix_for_postgresql_cookbook_node_run_state' do block do node.run_state['postgresql'] ||= {} node.run_state['postgresql']['version'] = '9.6' end end

:pancakes: Cookbook version

8.0.0

:woman_cook: Chef-Infra Version

Chef Infra Client 15.10.12

:tophat: Platform details

Linux RHEL 7 OS

Steps To Reproduce

Steps to reproduce the behavior:

Run a recipe containing the postgresql_server_install with method install and then again with method create. After that has run, run another recipe separately attempting to run postgresql_server_conf or postgresql_database. It errors out.

:police_car: Expected behavior

Expecting to run postgresql_server_conf or postgresql_database without errors.

:heavy_plus_sign: Additional context

louraz avatar Oct 16 '20 17:10 louraz