diff --git a/.kitchen.yml b/.kitchen.yml index 8518d18..54b0a11 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -78,6 +78,7 @@ suites: - minion_handler - minion_local_pillar - minion_local_reclass + - minion_config pillars-from-files: minion_pki.sls: tests/pillar/minion_pki_ca.sls minion_mine.sls: tests/pillar/minion_mine.sls @@ -86,6 +87,7 @@ suites: minion_local_pillar.sls: tests/pillar/minion_local_pillar.sls minion_local_reclass.sls: tests/pillar/minion_local_reclass.sls minion_backend_urllib.sls: tests/pillar/minion_backend_urllib.sls + minion_config.sls: tests/pillar/minion_config.sls - name: master-default provisioner: diff --git a/salt/minion/service.sls b/salt/minion/service.sls index 36d8aff..1009e24 100644 --- a/salt/minion/service.sls +++ b/salt/minion/service.sls @@ -35,6 +35,37 @@ salt_minion_dependency_packages: - require: - {{ minion.install_state }} +{#- Salt minion module additional configuration. Salt supports hundreds of modules, this formula pillar systematically structured #} +{#- provides support for most frequently used modules. In order to provide additional support to configure whatever configuration #} +{#- in ``minion.conf`` for any module without a need of dedicated formula dependency specify `salt:minion:config` pillar. #} + +{#- If you intend add minion configuration for any existing salt-formula please use //meta/salt.yml #} + +{#- This pillar is expected be used while ``masterless``, ``salt --local``, to configure modules without support in salt-formula. #} +{#- in salt state calls. It's not documented in README.rst as we recognize it a bad pattern for salt-formulas ecosystem. Example: #} +{#- salt: #} +{#- minion: #} +{#- config: #} +{#- influxdb: #} +{#- host: localhost #} +{#- port: 8086 #} +{#- mysqlite: #} +{#- driver: sqlite3 #} +{%- if minion.config is mapping %} +salt_minion_config_present: + file.serialize: + - name: /etc/salt/minion.d/minion.conf + - dataset_pillar: salt:minion:config + - formatter: yaml + - merge_if_exists: True + - makedirs: True + - require: + - {{ minion.install_state }} + - require_in: + - service: {{ minion.service }} +{%- endif %} + + {%- for service_name, service in pillar.items() %} {%- set support_fragment_file = service_name+'/meta/salt.yml' %} {%- macro load_support_file() %}{% include support_fragment_file ignore missing %}{% endmacro %} diff --git a/tests/integration/minion-default/minion_config_spec.rb b/tests/integration/minion-default/minion_config_spec.rb new file mode 100644 index 0000000..8dd19af --- /dev/null +++ b/tests/integration/minion-default/minion_config_spec.rb @@ -0,0 +1,9 @@ + + +describe file('/etc/salt/minion.d/minion.conf') do + it('should exist') + its('content') { should match /influxdb:/ } + its('content') { should match /^ port: 8086/ } + its('content') { should match /mysqlite:/ } +end + diff --git a/tests/pillar/minion_config.sls b/tests/pillar/minion_config.sls new file mode 100644 index 0000000..33cd350 --- /dev/null +++ b/tests/pillar/minion_config.sls @@ -0,0 +1,11 @@ +salt: + minion: + enabled: true + master: + host: config01.dc01.domain.com + config: + influxdb: + host: localhost + port: 8086 + mysqlite: + driver: sqlite3