Skip to content

Commit

Permalink
feat(config): allow to manage config files under CONFDIR
Browse files Browse the repository at this point in the history
* should fix #17
* restart exim service on config change

Also:

* feat(service): reload service instead of restarting it
* fix(service): reorder watchers to match org defaults
  • Loading branch information
javierbertoli authored May 8, 2020
1 parent cde9512 commit fd6debd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion exim/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ exim/config/install:
{%- if salt['pillar.get']('exim:files') %}
{%- for dir in exim.sub_dirs %}
{%- for file in salt['pillar.get']('exim:files:' + dir, {}) %}
{{ exim.config_dir }}/conf.d/{{ dir }}/{{ file }}:
{% set config_subdir_path = '/conf.d/' ~ dir ~ '/' if dir != 'base' else '/' %}
{{ exim.config_dir }}{{ config_subdir_path }}/{{ file }}:
file.managed:
- contents_pillar: exim:files:{{ dir }}:{{ file }}
- require:
Expand Down
1 change: 1 addition & 0 deletions exim/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ exim:
smarthost: []
cfilemode: '644'
sub_dirs:
- base
- main
- acl
- router
Expand Down
3 changes: 2 additions & 1 deletion exim/service/running.sls
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ exim/service/running:
service.running:
- name: {{ exim.service }}
- enable: true
- require:
- reload: true
- watch:
- sls: {{ sls_config_file }}
7 changes: 7 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ exim:
aliases:
root: [email protected]
files:
# 'base' dir files will be located under the main CONFDIR (/etc/exim4)
# this allows you to write files like `/etc/exim4/exim4.conf.localmacros`
# or `/etc/exim4/passwd.client`
base:
'passwd.client': |
# <server>:<username>:<user password>
*:[email protected]:abdc1243
main:
'01_exim4-config_listmacrosdefs': |
exim_path = /usr/sbin/exim4
Expand Down
5 changes: 5 additions & 0 deletions test/integration/default/controls/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
its('content') { should include 'foo.bar.baz' }
end

describe file('/etc/exim4/passwd.client') do
# Custom config
its('content') { should include '*:[email protected]:abdc1243' }
end

describe file('/etc/aliases') do
# Custom config
its('content') { should include 'root: [email protected]' }
Expand Down
5 changes: 5 additions & 0 deletions test/salt/pillar/exim.sls
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ exim:
mailname: foo.bar.baz
aliases:
root: [email protected]
files:
base:
'passwd.client': |
# <server>:<username>:<user password>
*:[email protected]:abdc1243

0 comments on commit fd6debd

Please sign in to comment.