1

I am creating a Chef recipe that does a couple of things, amongst others a big import of data into a Postgresql database.

I am using the Supermarket 'postgresql' cookbook which allows me to create a config file via node['postgresql']['config'] attributes.

I would like to update the config in postgresql.conf during my recipe run, namely set values that cater to the big import just before I do that big import and subsequently when that is finished update those values so that are more catered to day to day operations (specifically fsync and full_page_writes 'off' before the import and turn those 'on' after).

I created ruby_block resources that enable me to update the node.default['postgresql']['config']['fsync/full_page_write'] via a notify just before and just after the import but these changes are not serialised to the postgresql.conf, I guess because the postgresql::server_conf has already run at that stage.

Is there a way that I can signal the postgresql cookbook that I would like to have the node['postgresql']['config'] serialised multiple times during a run?

  • adding run_context.include_recipe or run_context.load_recipe to my ruby_block resource does not seem to help. – Martin Bokman Oct 18 '15 at 21:32
  • Are you using an immediate notify or a delayed one? I would expect an immediate notify would do what you want if you're notifying the appropriate resource defined in postgresql::server_conf. Can you show us specifically what you're doing in your recipe? – Martin Oct 20 '15 at 9:10
  • I am unable to answer this in a few sentences so I have created this gist (gist.github.com/mbokman/…) which hopefully clarifies what I am trying to do. – Martin Bokman Oct 21 '15 at 21:12
  • I don't think you can rely on include_recipe the way you are doing. If that recipe was already included earlier, your use of it would be a no-op. Recipes run only once, regardless of how many times you include them. – Martin Oct 22 '15 at 9:13
  • Hi, thanks for your reply. I guess I have no other recourse than copying the logic from server_conf.rb and serialize the postgresql.conf myself when I want. It seems clumsy. – Martin Bokman Oct 22 '15 at 9:27
-1

Found the answer myself, this gist (https://gist.github.com/mbokman/58b826258d05f1c7bec0) shows how I did it.

  • Made a slight edit to the resources() call in the gist to prevent foodcritic from complaining. – Martin Bokman Oct 27 '15 at 20:16
  • Even for self-answered questions, please add the most relevant details from external links to prevent link-rot. – Sven Oct 31 '15 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.