Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(resources): modify names to match template-formula's #120

Merged
merged 1 commit into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 32 additions & 26 deletions postfix/config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 %}

Expand All @@ -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
Expand All @@ -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 %}
30 changes: 18 additions & 12 deletions postfix/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,45 @@
{%- 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" %}
- force: True
- 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 #}
Expand All @@ -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 %}
Expand All @@ -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: /
Expand All @@ -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 %}
Expand Down
11 changes: 6 additions & 5 deletions postfix/iptables-input.sls
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

4 changes: 2 additions & 2 deletions postfix/mysql.sls
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions postfix/pcre.sls
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion postfix/policyd-spf.sls
Original file line number Diff line number Diff line change
@@ -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 }}
10 changes: 5 additions & 5 deletions postfix/postgrey.sls
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion postfix/postsrsd.sls
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% from "postfix/map.jinja" import postfix with context %}

postsrsd:
postfix-postsrsd-pkg-latest-postsrsd:
pkg.latest:
- name: {{ postfix.postsrsd_pkg }}