thias / puppet-postfix

Puppet Postfix module
Other
17 stars 117 forks source link

Modification Request #88

Open sellerthorpe opened 8 years ago

sellerthorpe commented 8 years ago

Good morning!

I love the module, and it has worked very well for me with a couple slight modification for my environment. I wanted to contribute to the project by letting you know what I tweaked, and seeing if this falls in line with what you've done. Hopefully you would like to add these changes to a future release, as it could help others who have a similar need.

  1. I had to add data content support for both a canonical database and generic database in the server.pp file. While you do have support for the main.cf parameters, there is currently no way to populate the files themselves through an automated fashion, which is what I was after. --> $canonical_data = [], $generic_data = [], ..... And hashed the default files at the end of server.pp. --> postfix::dbfile { 'canonical': content => template('postfix/canonical.erb'), } postfix::dbfile { 'generic': content => template('postfix/generic.erb'), }
  2. These templates are very simple. They started with the default "help text" version that comes with postfix. At the bottom, I simple set them up to append anything in hash form from the data variable. --> <% @generic_data.each do |line| -%> <%= line %> <% end -%>

--> <% @canonical_data.sort.each do |line| -%> <%= line %> <% end -%>

So as you can see, it should fall in line with what is already created. This just allows central configuration of the map data, as opposed to manually creating them on each server. In my environment this is required as none of my servers are routeable through to our corporate mail, and DNS is not resolvable. We use maps to mask our sender to a proper address before it hits a relay.

I hope this helps others out! Thank you for creating this.

sellerthorpe commented 8 years ago

I have recently updated the templates I started to properly hash these variables. I am still a bit new to this, so while my original templates work, they were not written as proper hashes.

In server.pp ... $canonical_data = {}, $generic_data = {}, ...

And in the templates, I replaced the 3 lines from before with this: --> <%- generic_data.keys.sort_by { |sk| (sk.to_s.upcase) }.each do |k| -%> <%- v = generic_data[k] -%> <%- if v != :undef and v != '' -%> <%= k %> <%= v %> <%- end -%> <%- end -%>

--> <%- canonical_data.keys.sort_by { |sk| (sk.to_s.upcase) }.each do |k| -%> <%- v = canonical_data[k] -%> <%- if v != :undef and v != '' -%> <%= k %> <%= v %> <%- end -%> <%- end -%>

Thank you again for this excellent module!