From af7f9d722a9908801132908ec36acd376d8fc194 Mon Sep 17 00:00:00 2001 From: Niels Abspoel Date: Sun, 14 Dec 2014 20:38:47 +0100 Subject: [PATCH] more improvements in _defaults.conf better newlines with iterations. --- salt/files/master.d/_defaults.conf | 77 +++++++++++++++--------------- salt/files/minion.d/_defaults.conf | 2 +- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/salt/files/master.d/_defaults.conf b/salt/files/master.d/_defaults.conf index f0bbcb3..c3e00a6 100644 --- a/salt/files/master.d/_defaults.conf +++ b/salt/files/master.d/_defaults.conf @@ -1,17 +1,17 @@ # This file managed by Salt, do not edit by hand!! # Based on salt version 0.17.4 default config -{% set reserved_keys = ['master', 'minion', 'cloud', 'salt_cloud_certs'] %} -{% set salt = pillar.get('salt', {}) %} -{% set master = salt.get('master', {}) %} -{% macro get_config(configname, default_value) %} -{% if configname in master %} +{% set reserved_keys = ['master', 'minion', 'cloud', 'salt_cloud_certs'] -%} +{% set salt = pillar.get('salt', {}) -%} +{% set master = salt.get('master', {}) -%} +{%- macro get_config(configname, default_value) -%} +{%- if configname in master -%} {{ configname }}: {{ master[configname] }} -{% elif configname in salt and configname not in reserved_keys %} +{%- elif configname in salt and configname not in reserved_keys -%} {{ configname }}: {{ salt[configname] }} -{% else %} +{%- else -%} #{{ configname }}: {{ default_value }} -{% endif %} -{% endmacro %} +{%- endif -%} +{%- endmacro -%} ##### Primary configuration settings ##### ########################################## # This configuration file is used to manage the behavior of the Salt Master @@ -344,27 +344,28 @@ client_acl_blacklist: # prod: # - /srv/salt/prod/services # - /srv/salt/prod/states -{% if 'file_roots' in master %} +{% if 'file_roots' in master -%} file_roots: -{% for name, roots in master['file_roots']|dictsort %} +{%- for name, roots in master['file_roots']|dictsort %} {{ name }}: -{% for dir in roots %} +{%- for dir in roots %} - {{ dir }} -{% endfor %} -{% endfor %} -{% elif 'file_roots' in salt %} +{%- endfor -%} +{%- endfor -%} +{% elif 'file_roots' in salt -%} file_roots: -{% for name, roots in salt['file_roots']|dictsort %} +{%- for name, roots in salt['file_roots']|dictsort %} {{ name }}: -{% for dir in roots %} +{%- for dir in roots %} - {{ dir }} -{% endfor %} -{% endfor %} -{% else %} +{%- endfor -%} +{%- endfor -%} +{% else -%} #file_roots: # base: # - /srv/salt -{% endif %} +{%- endif %} + # The hash_type is the hash to use when discovering the hash of a file on # the master server. The default is md5, but sha1, sha224, sha256, sha384 @@ -433,12 +434,12 @@ file_ignore_glob: #fileserver_backend: # - git # - roots -{% if 'fileserver_backend' in master %} +{% if 'fileserver_backend' in master -%} fileserver_backend: -{% for backend in master['fileserver_backend'] %} +{%- for backend in master['fileserver_backend'] %} - {{ backend }} -{% endfor %} -{% endif %} +{%- endfor -%} +{%- endif %} # # Uncomment the line below if you do not want the file_server to follow # symlinks when walking the filesystem tree. This is set to True @@ -483,23 +484,23 @@ fileserver_backend: # environments. # Note: file:// repos will be treated as a remote, so refs you want used must # exist in that repo as *local* refs. -{% if 'gitfs_remotes' in master %} +{% if 'gitfs_remotes' in master -%} gitfs_remotes: -{% for remote in master['gitfs_remotes'] %} -{% if remote is iterable and remote is not string %} - {% for repo, children in remote.iteritems() %} +{%- for remote in master['gitfs_remotes'] %} +{%- if remote is iterable and remote is not string %} + {%- for repo, children in remote.iteritems() %} - {{ repo }}: - {% for child in children %} - {% for key, value in child.iteritems() %} + {%- for child in children %} + {%- for key, value in child.iteritems() %} - {{ key }}: {{ value }} - {% endfor %} - {% endfor %} - {% endfor %} - {% else %} + {%- endfor -%} + {%- endfor -%} + {%- endfor -%} + {%- else %} - {{ remote }} -{% endif %} -{% endfor %} -{% endif %} +{%- endif -%} +{%- endfor -%} +{%- endif %} # #gitfs_remotes: # - git://github.com/saltstack/salt-states.git diff --git a/salt/files/minion.d/_defaults.conf b/salt/files/minion.d/_defaults.conf index 67d4b11..26a5772 100644 --- a/salt/files/minion.d/_defaults.conf +++ b/salt/files/minion.d/_defaults.conf @@ -466,7 +466,7 @@ gitfs_remotes: - {{ remote }} {%- endif -%} {%- endfor -%} -{%- endif -%} +{%- endif %} # #gitfs_remotes: # - git://github.com/saltstack/salt-states.git