Преглед изворни кода

Merge pull request #34 from tcpcloud/config

Add support for external config generation
tags/2016.12
Aleš Komárek пре 8 година
родитељ
комит
98b3b5aae7
3 измењених фајлова са 62 додато и 0 уклоњено
  1. +26
    -0
      README.rst
  2. +33
    -0
      linux/system/config.sls
  3. +3
    -0
      linux/system/init.sls

+ 26
- 0
README.rst Прегледај датотеку

@@ -687,6 +687,32 @@ Disabled multipath (the default setup)
multipath:
enabled: false

External config generation
--------------------------

You are able to use config support metadata between formulas and only generate
config files for external use, eg. docker, etc.

.. code-block:: yaml

parameters:
linux:
system:
config:
pillar:
jenkins:
master:
home: /srv/volumes/jenkins
approved_scripts:
- method java.net.URL openConnection
credentials:
- type: username_password
scope: global
id: test
desc: Testing credentials
username: test
password: test


Usage
=====

+ 33
- 0
linux/system/config.sls Прегледај датотеку

@@ -0,0 +1,33 @@
{%- from "linux/map.jinja" import system with context %}
{%- macro load_support_file(file, pillar, grains) %}{% include file %}{% endmacro %}

{%- if system.enabled %}

{%- for config_name, config in system.get('config', {}).iteritems() %}
{%- if config.enabled|default(True) %}
{%- for service_name in config.pillar.keys() %}
{%- if pillar.get(service_name, {}).get('_support', {}).get('config', {}).get('enabled', False) %}
{%- set support_fragment_file = service_name+'/meta/config.yml' %}
{%- set service_config_files = load_support_file(support_fragment_file, config.pillar, config.get('grains', {}))|load_yaml %}
{%- for service_config_name, service_config in service_config_files.config.iteritems() %}

{{ service_config.path }}:
file.managed:
- source: {{ service.config.source }}
{%- if service.config.template is defined %}
- template: {{ service.config.template }}
{%- endif %}
- makedirs: true
- defaults:
pillar: {{ config.pillar|yaml }}
grains: {{ config.get('grains', {}) }}

{%- endfor %}
{%- endif %}
{%- endfor %}
{%- else %}
{# TODO: configmap not using support between formulas #}
{%- endif %}
{%- endfor %}

{%- endif %}

+ 3
- 0
linux/system/init.sls Прегледај датотеку

@@ -60,3 +60,6 @@ include:
{%- if system.haveged is defined %}
- linux.system.haveged
{%- endif %}
{%- if system.config is defined %}
- linux.system.config
{%- endif %}

Loading…
Откажи
Сачувај