From 7c86eb4054c4d0123e9c8a4a92368b82c3ce2cae Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Nov 19 2017 19:20:44 +0000 Subject: pillar: replace include_optional macro with ignore_missing Salt allows to specify "ignore_missing: True" since a while, so let's use the official solution instead of a custom macro. --- diff --git a/pillar/macros.jinja b/pillar/macros.jinja index 75fe364..a824781 100644 --- a/pillar/macros.jinja +++ b/pillar/macros.jinja @@ -1,11 +1,3 @@ -{%- macro include_optional(sls_file) %} - {%- for root in opts['pillar_roots'][saltenv] -%} - {%- if salt['file.file_exists']('{0}/{1}/init.sls'.format(root, sls_file)) or salt['file.file_exists']('{0}/{1}.sls'.format(root, sls_file)) %} - - {{ sls_file }} - {% endif %} - {%- endfor %} -{%- endmacro %} - {%- macro valid_virt_cluster() -%} {%- import_yaml "valid_custom_grains.yaml" as valid_custom_grains -%} {%- set valid_virt_cluster = [] -%} diff --git a/pillar/top.sls b/pillar/top.sls index eab9795..2680eda 100644 --- a/pillar/top.sls +++ b/pillar/top.sls @@ -1,4 +1,3 @@ -{% from "macros.jinja" import include_optional with context %} {% from "macros.jinja" import valid_virt_cluster with context %} {% set country = salt['grains.get']('country') %} {% set domain = salt['grains.get']('domain') %} @@ -16,7 +15,8 @@ production: {% for role in roles %} 'roles:{{ role }}': - match: grain - {{ include_optional("role/{0}".format(role)) }} + - ignore_missing: True + - role.{{ role }} {% endfor %} {% if virt_cluster in valid_virt_cluster() %} 'virt_cluster:{{ virt_cluster }}':