diff --git a/exim/defaults.yaml b/exim/defaults.yaml index f823839..4d20b9d 100644 --- a/exim/defaults.yaml +++ b/exim/defaults.yaml @@ -7,18 +7,18 @@ exim: virtual_aliases: {} files: {} config: - configtype: 'satellite' - other_hostnames: '' - local_interfaces: '' - relay_domains: '' - relay_nets: '' - use_split_config: 'true' - hide_mailname: 'true' - ue4c_keepcomments: 'true' - localdelivery: 'mail_spool' - minimaldns: 'false' + configtype: satellite + other_hostnames: [] + local_interfaces: [] + relay_domains: [] + relay_nets: [] + use_split_config: true + hide_mailname: true + ue4c_keepcomments: true + localdelivery: mail_spool + minimaldns: false readhost: '' - smarthost: '' + smarthost: [] cfilemode: '644' sub_dirs: - main diff --git a/exim/files/default/update-exim4.conf.conf b/exim/files/default/update-exim4.conf.conf index 9cdb517..cdabadd 100644 --- a/exim/files/default/update-exim4.conf.conf +++ b/exim/files/default/update-exim4.conf.conf @@ -3,16 +3,18 @@ # Your changes will be overwritten. ######################################################################## +{%- from "exim/macros.jinja" import join_if_list %} + dc_eximconfig_configtype='{{ exim.configtype }}' -dc_other_hostnames='{{ exim.other_hostnames }}' -dc_local_interfaces='{{ exim.local_interfaces }}' -dc_relay_domains='{{ exim.relay_domains }}' -dc_relay_nets='{{ exim.relay_nets }}' -dc_use_split_config='{{ exim.use_split_config }}' -dc_hide_mailname='{{ exim.hide_mailname }}' -ue4c_keepcomments='{{ exim.ue4c_keepcomments }}' +dc_other_hostnames='{{ join_if_list(exim.other_hostnames) }}' +dc_local_interfaces='{{ join_if_list(exim.local_interfaces) }}' +dc_relay_domains='{{ join_if_list(exim.relay_domains) }}' +dc_relay_nets='{{ join_if_list(exim.relay_nets) }}' +dc_use_split_config='{{ exim.use_split_config | lower }}' +dc_hide_mailname='{{ exim.hide_mailname | lower }}' +ue4c_keepcomments='{{ exim.ue4c_keepcomments | lower }}' dc_localdelivery='{{ exim.localdelivery }}' -dc_minimaldns='{{ exim.minimaldns }}' +dc_minimaldns='{{ exim.minimaldns | lower }}' dc_readhost='{{ exim.readhost }}' -dc_smarthost='{{ exim.smarthost }}' +dc_smarthost='{{ join_if_list(exim.smarthost) }}' CFILEMODE='{{ exim.cfilemode }}' diff --git a/exim/macros.jinja b/exim/macros.jinja new file mode 100644 index 0000000..a7459da --- /dev/null +++ b/exim/macros.jinja @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# vim: ft=jinja +# +# Collection of common macros + +{%- macro join_if_list(value, delimiter=' ; ') -%} + {%- if value is list -%} + {{ value | join(delimiter) }} + {%- else -%} + {{ value }} + {%- endif -%} +{%- endmacro -%} diff --git a/test/integration/default/controls/config_spec.rb b/test/integration/default/controls/config_spec.rb index 84fa60c..e43df3e 100644 --- a/test/integration/default/controls/config_spec.rb +++ b/test/integration/default/controls/config_spec.rb @@ -6,7 +6,10 @@ its('content') { should include "dc_eximconfig_configtype='satellite'" } # Custom config + its('content') { should include "dc_other_hostnames='foo.bar.baz ; bar.baz.foo'" } + its('content') { should include "dc_local_interfaces='127.0.0.1'" } its('content') { should include "dc_hide_mailname='false'" } + its('content') { should include "dc_use_split_config='false'" } end describe file('/etc/mailname') do diff --git a/test/integration/default/controls/service_spec.rb b/test/integration/default/controls/service_spec.rb index 0b327e9..a92bfdc 100644 --- a/test/integration/default/controls/service_spec.rb +++ b/test/integration/default/controls/service_spec.rb @@ -10,7 +10,6 @@ it { should be_listening } its('processes') { should include 'exim4' } its('protocols') { should include 'tcp' } - its('addresses') { should include '0.0.0.0' } - its('addresses') { should include '::' } + its('addresses') { should include '127.0.0.1' } end end diff --git a/test/salt/pillar/exim.sls b/test/salt/pillar/exim.sls index d8af6b3..c42ebb3 100644 --- a/test/salt/pillar/exim.sls +++ b/test/salt/pillar/exim.sls @@ -3,8 +3,13 @@ --- exim: config: - configtype: 'satellite' + configtype: satellite hide_mailname: 'false' + use_split_config: false + other_hostnames: + - foo.bar.baz + - bar.baz.foo + local_interfaces: 127.0.0.1 mailname: foo.bar.baz aliases: root: root@bar.baz