Skip to content

Commit a947ba9

Browse files
committed
refactor(states): split exim metastate in .package/.config/.service
1 parent 5b815e6 commit a947ba9

File tree

8 files changed

+109
-65
lines changed

8 files changed

+109
-65
lines changed

docs/README.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ exim-formula
1414
:scale: 100%
1515
:target: https://github.com/semantic-release/semantic-release
1616

17-
Formula to install and configure the exim mail server.
18-
17+
Formula to install and configure the exim mail server.
1918

2019
.. contents:: **Table of Contents**
2120

@@ -46,12 +45,22 @@ Available states
4645
.. contents::
4746
:local:
4847

49-
5048
``exim``
5149
^^^^^^^^
52-
5350
Install the ``exim`` package and enable the service.
5451

52+
``exim.package``
53+
^^^^^^^^^^^^^^^^
54+
Installs the exim package.
55+
56+
``exim.config``
57+
^^^^^^^^^^^^^^^
58+
This state manages the file ``update-exim4.conf.conf`` under ``/etc/exim4`` (template found in "exim/files"). The configuration is populated by values in "exim/map.jinja" based on the package's default values (and RedHat, Debian, Suse and Arch family distribution specific values), which can then be overridden by values of the same name in pillar.
59+
60+
``exim.service``
61+
^^^^^^^^^^^^^^^^
62+
Manages the startup and running state of the exim service.
63+
5564
Testing
5665
-------
5766

exim/config/file.sls

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
6+
{%- set sls_package_install = tplroot ~ '.package.install' %}
7+
{%- from tplroot ~ "/map.jinja" import map with context %}
8+
9+
{% set use_split_config = salt['pillar.get']('exim:config:use_split_config', 'true') %}
10+
{% set configtype = salt['pillar.get']('exim:config:configtype', 'satellite') %}
11+
{% set hide_mailname = salt['pillar.get']('exim:config:hide_mailname', 'true') %}
12+
{% set ue4c_keepcomments = salt['pillar.get']('exim:config:ue4c_keepcomments', 'true') %}
13+
{% set localdelivery = salt['pillar.get']('exim:config:localdelivery', 'mail_spool') %}
14+
{% set local_interfaces = salt['pillar.get']('exim:config:local_interfaces', '') %}
15+
{% set minimaldns = salt['pillar.get']('exim:config:minimaldns', 'false') %}
16+
{% set other_hostnames = salt['pillar.get']('exim:config:other_hostnames', '') %}
17+
{% set readhost = salt['pillar.get']('exim:config:readhost', '') %}
18+
{% set relay_domains = salt['pillar.get']('exim:config:relay_domains', '') %}
19+
{% set relay_nets = salt['pillar.get']('exim:config:relay_nets', '') %}
20+
{% set smarthost = salt['pillar.get']('exim:config:smarthost', '') %}
21+
{% set cfilemode = salt['pillar.get']('exim:config:cfilemode', '644') %}
22+
23+
{{ map.config_dir }}/{{ map.config_file }}:
24+
file.managed:
25+
- contents: |
26+
dc_eximconfig_configtype='{{ configtype }}'
27+
dc_other_hostnames='{{ other_hostnames }}'
28+
dc_local_interfaces='{{ local_interfaces }}'
29+
dc_relay_domains='{{ relay_domains }}'
30+
dc_relay_nets='{{ relay_nets }}'
31+
dc_use_split_config='{{ use_split_config }}'
32+
dc_hide_mailname='{{ hide_mailname }}'
33+
ue4c_keepcomments='{{ ue4c_keepcomments }}'
34+
dc_localdelivery='{{ localdelivery }}'
35+
dc_minimaldns='{{ minimaldns }}'
36+
dc_readhost='{{ readhost }}'
37+
dc_smarthost='{{ smarthost }}'
38+
CFILEMODE='{{ cfilemode }}'
39+
40+
{% if salt['pillar.get']('exim:files') %}
41+
{% for dir in map.sub_dirs %}
42+
{% for file in salt['pillar.get']('exim:files:' + dir, {}) %}
43+
{{ map.config_dir }}/conf.d/{{ dir }}/{{ file }}:
44+
file.managed:
45+
- contents_pillar: exim:files:{{ dir }}:{{ file }}
46+
{% endfor %}
47+
{% endfor %}
48+
{% endif %}

exim/config/init.sls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
include:
5+
- .file

exim/init.sls

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,7 @@
1-
# This is the main state file for configuring exim,
2-
3-
{% from "exim/map.jinja" import map with context %}
4-
5-
exim_install_packages:
6-
pkg.installed:
7-
- pkgs:
8-
{% for pkg in map.pkgs %}
9-
- {{ pkg }}
10-
{% endfor %}
11-
12-
{% set use_split_config = salt['pillar.get']('exim:config:use_split_config', 'true') %}
13-
{% set configtype = salt['pillar.get']('exim:config:configtype', 'satellite') %}
14-
{% set hide_mailname = salt['pillar.get']('exim:config:hide_mailname', 'true') %}
15-
{% set ue4c_keepcomments = salt['pillar.get']('exim:config:ue4c_keepcomments', 'true') %}
16-
{% set localdelivery = salt['pillar.get']('exim:config:localdelivery', 'mail_spool') %}
17-
{% set local_interfaces = salt['pillar.get']('exim:config:local_interfaces', '') %}
18-
{% set minimaldns = salt['pillar.get']('exim:config:minimaldns', 'false') %}
19-
{% set other_hostnames = salt['pillar.get']('exim:config:other_hostnames', '') %}
20-
{% set readhost = salt['pillar.get']('exim:config:readhost', '') %}
21-
{% set relay_domains = salt['pillar.get']('exim:config:relay_domains', '') %}
22-
{% set relay_nets = salt['pillar.get']('exim:config:relay_nets', '') %}
23-
{% set smarthost = salt['pillar.get']('exim:config:smarthost', '') %}
24-
{% set cfilemode = salt['pillar.get']('exim:config:cfilemode', '644') %}
25-
26-
{{ map.config_dir }}/{{ map.config_file }}:
27-
file.managed:
28-
- contents: |
29-
dc_eximconfig_configtype='{{ configtype }}'
30-
dc_other_hostnames='{{ other_hostnames }}'
31-
dc_local_interfaces='{{ local_interfaces }}'
32-
dc_relay_domains='{{ relay_domains }}'
33-
dc_relay_nets='{{ relay_nets }}'
34-
dc_use_split_config='{{ use_split_config }}'
35-
dc_hide_mailname='{{ hide_mailname }}'
36-
ue4c_keepcomments='{{ ue4c_keepcomments }}'
37-
dc_localdelivery='{{ localdelivery }}'
38-
dc_minimaldns='{{ minimaldns }}'
39-
dc_readhost='{{ readhost }}'
40-
dc_smarthost='{{ smarthost }}'
41-
CFILEMODE='{{ cfilemode }}'
42-
- watch_in:
43-
- service: {{ map.service }}
44-
45-
{% if salt['pillar.get']('exim:files') %}
46-
{% for dir in map.sub_dirs %}
47-
{% for file in salt['pillar.get']('exim:files:' + dir, {}) %}
48-
{{ map.config_dir }}/conf.d/{{ dir }}/{{ file }}:
49-
file.managed:
50-
- contents_pillar: exim:files:{{ dir }}:{{ file }}
51-
- watch_in:
52-
- service: {{ map.service }}
53-
{% endfor %}
54-
{% endfor %}
55-
{% endif %}
56-
57-
58-
exim_service:
59-
service.running:
60-
- name: {{ map.service }}
61-
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
623

4+
include:
5+
- .package
6+
- .config
7+
- .service

exim/package/init.sls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
include:
5+
- .install

exim/package/install.sls

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
6+
{%- from tplroot ~ "/map.jinja" import map with context %}
7+
8+
exim/package/install:
9+
pkg.installed:
10+
- pkgs: {{ map.pkgs | json }}

exim/service/init.sls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
include:
5+
- .running

exim/service/running.sls

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=sls
3+
4+
{#- Get the `tplroot` from `tpldir` #}
5+
{%- set tplroot = tpldir.split('/')[0] %}
6+
{%- set sls_config_file = tplroot ~ '.config.file' %}
7+
{%- from tplroot ~ "/map.jinja" import map with context %}
8+
9+
include:
10+
- {{ sls_config_file }}
11+
12+
exim/service/running:
13+
service.running:
14+
- name: {{ map.service }}
15+
- enable: true
16+
- require:
17+
- sls: {{ sls_config_file }}

0 commit comments

Comments
 (0)