Merge "Move fluentd config under agent role"
diff --git a/README.rst b/README.rst
index 1cbc18c..b90c0f5 100644
--- a/README.rst
+++ b/README.rst
@@ -626,6 +626,21 @@
       system:
         purge_repos: true
 
+Setup custom apt config options:
+
+.. code-block:: yaml
+
+    linux:
+      system:
+        apt:
+          config:
+            compression-workaround:
+              "Acquire::CompressionTypes::Order": "gz"
+            docker-clean:
+              "DPkg::Post-Invoke":
+                - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
+              "APT::Update::Post-Invoke":
+                - "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"
 
 RC
 ~~
@@ -1422,7 +1437,7 @@
                   mount: ${linux:storage:mount:data}
 
 Create partitions on disk. Specify size in MB. It expects empty
-disk without any existing partitions.
+disk without any existing partitions. (set startsector=1, if you want to start partitions from 2048)
 
 .. code-block:: yaml
 
@@ -1430,6 +1445,7 @@
         storage:
           disk:
             first_drive:
+              startsector: 1
               name: /dev/loop1
               type: gpt
               partitions:
diff --git a/linux/files/apt.conf b/linux/files/apt.conf
new file mode 100644
index 0000000..709fbd6
--- /dev/null
+++ b/linux/files/apt.conf
@@ -0,0 +1,9 @@
+// apt.conf file managed by salt-minion
+// DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
+
+{%- for key, value in config.iteritems() %}
+{{ key }} {% if value is iterable and value is not string %}{ {% for entry in value %}"{{ entry }}";{% endfor %} } {% else %}{{ value }};{% endif %}
+{%- endfor %}
+{#-
+vim: syntax=jinja
+-#}
diff --git a/linux/map.jinja b/linux/map.jinja
index c623d63..812033a 100644
--- a/linux/map.jinja
+++ b/linux/map.jinja
@@ -117,6 +117,7 @@
     'hashing-algorithm',
     'hardware-dma-ring-rx',
     'hwaddr',
+    'noifupdown',
 ] %}
 
 {% set network = salt['grains.filter_by']({
diff --git a/linux/meta/salt.yml b/linux/meta/salt.yml
index 9ca9ee9..20c9be9 100644
--- a/linux/meta/salt.yml
+++ b/linux/meta/salt.yml
@@ -12,9 +12,12 @@
     {%- for service_name, service in pillar.items() %}
       {%- if service.get('_support', {}).get('sphinx', {}).get('enabled', False) %}
         {%- set grains_fragment_file = service_name+'/meta/sphinx.yml' %}
-        {%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
-        {%- set grains_yaml = load_grains_file()|load_yaml %}
-        {%- do service_grains.sphinx.doc.update({ service_name: grains_yaml.doc }) %}
+        {%- macro load_grains_file() %}{% include grains_fragment_file ignore missing %}{% endmacro %}
+        {%- set grains = load_grains_file()|load_yaml %}
+        {%- if grains %}
+          {%- set grains_yaml = load_grains_file()|load_yaml %}
+          {%- do service_grains.sphinx.doc.update({ service_name: grains_yaml.doc }) %}
+        {%- endif %}
       {%- endif %}
     {%- endfor %}
     {{ service_grains|yaml(False)|indent(4) }}
diff --git a/linux/network/dpdk.sls b/linux/network/dpdk.sls
index 751941c..1ac9e25 100644
--- a/linux/network/dpdk.sls
+++ b/linux/network/dpdk.sls
@@ -55,6 +55,10 @@
 ]
 %}
 
+{%- if network.openvswitch.get('vhost_socket_dir',{}).get('path') %}
+{%- do ovs_options.append("vhost-sock-dir=\""+network.openvswitch.vhost_socket_dir.path+"\"") %}
+{%- endif %}
+
 {%- for option in ovs_options %}
 
 linux_network_dpdk_ovs_option_{{ option }}:
diff --git a/linux/network/interface.sls b/linux/network/interface.sls
index 6f37348..c97e3dc 100644
--- a/linux/network/interface.sls
+++ b/linux/network/interface.sls
@@ -346,6 +346,14 @@
       # Workaround for Upstream-Bug: https://github.com/saltstack/salt/issues/40262
       source /etc/network/interfaces.u/*
 
+linux_interfaces_final_include_no_requisite:
+  file.prepend:
+  - name: /etc/network/interfaces
+  - text: |
+      source /etc/network/interfaces.d/*
+      # Workaround for Upstream-Bug: https://github.com/saltstack/salt/issues/40262
+      source /etc/network/interfaces.u/*
+
 {%- endif %}
 
 {%- endif %}
diff --git a/linux/storage/disk.sls b/linux/storage/disk.sls
index 4fc96e5..f6c70c5 100644
--- a/linux/storage/disk.sls
+++ b/linux/storage/disk.sls
@@ -20,6 +20,9 @@
     - pkg: parted
 
 {% set end_size = 0 -%}
+{% if disk.get('startsector', None) %}
+{% set end_size = disk.get('startsector')|int %}
+{% endif %}
 
 {%- for partition in disk.get('partitions', []) %}
 
diff --git a/linux/system/apt.sls b/linux/system/apt.sls
new file mode 100644
index 0000000..dca8135
--- /dev/null
+++ b/linux/system/apt.sls
@@ -0,0 +1,27 @@
+{%- from "linux/map.jinja" import system with context %}
+{%- if system.enabled %}
+{%- if grains.os_family == 'Debian' %}
+
+{%- if system.repo|length > 0 %}
+include:
+- linux.system.repo
+{%- endif %}
+
+{%- for key, config in system.apt.get('config', {}).iteritems() %}
+
+linux_apt_conf_{{ key }}:
+  file.managed:
+  - name: /etc/apt/apt.conf.d/99{{ key }}-salt
+  - template: jinja
+  - source: salt://linux/files/apt.conf
+  - defaults:
+      config: {{ config|yaml }}
+  {%- if system.repo|length > 0 %}
+  - require_in:
+    - pkg: linux_repo_prereq_pkgs
+  {%- endif %}
+
+{%- endfor %}
+
+{%- endif %}
+{%- endif %}
diff --git a/linux/system/init.sls b/linux/system/init.sls
index 4dc1a8c..e17adc5 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -99,3 +99,6 @@
 {%- if system.directory is defined %}
 - linux.system.directory
 {%- endif %}
+{%- if system.apt is defined and grains.os_family == 'Debian' %}
+- linux.system.apt
+{%- endif %}
diff --git a/tests/pillar/network_openvswitch_dpdk.sls b/tests/pillar/network_openvswitch_dpdk.sls
index fa96cb9..d4e6785 100644
--- a/tests/pillar/network_openvswitch_dpdk.sls
+++ b/tests/pillar/network_openvswitch_dpdk.sls
@@ -16,6 +16,9 @@
       dpdk_socket_mem: "1024"
       dpdk_lcore_mask: "0x400"
       memory_channels: "2"
+      vhost_socket_dir:
+        name: "openvswitch-vhost"
+        path: "/run/openvswitch-vhost"
     interface:
       dpdk0:
         name: enp5s0f1