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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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