Merge "move lvm config and service before managing VG and LV"
diff --git a/linux/files/60-net-txqueue.rules b/linux/files/60-net-txqueue.rules
index 7805c9c..8f6478c 100644
--- a/linux/files/60-net-txqueue.rules
+++ b/linux/files/60-net-txqueue.rules
@@ -1 +1 @@
-KERNEL==”tap[0-9a-z\-]*", RUN+="/sbin/ip link set %k txqueuelen {{ network.tap_custom_txqueuelen }}"
\ No newline at end of file
+KERNEL=="tap[0-9a-z\-]*", RUN+="/sbin/ip link set %k txqueuelen {{ tap_custom_txqueuelen }}"
diff --git a/linux/map.jinja b/linux/map.jinja
index 812033a..29dba83 100644
--- a/linux/map.jinja
+++ b/linux/map.jinja
@@ -118,6 +118,8 @@
     'hardware-dma-ring-rx',
     'hwaddr',
     'noifupdown',
+    'arp_ip_target',
+    'primary',
 ] %}
 
 {% set network = salt['grains.filter_by']({
diff --git a/linux/meta/prometheus.yml b/linux/meta/prometheus.yml
index 2d82209..e8a26e3 100644
--- a/linux/meta/prometheus.yml
+++ b/linux/meta/prometheus.yml
@@ -22,6 +22,16 @@
         summary: 'Free space for {{ $labels.path }} too low on {{ $labels.host }}'
         description: 'The disk partition ({{ $labels.path }}) will be full in less than 8 hours on {{ $labels.host }}.'
       {% endraw %}
+    SystemFreeOpenFilesTooLow:
+      if: 'predict_linear(linux_sysctl_fs_file_nr[1h], 8*3600) > linux_sysctl_fs_file_max'
+      {% raw %}
+      labels:
+        severity: warning
+        service: system
+      annotations:
+        summary: 'Free open files for {{ $labels.path }} too low on {{ $labels.host }}'
+        description: 'Host {{ $labels.host }}) will run out of free open files in less than 8 hours.'
+      {% endraw %}
     SystemDiskSpaceFull:
       if: 'disk_used_percent >= 99 and disk_inodes_total > 0'
       {% raw %}
diff --git a/linux/meta/telegraf.yml b/linux/meta/telegraf.yml
index 693638b..45fef5c 100644
--- a/linux/meta/telegraf.yml
+++ b/linux/meta/telegraf.yml
@@ -22,3 +22,4 @@
     processes:
     swap:
     system:
+    linux_sysctl_fs:
diff --git a/linux/network/dhclient.sls b/linux/network/dhclient.sls
index 6de2cfd..c0b007b 100644
--- a/linux/network/dhclient.sls
+++ b/linux/network/dhclient.sls
@@ -8,4 +8,11 @@
     - source: salt://linux/files/dhclient.conf
     - template: jinja
 
+{%- elif network.dhclient.enabled is defined and network.dhclient.enabled == False %}
+
+kill_dhcp_client:
+  cmd.run:
+  - name: "pkill dhclient"
+  - onlyif: "pgrep dhclient"
+
 {%- endif %}
diff --git a/linux/network/interface.sls b/linux/network/interface.sls
index ddcb8d8..921ceac 100644
--- a/linux/network/interface.sls
+++ b/linux/network/interface.sls
@@ -45,6 +45,13 @@
 
 {%- endfor %}
 
+{%- if network.interface is defined %}
+
+remove_cloud_init_file:
+  file.absent:
+  - name: /etc/network/interfaces.d/50-cloud-init.cfg
+
+{%- endif %}
 
 {%- for interface_name, interface in network.interface.iteritems() %}
 
@@ -218,7 +225,7 @@
 
 linux_interface_ipflush_onchange_{{ interface_name }}:
   cmd.run:
-  - name: "/sbin/ip address flush dev {{ interface_name }}"
+  - name: "/sbin/ip address flush dev {{ interface_name }}; ifdown {{ interface_name }} ;ifup {{ interface_name }};"
   - onchanges:
     - network: linux_interface_{{ interface_name }}
 
@@ -373,5 +380,19 @@
   - source: salt://linux/files/60-net-txqueue.rules
   - mode: 755
   - template: jinja
+  - defaults:
+    tap_custom_txqueuelen: {{ network.tap_custom_txqueuelen }}
+
+udev_reload_rules:
+  cmd.run:
+  - name: "/bin/udevadm control --reload-rules"
+  - onchanges:
+    - file: /etc/udev/rules.d/60-net-txqueue.rules
+
+udev_retrigger:
+  cmd.run:
+  - name: "/bin/udevadm trigger --attr-match=subsystem=net"
+  - onchanges:
+    - udev_reload_rules
 
 {%- endif %}
diff --git a/linux/system/grub.sls b/linux/system/grub.sls
index e7e1f8c..74ea553 100644
--- a/linux/system/grub.sls
+++ b/linux/system/grub.sls
@@ -6,8 +6,22 @@
     - mode: 755
     - makedirs: True
 
+{%- if grains['os_family'] == 'RedHat' %}
+/etc/default/grub:
+  file.append:
+    - text:
+      - for i in $(ls /etc/default/grub.d);do source /etc/default/grub.d/$i ;done
+
+grub_update:
+  cmd.wait:
+  - name: grub2-mkconfig -o /boot/grub2/grub.cfg
+
+{%- else %}
+
 {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
 grub_update:
   cmd.wait:
   - name: update-grub
 {%- endif %}
+
+{%- endif %}
diff --git a/tests/pillar/network_extended.sls b/tests/pillar/network_extended.sls
index 19587c9..e0e428d 100644
--- a/tests/pillar/network_extended.sls
+++ b/tests/pillar/network_extended.sls
@@ -8,6 +8,7 @@
     hostname: linux
     fqdn: linux.ci.local
     network_manager: false
+    tap_custom_txqueuelen: 10000
     interface:
       eth0:
         enabled: true
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 3f42101..9451611 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -110,7 +110,7 @@
 }
 
 salt_run() {
-    [ -e ${VEN_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate
+    [ -e ${VENV_DIR}/bin/activate ] && source ${VENV_DIR}/bin/activate
     salt-call ${SALT_OPTS} $*
 }