added possibility to use list for sysfs params

Change-Id: Id9ffc5cbbbb10fd6136d459ed461151a1800e857
related-bug: PROD-21205
diff --git a/README.rst b/README.rst
index 45c045d..8367d87 100644
--- a/README.rst
+++ b/README.rst
@@ -429,7 +429,7 @@
             - tp_smapi
             - 8021q
 
-Configure or blacklist kernel modules with additional options to `/etc/modprobe.d` following example 
+Configure or blacklist kernel modules with additional options to `/etc/modprobe.d` following example
 will add `/etc/modprobe.d/nf_conntrack.conf` file with line `options nf_conntrack hashsize=262144`:
 
 .. code-block:: yaml
@@ -554,7 +554,7 @@
             java:
               - /usr/lib/jvm/jre-openjdk/lib/amd64/server
               - /opt/java/jre/lib/amd64/server
-    
+
 
 Certificates
 ~~~~~~~~~~~~
@@ -601,6 +601,22 @@
               power/state: "root:power"
             devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
 
+Optional: You can also use list that will ensure order of items.
+
+.. code-block:: yaml
+
+    linux:
+      system:
+        sysfs:
+          scheduler:
+            block/sda/queue/scheduler: deadline
+          power:
+            - mode:
+                power/state: 0660
+            - owner:
+                power/state: "root:power"
+            - devices/system/cpu/cpu0/cpufreq/scaling_governor: powersave
+
 Huge Pages
 ~~~~~~~~~~~~
 
diff --git a/linux/files/sysfs.conf b/linux/files/sysfs.conf
index ff26672..f45098f 100644
--- a/linux/files/sysfs.conf
+++ b/linux/files/sysfs.conf
@@ -1,7 +1,15 @@
 # Sysfs file for {{ name }} managed by salt-minion(1)
 #   DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
 
-{%- for key, value in sysfs.items() %}
+{%- if sysfs is mapping %}
+{%- set sysfs_list = [sysfs] %}
+{%- else %}
+{%- set sysfs_list = sysfs %}
+{%- endif %}
+
+
+{%- for item in sysfs_list %}
+{%- for key, value in item.items() %}
   {%- if key in ["mode", "owner"] %}
     {%- for attr, val in value.items() %}
 mode {{ attr }} = {{ val }}
@@ -10,6 +18,7 @@
 {{ key }} = {{ value }}
   {%- endif %}
 {%- endfor %}
+{%- endfor %}
 
 {#-
 vim: syntax=jinja
diff --git a/linux/system/sysfs.sls b/linux/system/sysfs.sls
index 71c560b..9b0b8f6 100644
--- a/linux/system/sysfs.sls
+++ b/linux/system/sysfs.sls
@@ -26,7 +26,14 @@
     - require:
       - file: /etc/sysfs.d
 
-  {%- for key, value in sysfs.items() %}
+{%- if sysfs is mapping %}
+{%- set sysfs_list = [sysfs] %}
+{%- else %}
+{%- set sysfs_list = sysfs %}
+{%- endif %}
+
+{%- for item in sysfs_list %}
+{%- for key, value in item.items() %}
     {%- if key not in ["mode", "owner"] %}
       {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
       {#- Sysfs cannot be set in docker, LXC, etc. #}
@@ -40,3 +47,4 @@
   {%- endfor %}
 
 {%- endfor %}
+{%- endfor %}