Merge pull request #120 from netmanagers/master

fix(resources): modify names to match template-formula's
This commit is contained in:
Imran Iqbal 2021-03-15 19:38:20 +00:00 committed by GitHub
commit dc986f084e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 54 deletions

View File

@ -2,78 +2,84 @@
include:
- postfix
{{ postfix.config_path }}:
postfix-config-file-directory-config-path:
file.directory:
- name: {{ postfix.config_path }}
- user: root
- group: {{ postfix.root_grp }}
- dir_mode: '0755'
- file_mode: '0644'
- makedirs: True
{{ postfix.config_path }}/main.cf:
postfix-config-file-managed-main.cf:
file.managed:
- name: {{ postfix.config_path }}/main.cf
- source: salt://postfix/files/main.cf
- user: root
- group: {{ postfix.root_grp }}
- mode: '0644'
- require:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
- template: jinja
- context:
postfix: {{ postfix|tojson }}
{% if 'vmail' in pillar.get('postfix', '') %}
{{ postfix.config_path }}/virtual_alias_maps.cf:
postfix-config-file-managed-virtual-alias-maps.cf:
file.managed:
- name: {{ postfix.config_path }}/virtual_alias_maps.cf
- source: salt://postfix/files/virtual_alias_maps.cf
- user: root
- group: postfix
- mode: '0640'
- require:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
- template: jinja
{{ postfix.config_path }}/virtual_mailbox_domains.cf:
postfix-config-file-managed-virtual-mailbox-domains.cf:
file.managed:
- name: {{ postfix.config_path }}/virtual_mailbox_domains.cf
- source: salt://postfix/files/virtual_mailbox_domains.cf
- user: root
- group: postfix
- mode: '0640'
- require:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
- template: jinja
{{ postfix.config_path }}/virtual_mailbox_maps.cf:
postfix-config-file-managed-virtual-mailbox-maps.cf:
file.managed:
- name: {{ postfix.config_path }}/virtual_mailbox_maps.cf
- source: salt://postfix/files/virtual_mailbox_maps.cf
- user: root
- group: postfix
- mode: '0640'
- require:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
- template: jinja
{% endif %}
{% if salt['pillar.get']('postfix:manage_master_config', True) %}
{% import_yaml "postfix/services.yaml" as postfix_master_services %}
{{ postfix.config_path }}/master.cf:
postfix-config-file-managed-master.cf:
file.managed:
- name: {{ postfix.config_path }}/master.cf
- source: salt://postfix/files/master.cf
- user: root
- group: {{ postfix.root_grp }}
- mode: '0644'
- require:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
- template: jinja
- context:
postfix: {{ postfix|tojson }}
@ -82,23 +88,22 @@ include:
{%- for domain in salt['pillar.get']('postfix:certificates', {}).keys() %}
postfix_{{ domain }}_ssl_certificate:
postfix-config-file-managed-{{ domain }}-ssl-certificate:
file.managed:
- name: {{ postfix.config_path }}/ssl/{{ domain }}.crt
- makedirs: True
- contents_pillar: postfix:certificates:{{ domain }}:public_cert
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
postfix_{{ domain }}_ssl_key:
postfix-config-file-managed-{{ domain }}-ssl-key:
file.managed:
- name: {{ postfix.config_path }}/ssl/{{ domain }}.key
- mode: '0600'
- makedirs: True
- contents_pillar: postfix:certificates:{{ domain }}:private_key
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
{% endfor %}
@ -120,7 +125,7 @@ postfix_{{ domain }}_ssl_key:
{%- if file_type in ("btree", "cdb", "cidr", "dbm", "hash", "pcre", "regexp", "sdbm") %}
{%- set need_postmap = True %}
{%- endif %}
postfix_{{ mapping }}:
postfix-config-file-managed-{{ mapping }}:
file.managed:
- name: {{ file_path }}
- source: salt://postfix/files/mapping.j2
@ -135,15 +140,16 @@ postfix_{{ mapping }}:
- context:
data: {{ data|json() }}
- require:
- pkg: postfix
- file: {{ postfix.config_path }}/main.cf
- pkg: postfix-init-pkg-installed-postfix
- file: postfix-config-file-managed-main.cf
{%- if need_postmap %}
postfix-config-cmd-wait-{{ mapping }}:
cmd.wait:
- name: {{ postfix.xbin_prefix }}/sbin/postmap {{ file_path }}
- cwd: /
- watch:
- file: {{ file_path }}
- file: postfix-config-file-managed-{{ mapping }}
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
{%- endif %}
{% endfor %}

View File

@ -3,17 +3,18 @@
{%- if grains.os_family == "Suse" %}
# The existence of this file prevents the system to
# overwrite files from salt when installing.
/var/adm/postfix.configured:
postfix-init-file-managed-postfix.configured:
file.managed:
- name: /var/adm/postfix.configured
- contents: ''
- mode: '0644'
- user: 'root'
- group: 'root'
- require_in:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
{%- endif %}
postfix:
postfix-init-pkg-installed-postfix:
pkg.installed:
- name: {{ postfix.package }}
{%- if grains.os_family == "FreeBSD" %}
@ -21,23 +22,26 @@ postfix:
- batch: True
{%- endif %}
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix
postfix-init-service-running-postfix:
service.running:
- name: postfix
- enable: {{ salt['pillar.get']('postfix:enable_service', True) }}
- reload: {{ salt['pillar.get']('postfix:reload_service', True) }}
- require:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
- watch:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
{%- if salt['pillar.get']('postfix:reload_service', True) %}
# Restart postfix if the package was changed.
# This also provides an ID to be used in a watch_in statement.
postfix_service_restart:
postfix-init-service-running-postfix-restart:
service.running:
- name: postfix
- watch:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
{%- endif %}
{# Used for newaliases, postalias and postconf #}
@ -56,7 +60,7 @@ postfix_service_restart:
{%- if file_type in ("btree", "cdb", "dbm", "hash", "sdbm") %}
{%- set need_newaliases = True %}
{%- endif %}
postfix_alias_database:
postfix-init-file-managed-alias-database:
file.managed:
- name: {{ file_path }}
{% if salt['pillar.get']('postfix:aliases:content', None) is string %}
@ -72,8 +76,10 @@ postfix_alias_database:
data: {{ salt['pillar.get']('postfix:aliases:present') }}
colon: True
- require:
- pkg: postfix
- pkg: postfix-init-pkg-installed-postfix
{%- if need_newaliases %}
postfix-init-cmd-wait-new-aliases:
cmd.wait:
- name: newaliases
- cwd: /
@ -82,13 +88,13 @@ postfix_alias_database:
{%- endif %}
{% else %}
{%- for user, target in salt['pillar.get']('postfix:aliases:present', {}).items() %}
postfix_alias_present_{{ user }}:
postfix-init-alias-present-{{ user }}:
alias.present:
- name: {{ user }}
- target: {{ target }}
{%- endfor %}
{%- for user in salt['pillar.get']('postfix:aliases:absent', {}) %}
postfix_alias_absent_{{ user }}:
postfix-init-alias-absent-{{ user }}:
alias.absent:
- name: {{ user }}
{%- endfor %}

View File

@ -1,9 +1,10 @@
smtp.input:
postfix-iptables-iptables-chain-present-smtp-input:
iptables.chain_present:
-
- name: smtp.input
smtp.iptables.tcp:
postfix-iptables-iptables-insert-smtp-iptables-tcp:
iptables.insert:
- name: smtp.iptables.tcp
- table: filter
- position: 1
- chain: smtp.input
@ -14,11 +15,11 @@ smtp.iptables.tcp:
- proto: tcp
- save: True
smtp.iptables.filter:
postfix-iptables-iptables-insert-smtp-iptables-filter:
iptables.insert:
- name: smtp.iptables.filter
- table: filter
- position: 1
- chain: INPUT
- jump: smtp.input
- save: True

View File

@ -1,7 +1,7 @@
{% from "postfix/map.jinja" import postfix with context %}
mysql:
postfix-mysql-pkg-installed-mysql:
pkg.installed:
- name: {{ postfix.mysql_pkg }}
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix

View File

@ -1,7 +1,7 @@
{% from "postfix/map.jinja" import postfix with context %}
pcre:
postfix-pcre-pkg-installed-pcre:
pkg.installed:
- name: {{ postfix.pcre_pkg }}
- watch_in:
- service: postfix
- service: postfix-init-service-running-postfix

View File

@ -1,5 +1,5 @@
{% from "postfix/map.jinja" import postfix with context %}
policyd_spf:
postfix-policyd-spf-pkg-installed-policyd_spf:
pkg.installed:
- name: {{ postfix.policyd_spf_pkg }}

View File

@ -1,15 +1,15 @@
{% from "postfix/map.jinja" import postfix with context %}
postgrey:
postfix-postgrey-pkg-installed-postgrey:
pkg.installed:
- name: {{ postfix.postgrey_pkg }}
- watch_in:
- service: postgrey
postfix-postgrey-service-running-postgrey:
service.running:
- name: postgrey
- enable: {{ salt['pillar.get']('postfix:postgrey:enable_service', True) }}
- require:
- pkg: postgrey
- pkg: postfix-postgrey-pkg-installed-postgrey
- watch:
- pkg: postgrey
- pkg: postfix-postgrey-pkg-installed-postgrey

View File

@ -1,6 +1,6 @@
{% from "postfix/map.jinja" import postfix with context %}
postsrsd:
postfix-postsrsd-pkg-latest-postsrsd:
pkg.latest:
- name: {{ postfix.postsrsd_pkg }}