- Fix virtual handling - can't just dump json to virtual
- Add in handling for sender_canonical - Add examples to pillar
This commit is contained in:
parent
af33209442
commit
83c0a448fe
@ -3,6 +3,16 @@ postfix:
|
|||||||
master_config:
|
master_config:
|
||||||
enable_submission: False
|
enable_submission: False
|
||||||
|
|
||||||
|
virtual:
|
||||||
|
groupaliasexample:
|
||||||
|
- someuser_1@example.com
|
||||||
|
- someuser_2@example.com
|
||||||
|
singlealiasexample: 'someuser_3@example.com'
|
||||||
|
|
||||||
|
sender_canonical:
|
||||||
|
root: 'servers@example.com'
|
||||||
|
nagios: 'alerts@example.com'
|
||||||
|
|
||||||
postgrey:
|
postgrey:
|
||||||
enabled: True
|
enabled: True
|
||||||
location: inet:172.16.0.5:6379
|
location: inet:172.16.0.5:6379
|
||||||
@ -34,3 +44,4 @@ postfix:
|
|||||||
mailbox_size_limit: 0
|
mailbox_size_limit: 0
|
||||||
recipient_delimiter: +
|
recipient_delimiter: +
|
||||||
inet_interfaces: all
|
inet_interfaces: all
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{%- from "postfix/map.jinja" import postfix with context -%}
|
{%- from "postfix/map.jinja" import postfix with context -%}
|
||||||
{%- set config = salt['pillar.get']('postfix:config', {}) -%}
|
{%- set config = salt['pillar.get']('postfix:config', {}) -%}
|
||||||
{% set processed_parameters = ['aliases_file', 'virtual'] %}
|
{% set processed_parameters = ['aliases_file', 'virtual', 'sender_canonical'] %}
|
||||||
{%- macro set_parameter(parameter, default=None) -%}
|
{%- macro set_parameter(parameter, default=None) -%}
|
||||||
{% set value = config.get(parameter, default) %}
|
{% set value = config.get(parameter, default) %}
|
||||||
{%- if value is not none %}
|
{%- if value is not none %}
|
||||||
@ -103,6 +103,10 @@ policy-spf_time_limit = {{ policyd_spf.get('time_limit', '3600s') }}
|
|||||||
virtual_alias_maps = hash:/etc/postfix/virtual
|
virtual_alias_maps = hash:/etc/postfix/virtual
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if 'sender_canonical' in pillar.get('postfix','') %}
|
||||||
|
sender_canonical_maps = hash:/etc/postfix/sender_canonical
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{# Accept arbitrary parameters -#}
|
{# Accept arbitrary parameters -#}
|
||||||
{% for parameter in config -%}
|
{% for parameter in config -%}
|
||||||
{% if parameter not in processed_parameters -%}
|
{% if parameter not in processed_parameters -%}
|
||||||
|
@ -51,3 +51,22 @@ run-postmap:
|
|||||||
- watch:
|
- watch:
|
||||||
- file: /etc/postfix/virtual
|
- file: /etc/postfix/virtual
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
# manage /etc/postfix/sender_canonical if data found in pillar
|
||||||
|
{% if 'sender_canonical' in pillar.get('postfix', '') %}
|
||||||
|
/etc/postfix/sender_canonical:
|
||||||
|
file.managed:
|
||||||
|
- source: salt://postfix/sender_canonical
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 644
|
||||||
|
- template: jinja
|
||||||
|
- require:
|
||||||
|
- pkg: postfix
|
||||||
|
|
||||||
|
cmd.wait:
|
||||||
|
- name: /usr/sbin/postmap /etc/postfix/sender_canonical
|
||||||
|
- cwd: /
|
||||||
|
- watch:
|
||||||
|
- file: /etc/postfix/sender_canonical
|
||||||
|
{% endif %}
|
||||||
|
7
postfix/sender_canonical
Normal file
7
postfix/sender_canonical
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Managed by config management
|
||||||
|
{% set canonical = salt['pillar.get']('postfix:sender_canonical',{}) -%}
|
||||||
|
{% if canonical is iterable -%}
|
||||||
|
{% for key,value in salt['pillar.get']('postfix:sender_canonical',{}).iteritems() -%}
|
||||||
|
{{ key }} {{ value }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
@ -1,2 +1,17 @@
|
|||||||
# Managed by config management
|
# Managed by config management
|
||||||
{{pillar['postfix']['virtual']}}
|
{% set virtual = salt['pillar.get']('postfix:virtual',{}) -%}
|
||||||
|
{# to have virtual file emptied, just set an empty key 'virtual' -#}
|
||||||
|
{% if virtual is iterable -%}
|
||||||
|
{% for key, value in virtual.iteritems() -%}
|
||||||
|
{# Mutiple values available for single key in virtual alias maps - ie for dist groups -#}
|
||||||
|
{# We test if list was provided as value, and iterate if so -#}
|
||||||
|
{% if value is iterable and value is not string -%}
|
||||||
|
{% for item in value -%}
|
||||||
|
{{key }} {{ item }}
|
||||||
|
{% endfor -%}
|
||||||
|
{% else -%}
|
||||||
|
{# ..otherwise expect it to be just a string for the value -#}
|
||||||
|
{{ key }} {{ value }}
|
||||||
|
{% endif -%}
|
||||||
|
{% endfor -%}
|
||||||
|
{% endif -%}
|
||||||
|
Loading…
Reference in New Issue
Block a user