ifdown ifup fix

PROD-16903

Change-Id: I660f745fc7518836f262b08fb92d39bbbe7a24e8
diff --git a/README.rst b/README.rst
index 1449ee1..1184d0a 100644
--- a/README.rst
+++ b/README.rst
@@ -1010,6 +1010,27 @@
             mtu: 9100
             ipflush_onchange: true
 
+Debian static proto interfaces
+
+When you are changing interface proto from dhcp in up state to static, you
+may need to flush ip addresses and restart interface to assign ip address from a managed file.
+For example, if you want to use the interface and the ip on the bridge.
+This can be done by setting the ``ipflush_onchange`` with combination
+``restart_on_ipflush`` param set to to true.
+
+.. code-block:: yaml
+
+    linux:
+      network:
+        interface:
+          eth1:
+            enabled: true
+            type: eth
+            proto: static
+            address: 10.1.0.22
+            netmask: 255.255.255.0
+            ipflush_onchange: true
+            restart_on_ipflush: true
 
 Concatinating and removing interface files
 
diff --git a/linux/network/interface.sls b/linux/network/interface.sls
index 921ceac..b9c1c41 100644
--- a/linux/network/interface.sls
+++ b/linux/network/interface.sls
@@ -225,10 +225,20 @@
 
 linux_interface_ipflush_onchange_{{ interface_name }}:
   cmd.run:
-  - name: "/sbin/ip address flush dev {{ interface_name }}; ifdown {{ interface_name }} ;ifup {{ interface_name }};"
+  - name: "/sbin/ip address flush dev {{ interface_name }}"
   - onchanges:
     - network: linux_interface_{{ interface_name }}
 
+{%- if interface.get('restart_on_ipflush', False) %}
+
+linux_interface_restart_on_ipflush_{{ interface_name }}:
+  cmd.run:
+  - name: "ifdown {{ interface_name }}; ifup {{ interface_name }};"
+  - onchanges:
+    - cmd: linux_interface_ipflush_onchange_{{ interface_name }}
+
+{%- endif %}
+
 {%- endif %}
 
 {%- if salt['grains.get']('saltversion') < '2017.7' %}