Skip to content

Commit 8f11260

Browse files
authored
Merge pull request #81 from bawuenet/services_yaml
Improve services definitions
2 parents f2a6454 + fb69881 commit 8f11260

File tree

7 files changed

+374
-364
lines changed

7 files changed

+374
-364
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.kitchen/
2+
Gemfile.lock

.kitchen.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ platforms:
2121
driver_config:
2222
provision_command:
2323
- yum install udev net-tools -y
24+
- name: fedora-latest
25+
driver_config:
26+
provision_command:
27+
- yum install udev net-tools -y
2428

2529
provisioner:
2630
name: salt_solo
@@ -38,7 +42,7 @@ provisioner:
3842
- postfix
3943
postfix.sls:
4044
postfix:
41-
manage_master_config: False
45+
manage_master_config: True
4246

4347
verifier:
4448
name: inspec

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
- INSTANCE: postfix-debian-9
1414
- INSTANCE: postfix-ubuntu-1804
1515
- INSTANCE: postfix-centos-7
16+
- INSTANCE: postfix-fedora-latest
1617

1718
script:
1819
- bundle exec kitchen verify ${INSTANCE}

README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Formulas to set up and configure the Postfix mail transfer agent.
88
See the full `Salt Formulas installation and usage instructions
99
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.
1010

11+
1112
Available states
1213
================
1314

@@ -50,3 +51,12 @@ Installs postfix pcre package ( Debian only)
5051
------------------
5152

5253
Installs postfix postsrsd package
54+
55+
56+
Integration testing
57+
===================
58+
59+
A rudimentary test-suite exists to verify basic functionality of the postfix-formula.
60+
Testing is done using the [Kitchen CI Framework](https://kitchen.ci/). Pull-Requests are verified using [Travis CI](https://travis-ci.org/).
61+
62+
A general getting started guide for kitchen-salt can be found at <https://github.com/saltstack/kitchen-salt/blob/master/docs/gettingstarted.md>.

postfix/files/master.cf

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{%- from "postfix/map.jinja" import postfix with context -%}
22
{%- set master_config = salt['pillar.get']('postfix:master_config', {}) -%}
3-
{%- from "postfix/services.jinja" import postfix_master_services_defaults,
4-
postfix_master_services_order -%}
3+
{% import_yaml "postfix/services.yaml" as postfix_master_services %}
54

65
{#-
76
# Handle the case that the pillar data does not provide any service
@@ -49,7 +48,7 @@
4948
{#- Fetch the value from the passed service dictionary or fall back to the
5049
# service defaults by chaining .get() commands. #}
5150
{%- set value = service.get(parameter_name,
52-
postfix_master_services_defaults[service_name].get(
51+
postfix_master_services.defaults[service_name].get(
5352
parameter_name, default)) -%}
5453
{%- if value is sameas false -%}
5554
n
@@ -76,15 +75,15 @@ y
7675
# service type private unpriv chroot wakeup maxproc command + args
7776
# (yes) (yes) (no) (never) (100)
7877
# ==========================================================================
79-
{%- for service_name in postfix_master_services_order %}
78+
{%- for service_name in postfix_master_services.order %}
8079
{#- Try to get the service configuration from the pillar if present.
8180
# Next try if the service has been dynamically configured and is present in
8281
# the additional_services dictionary.
8382
# If absent, fall back to the defaults provided in services.jinja -#}
8483
{%- set service = salt['pillar.get']('postfix:master_config:services:%s' % (
8584
service_name,),
8685
additional_services.get(service_name,
87-
postfix_master_services_defaults[service_name])) -%}
86+
postfix_master_services.defaults[service_name])) -%}
8887
{%- if service.get('enable', True) -%}
8988
{%- set comment = '' -%}
9089
{%- else -%}
@@ -100,7 +99,7 @@ y
10099
service_param(service, service_name, 'maxproc'),
101100
service_param(service, service_name, 'command', service_name)) -}}
102101
{%- if service.args is not none -%}
103-
{%- for option in service.get('args', postfix_master_services_defaults[
102+
{%- for option in service.get('args', postfix_master_services.defaults[
104103
service_name].get('args', [])) -%}
105104
{%- if option.startswith('#') %}
106105
{{ option }}
@@ -116,7 +115,7 @@ y
116115
{%- do handled_extra_services.append(service_name) -%}
117116
{%- set service = salt['pillar.get']('postfix:master_config:services:%s' % (
118117
service_name,),
119-
postfix_master_services_defaults[service_name]) -%}
118+
postfix_master_services.defaults[service_name]) -%}
120119
{%- if service.get('enable', True) -%}
121120
{%- set comment = '' -%}
122121
{%- else -%}
@@ -131,7 +130,7 @@ y
131130
service_param(service, service_name, 'wakeup'),
132131
service_param(service, service_name, 'maxproc'),
133132
service_param(service, service_name, 'command', service_name)) }}
134-
{%- if 'flags' in service or 'flags' in postfix_master_services_defaults[service_name] -%}
133+
{%- if 'flags' in service or 'flags' in postfix_master_services.defaults[service_name] -%}
135134
{%- set parameter_str = "%s flags=%s user=%s argv=%s %s" | format(comment,
136135
service_param(service, service_name, 'flags'),
137136
service_param(service, service_name, 'user'),
@@ -153,7 +152,7 @@ y
153152
{#- Handle legacy configuration of services for backwards compatibility
154153
by extending the services dictionary accordingly #}
155154
{%- if salt['pillar.get']('postfix:policyd-spf:enabled', False) %}
156-
{%- do postfix_master_services_defaults.update({'policy-spf': {
155+
{%- do postfix_master_services.defaults.update({'policy-spf': {
157156
'command': 'spawn',
158157
'chroot': False,
159158
'enable': True,
@@ -164,7 +163,7 @@ y
164163
{%- endif %}
165164
{%- if master_config.get('enable_dovecot', False) -%}
166165
{%- set dovecot = master_config.get('dovecot', {} )%}
167-
{%- do postfix_master_services_defaults.update({'dovecot': {
166+
{%- do postfix_master_services.defaults.update({'dovecot': {
168167
'command': 'pipe',
169168
'chroot': False,
170169
'enable': True,
@@ -234,11 +233,11 @@ y
234233
dictionary for all defined services that have not been otherwise be
235234
handled yet. -#}
236235
{%- for service in salt['pillar.get']('postfix:master_config:services', []) if not service in handled_extra_services -%}
237-
{%- do postfix_master_services_defaults.update({service: salt['pillar.get']('postfix:master_config:services:%s' % (service,))}) -%}
236+
{%- do postfix_master_services.defaults.update({service: salt['pillar.get']('postfix:master_config:services:%s' % (service,))}) -%}
238237
{%- endfor -%}
239-
{%- for service in postfix_master_services_defaults if not service in handled_extra_services and not service in postfix_master_services_order %}
238+
{%- for service in postfix_master_services.defaults if not service in handled_extra_services and not service in postfix_master_services.order %}
240239
#
241-
{%- if postfix_master_services_defaults[service].get('wrap', False) %}
240+
{%- if postfix_master_services.defaults[service].get('wrap', False) %}
242241
{{ extra_service(service, 78) }}
243242
{%- else %}
244243
{{ extra_service(service) }}

0 commit comments

Comments
 (0)