backward compatible master:pillar:reclass

Change-Id: I7636e3b43996abfa8be21f58ff485d998eacf74c
diff --git a/metadata/service/master/pillar/saltclass.yml b/metadata/service/master/pillar/saltclass.yml
deleted file mode 100644
index 44d682a..0000000
--- a/metadata/service/master/pillar/saltclass.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-parameters:
-  salt:
-    master:
-      pillar:
-        engine: saltclass
-        saltclass:
-          path: /srv/salt/saltclass
diff --git a/salt/files/master.conf b/salt/files/master.conf
index 7fec1bd..10ca746 100644
--- a/salt/files/master.conf
+++ b/salt/files/master.conf
@@ -58,11 +58,13 @@
   - {{ master.pillar.get('salt', {}).get('path', '/srv/salt/pillar') }}
 {%- endif %}
 
-{%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined)  %}
+{%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined) %}
 
 reclass: &reclass
   storage_type: {{ master.pillar.get('reclass', {'storage_type': 'yaml_fs'}).storage_type }}
   inventory_base_uri: {{ master.pillar.get('reclass', {'inventory_base_uri': '/srv/salt/reclass'}).inventory_base_uri }}
+  {# Additional options, for backward compatibility salt:master:pillar might not be defined #}
+  {%- if master.pillar.reclass is defined %}
   {%- if master.pillar.reclass.reclass_source_path is defined %}
   reclass_source_path: {{ master.pillar.reclass.reclass_source_path }}
   {%- endif %}
@@ -80,16 +82,17 @@
   ignore_class_notfound: {{ master.pillar.reclass.ignore_class_notfound }}
   ignore_class_regexp: {{ master.pillar.reclass.ignore_class_regexp }}
   {%- endif %}
+  {%- endif %}
 {%- endif %}
 
-{%- if master.pillar.engine == 'saltclass' or (master.pillar.engine == 'composite' and master.pillar.saltclass is defined )  %}
+{%- if master.pillar.engine == 'saltclass' or (master.pillar.engine == 'composite' and master.pillar.saltclass is defined ) %}
 
 saltclass: &saltclass
   path: {{ master.pillar.saltclass.get('path', '/srv/salt/saltclass') }}
 {%- endif %}
 
 
-{%- if master.pillar.engine in ['composite', 'reclass', 'saltclass'] %}
+{%- if master.pillar.engine in ['composite', 'reclass'] %}
 {# generate indexed list of ext_engines #}
 {# NONE: Might be rewritten, once proved to work properly, with filters: #}
 {# NONE: select('mapping')|selectattr('_index')|sort(attribute='_index') #}
@@ -100,14 +103,18 @@
 {%-   set index = engine.get('index', '1')~'-'~name %}
 {%-   do ext_engines.update({ index: engine }) %}
 {%- endfor %}
-{%- if ext_engines|length > 0 %}
+{%- if ext_engines|length > 0 or master.pillar.engine == "reclass" %}
 
 ext_pillar:
-  {%- for name, engine in ext_engines|dictsort %}
-  {%- if master.pillar.engine in ['composite', 'reclass'] and engine.name == 'reclass' %}
+  {%- if master.pillar.engine == 'reclass' %}
+  {#- too keep backward compatibility, in case master.pillar.reclass is not defied at all #}
   - reclass: *reclass
   {%- endif %}
-  {%- if master.pillar.engine in ['composite', 'saltclass'] and engine.name == 'saltclass' %}
+  {%- for name, engine in ext_engines|dictsort %}
+  {%- if master.pillar.engine == 'composite' and engine.name == 'reclass' %}
+  - reclass: *reclass
+  {%- endif %}
+  {%- if engine.name == 'saltclass' %}
   - saltclass: *saltclass
   {%- endif %}
   {%- if engine.name == 'nacl' %}
@@ -120,16 +127,16 @@
 {%- endif %}
 {%- endif %}
 
-{%- if master.pillar.engine in ['saltclass', 'reclass']
+{%- if master.pillar.engine == 'reclass'
     or (master.pillar.engine == 'composite' and
         (master.pillar.saltclass is defined or
          master.pillar.reclass is defined ))  %}
 
 master_tops:
-  {%- if master.pillar.engine in ['composite', 'reclass'] and master.pillar.get('reclass', False) %}
+  {%- if master.pillar.engine == 'reclass' or (master.pillar.engine == 'composite' and master.pillar.reclass is defined ) %}
   reclass: *reclass
   {%- endif %}
-  {%- if master.pillar.engine in ['composite', 'saltclass'] and master.pillar.get('saltclass', False) %}
+  {%- if master.pillar.engine == 'saltclass' or (master.pillar.engine == 'composite' and master.pillar.saltclass is defined ) %}
   saltclass: *saltclass
   {%- endif %}
 {%- endif %}