Skip to content

Commit

Permalink
Merge pull request #15 from n-rodriguez/wip/lists
Browse files Browse the repository at this point in the history
feat(pillar): some config values can be treated as lists
  • Loading branch information
n-rodriguez authored Oct 8, 2019
2 parents 827b8fb + 481966d commit 66150d4
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 23 deletions.
22 changes: 11 additions & 11 deletions exim/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions exim/files/default/update-exim4.conf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
12 changes: 12 additions & 0 deletions exim/macros.jinja
Original file line number Diff line number Diff line change
@@ -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 -%}
3 changes: 3 additions & 0 deletions test/integration/default/controls/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/integration/default/controls/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 6 additions & 1 deletion test/salt/pillar/exim.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]

0 comments on commit 66150d4

Please sign in to comment.