saltstack-formulas / postfix-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
25 stars 130 forks source link

Fix #89 by ignoring only keys which are actually used in Pillar 'postfix:mapping' #90

Closed alxwr closed 5 years ago

alxwr commented 5 years ago

With this change the following becomes feasible:

postfix:
  config:
    virtual_alias_maps: "$my_va_map"
    my_va_map: hash:{{ pillar['userland_etc'] }}/postfix/virtual_alias_maps
  mapping:
    # previously: 'virtual_alias_maps:'
    my_va_map:
      - '@example.test': catchall@example.test

resulting in

----------                                                                                                
          ID: /usr/local/etc/postfix/main.cf                                                              
    Function: file.managed                                                                                
      Result: True                                                                                        
     Comment: File /usr/local/etc/postfix/main.cf updated                                                 
     Started: 20:22:32.857905                                                                             
    Duration: 157.56 ms                                                                                   
     Changes:                                                                                             
              ----------                                                                                  
              diff:                                                                                       
                  ---                                                                                     
                  +++                                                                                     
                  @@ -70,7 +70,7 @@                                                                       

                  -virtual_alias_maps = hash:/usr/local/etc/postfix/virtual_alias_maps
                  +my_va_map = hash:/usr/local/etc/postfix/virtual_alias_maps

                   tls_high_cipherlist = EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+
CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH
                  @@ -89,6 +89,7 @@
                   smtpd_tls_protocols = !SSLv2, !SSLv3
                   smtpd_tls_session_cache_timeout = 3600s
                   strict_rfc821_envelopes = yes
                  +virtual_alias_maps = $my_va_map
                   virtual_mailbox_maps = 
                   virtual_transport = lmtp:unix:private/dovecot-lmtp
                   virtual_mailbox_domains = dmz.tty1.eu

This allows also for multiple maps within virtual_alias_maps as mentioned in #89 and https://github.com/saltstack-formulas/postfix-formula/issues/83#issuecomment-463342748 by @roskens.


I also fixed mapping.j2 along the way. It didn't work with Python 3.6.


Tested on FreeBSD 11.2.

alxwr commented 5 years ago

@vutny Thanks for making me re-think my code and learn new details. :-)