postfix icon indicating copy to clipboard operation
postfix copied to clipboard

Cookbook does not ensure presence of postfix table dbs

Open explody opened this issue 9 years ago • 3 comments

During testing of a wrapper cookbook, we very quickly noticed that if the .db files corresponding to a postfix table are deleted, they are not replaced unless the content of the table file is changed, which triggers execution of postmap again.

Obviously, nothing should be deleting these files but this makes it really difficult to ensure consistency of the state declared by the cookbook.

There's a simple fix - in the recipes for the various files, like transport.rb, instead of:

execute 'update-postfix-transport' do
  command "postmap #{node['postfix']['transport_db']}"
  environment PATH: "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
  action :nothing
end

It could be:

execute 'update-postfix-transport' do
  command "postmap #{node['postfix']['transport_db']}"
  environment PATH: "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios')
  action File.exist?("#{node['postfix']['transport_db'].db") ? :nothing : :run
end

Which maintains all the current behavior but also runs postmap if the db file is missing.

Thanks

explody avatar Sep 20 '15 05:09 explody

So would you want to recreate these in the event of a failure? Wouldn't you want it to blow up?

cheeseplus avatar Feb 22 '17 20:02 cheeseplus

We'd love to better understand the appropriate action to take here. If you still have thoughts on this please reopen. Thanks!

iennae avatar May 02 '17 06:05 iennae

Oh, sorry, I didn't see the notifications. IMHO, the appropriate action would be like the code snip above where the update will run if the source (text) has changed or output (db map) is missing.

@cheeseplus I get your point but in this case, no, I wouldn't want it to blow up. If one were managing the files manually and restarted postfix or ran 'newaliases' for example, the DBs would be automatically recreated if missing. There's pretty much no scenario in which I'd want the text to exist without the corresponding DB.

It's a corner case, I think, but the overhead is minuscule and since the standard tools don't make a distinction between 'create' and 'update', it makes sense to have the resource behave similarly.

explody avatar May 26 '17 13:05 explody