diff --git a/states/postfix/config.sls b/states/postfix/config.sls new file mode 100644 index 0000000..c3c921a --- /dev/null +++ b/states/postfix/config.sls @@ -0,0 +1,40 @@ +--- +{%- from "postfix/map.jinja" import postfix with context %} +postfix-pgsql-dir: + file.directory: + - name: {{ postfix.base_dir }}/pgsql + - user: root + - group: root + +postfix-main-cf: + file.managed: + - name: {{ postfix.base_dir }}/pgsql/main.cf + - source: salt://postfix/templates/main.cf.j2 + - user: root + - group: root + - mode: 644 + - template: jinja + - watch_in: + - service: postfix-service + +postfix-main-cf: + file.managed: + - name: {{ postfix.base_dir }}/main.cf + - source: salt://postfix/templates/main.cf.j2 + - user: root + - group: root + - mode: 644 + - template: jinja + - watch_in: + - service: postfix-service + +postfix-master-cf: + file.managed: + - name: {{ postfix.base_dir }}/master.cf + - source: salt://postfix/templates/master.cf.j2 + - user: root + - group: root + - mode: 644 + - template: jinja + - watch_in: + - service: postfix-service \ No newline at end of file diff --git a/states/postfix/defaults.yaml b/states/postfix/defaults.yaml index d7f8ea7..2277e02 100644 --- a/states/postfix/defaults.yaml +++ b/states/postfix/defaults.yaml @@ -2,6 +2,8 @@ postfix: enabled: true base_dir: '/etc/postfix' + pkgs: + - postfix config: main: alias_database: 'hash:/etc/aliases' diff --git a/states/postfix/init.sls b/states/postfix/init.sls index c0c4af4..ab823b4 100644 --- a/states/postfix/init.sls +++ b/states/postfix/init.sls @@ -1,73 +1,6 @@ --- -{%- from "postfix/map.jinja" import postfix with context %} -postfix-pkg: - pkg.latest: - - name: postfix - -postfix-pgsql-dir: - file.directory: - - name: {{ postfix.base_dir }}/pgsql - - user: root - - group: root - -postfix-main-cf: - file.managed: - - name: {{ postfix.base_dir }}/main.cf - - source: salt://postfix/main.cf.j2 - - user: root - - group: root - - mode: 644 - - template: jinja - - watch_in: - - service: postfix-service - -postfix-master-cf: - file.managed: - - name: {{ postfix.base_dir }}/master.cf - - source: salt://postfix/master.cf.j2 - - user: root - - group: root - - mode: 644 - - template: jinja - - watch_in: - - service: postfix-service - -postfix-transport-maps: - file.managed: - - name: {{ postfix.base_dir }}/transport - - source: salt://postfix/transport.j2 - - user: root - - group: root - - mode: 644 - - template: jinja - - watch_in: - - service: postfix-service - - cmd: postfix-transport - -postfix-sender-access-maps: - file.managed: - - name: {{ postfix.base_dir }}/sender_access - - source: salt://postfix/sender_access.j2 - - user: root - - group: root - - mode: 644 - - template: jinja - - watch_in: - - service: postfix-service - - cmd: postfix-sender-access - -postfix-transport: - cmd.run: - - name: postmap transport - - cwd: {{ postfix.base_dir }} - -postfix-sender-access: - cmd.run: - - name: postmap sender_access - - cwd: {{ postfix.base_dir }} - -postfix-service: - service.running: - - name: postfix - - enable: True - - reload: True \ No newline at end of file +include: + - .install + - .config + - .maps + - .service \ No newline at end of file diff --git a/states/postfix/install.sls b/states/postfix/install.sls new file mode 100644 index 0000000..86b3cba --- /dev/null +++ b/states/postfix/install.sls @@ -0,0 +1,5 @@ +--- +{%- from "postfix/map.jinja" import postfix with context %} +postfix-pkg: + pkg.latest: + - pkgs: {{ postfix.pkgs }} \ No newline at end of file diff --git a/states/postfix/maps.sls b/states/postfix/maps.sls new file mode 100644 index 0000000..943ded4 --- /dev/null +++ b/states/postfix/maps.sls @@ -0,0 +1,35 @@ +--- +{%- from "postfix/map.jinja" import postfix with context %} +postfix-transport-maps: + file.managed: + - name: {{ postfix.base_dir }}/transport + - source: salt://postfix/templates/transport.j2 + - user: root + - group: root + - mode: 644 + - template: jinja + - watch_in: + - service: postfix-service + - cmd: postfix-transport + +postfix-sender-access-maps: + file.managed: + - name: {{ postfix.base_dir }}/sender_access + - source: salt://postfix/templates/sender_access.j2 + - user: root + - group: root + - mode: 644 + - template: jinja + - watch_in: + - service: postfix-service + - cmd: postfix-sender-access + +postfix-transport: + cmd.run: + - name: postmap transport + - cwd: {{ postfix.base_dir }} + +postfix-sender-access: + cmd.run: + - name: postmap sender_access + - cwd: {{ postfix.base_dir }} \ No newline at end of file diff --git a/states/postfix/service.sls b/states/postfix/service.sls new file mode 100644 index 0000000..5a02a5b --- /dev/null +++ b/states/postfix/service.sls @@ -0,0 +1,7 @@ +--- +{%- from "postfix/map.jinja" import postfix with context %} +postfix-service: + service.running: + - name: postfix + - enable: True + - reload: True \ No newline at end of file diff --git a/states/postfix/main.cf.j2 b/states/postfix/templates/main.cf.j2 similarity index 100% rename from states/postfix/main.cf.j2 rename to states/postfix/templates/main.cf.j2 diff --git a/states/postfix/master.cf.j2 b/states/postfix/templates/master.cf.j2 similarity index 100% rename from states/postfix/master.cf.j2 rename to states/postfix/templates/master.cf.j2 diff --git a/states/postfix/sender_access.j2 b/states/postfix/templates/sender_access.j2 similarity index 100% rename from states/postfix/sender_access.j2 rename to states/postfix/templates/sender_access.j2 diff --git a/states/postfix/transport.j2 b/states/postfix/templates/transport.j2 similarity index 100% rename from states/postfix/transport.j2 rename to states/postfix/templates/transport.j2