From d93caa21b6a9209efa5532536accc4052cf575b1 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sun, 18 Oct 2020 12:31:17 -0700 Subject: [PATCH] Ensure all postmap files are rebuilt immediately if needed This fixes a race condition where postmap files are updated but not generated to .db files before postfix has been started or restarted. By running these immediately on updates, this ensures that the .db files exist properly. Signed-off-by: Lance Albertson --- CHANGELOG.md | 4 ++++ recipes/_common.rb | 6 +++--- recipes/access.rb | 2 +- recipes/aliases.rb | 2 +- recipes/relay_restrictions.rb | 2 +- recipes/transports.rb | 2 +- recipes/virtual_aliases.rb | 2 +- recipes/virtual_aliases_domains.rb | 2 +- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03a3b99..11858a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This file is used to list changes made in each version of the postfix cookbook. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +- Ensure all postmap files are rebuilt immediately if needed + ## 5.4.0 - 2020-10-11 ### Changed diff --git a/recipes/_common.rb b/recipes/_common.rb index 88d6eee..260a9fb 100644 --- a/recipes/_common.rb +++ b/recipes/_common.rb @@ -131,7 +131,7 @@ unless node['postfix']['sender_canonical_map_entries'].empty? owner 'root' group node['root_group'] mode '0644' - notifies :run, 'execute[update-postfix-sender_canonical]' + notifies :run, 'execute[update-postfix-sender_canonical]', :immediately notifies :reload, 'service[postfix]' end @@ -148,7 +148,7 @@ unless node['postfix']['smtp_generic_map_entries'].empty? owner 'root' group node['root_group'] mode '0644' - notifies :run, 'execute[update-postfix-smtp_generic]' + notifies :run, 'execute[update-postfix-smtp_generic]', :immediately notifies :reload, 'service[postfix]' end @@ -165,7 +165,7 @@ unless node['postfix']['recipient_canonical_map_entries'].empty? owner 'root' group node['root_group'] mode '0644' - notifies :run, 'execute[update-postfix-recipient_canonical]' + notifies :run, 'execute[update-postfix-recipient_canonical]', :immediately notifies :reload, 'service[postfix]' end diff --git a/recipes/access.rb b/recipes/access.rb index d774347..cfe5dbd 100644 --- a/recipes/access.rb +++ b/recipes/access.rb @@ -23,5 +23,5 @@ end template node['postfix']['access_db'] do source 'access.erb' - notifies :run, 'execute[update-postfix-access]' + notifies :run, 'execute[update-postfix-access]', :immediately end diff --git a/recipes/aliases.rb b/recipes/aliases.rb index dcdbb4d..f8eec97 100644 --- a/recipes/aliases.rb +++ b/recipes/aliases.rb @@ -25,5 +25,5 @@ end template node['postfix']['aliases_db'] do source 'aliases.erb' - notifies :run, 'execute[update-postfix-aliases]' + notifies :run, 'execute[update-postfix-aliases]', :immediately end diff --git a/recipes/relay_restrictions.rb b/recipes/relay_restrictions.rb index de576e9..08aabcd 100644 --- a/recipes/relay_restrictions.rb +++ b/recipes/relay_restrictions.rb @@ -25,5 +25,5 @@ end template node['postfix']['relay_restrictions_db'] do source 'relay_restrictions.erb' - notifies :run, 'execute[update-postfix-relay-restrictions]' + notifies :run, 'execute[update-postfix-relay-restrictions]', :immediately end diff --git a/recipes/transports.rb b/recipes/transports.rb index 7304712..5436ae6 100644 --- a/recipes/transports.rb +++ b/recipes/transports.rb @@ -25,5 +25,5 @@ end template node['postfix']['transport_db'] do source 'transport.erb' - notifies :run, 'execute[update-postfix-transport]' + notifies :run, 'execute[update-postfix-transport]', :immediately end diff --git a/recipes/virtual_aliases.rb b/recipes/virtual_aliases.rb index 8c79d87..7047807 100644 --- a/recipes/virtual_aliases.rb +++ b/recipes/virtual_aliases.rb @@ -23,6 +23,6 @@ end template node['postfix']['virtual_alias_db'] do source 'virtual_aliases.erb' - notifies :run, 'execute[update-postfix-virtual-alias]' + notifies :run, 'execute[update-postfix-virtual-alias]', :immediately notifies :restart, 'service[postfix]' end diff --git a/recipes/virtual_aliases_domains.rb b/recipes/virtual_aliases_domains.rb index 6c61152..3ded82d 100644 --- a/recipes/virtual_aliases_domains.rb +++ b/recipes/virtual_aliases_domains.rb @@ -23,6 +23,6 @@ end template node['postfix']['virtual_alias_domains_db'] do source 'virtual_aliases_domains.erb' - notifies :run, 'execute[update-postfix-virtual-alias-domains]' + notifies :run, 'execute[update-postfix-virtual-alias-domains]', :immediately notifies :restart, 'service[postfix]' end