Merge pull request #57 from M2Mobi/aliases
Use alias states for managing mail aliases.
This commit is contained in:
commit
7fc82e0bd2
@ -94,6 +94,21 @@ postfix:
|
||||
hosts: DB_HOST
|
||||
dbname: postfix_db
|
||||
|
||||
aliases:
|
||||
# manage single aliases
|
||||
# this uses the aliases file defined in the minion config, /etc/aliases by default
|
||||
use_file: false
|
||||
present:
|
||||
root: info@example.com
|
||||
absent:
|
||||
- root
|
||||
|
||||
# manage entire aliases file
|
||||
use_file: true
|
||||
content: |
|
||||
# Forward all local *nix users mail to our admins (via greedy regexp)
|
||||
/.+/ admins@example.com
|
||||
|
||||
certificates:
|
||||
server-cert:
|
||||
public_cert: |
|
||||
|
@ -1,3 +1,3 @@
|
||||
# Managed by config management
|
||||
# See man 5 aliases for format
|
||||
{{pillar['postfix']['aliases']}}
|
||||
{{pillar['postfix']['aliases']['content']}}
|
||||
|
@ -17,6 +17,7 @@ postfix:
|
||||
|
||||
# manage /etc/aliases if data found in pillar
|
||||
{% if 'aliases' in pillar.get('postfix', '') %}
|
||||
{% if salt['pillar.get']('postfix:aliases:use_file', true) == true %}
|
||||
{%- set need_newaliases = False %}
|
||||
{%- set file_path = postfix.aliases_file %}
|
||||
{%- if ':' in file_path %}
|
||||
@ -44,6 +45,19 @@ postfix_alias_database:
|
||||
- watch:
|
||||
- file: {{ file_path }}
|
||||
{%- endif %}
|
||||
{% else %}
|
||||
{%- for user, target in salt['pillar.get']('postfix:aliases:present', {}).items() %}
|
||||
postfix_alias_present_{{ user }}:
|
||||
alias.present:
|
||||
- name: {{ user }}
|
||||
- target: {{ target }}
|
||||
{%- endfor %}
|
||||
{%- for user in salt['pillar.get']('postfix:aliases:absent', {}) %}
|
||||
postfix_alias_absent_{{ user }}:
|
||||
alias.absent:
|
||||
- name: {{ user }}
|
||||
{%- endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
# manage various mappings
|
||||
|
Loading…
Reference in New Issue
Block a user