How can I serialize postgresql.conf multiple times during a Chef run when using cookbook postgresql?

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_writesoff‘ 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?

Answer

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

Attribution
Source : Link , Question Author : Martin Bokman , Answer Author : Martin Bokman

Leave a Comment