Permalink
Browse files

Use systemd to configure the network.

Signed-off-by: Volker Theile <votdev@gmx.de>
  • Loading branch information...
votdev committed Jul 30, 2018
1 parent a28068b commit fba28ea861eae60c150392eb49ea7b40b2857dc4
Showing with 784 additions and 460 deletions.
  1. +1 −0 deb/openmediavault/debian/changelog
  2. +3 −3 deb/openmediavault/debian/control
  3. +8 −1 deb/openmediavault/debian/openmediavault.postinst
  4. +12 −0 deb/openmediavault/srv/salt/_modules/omv.py
  5. +6 −11 deb/openmediavault/srv/salt/omv/deploy/interfaces/{00header.sls → 10cleanup.sls}
  6. +16 −12 deb/openmediavault/srv/salt/omv/deploy/interfaces/{20en.sls → 20wired.sls}
  7. +0 −49 deb/openmediavault/srv/salt/omv/deploy/interfaces/30bond.sls
  8. +66 −0 deb/openmediavault/srv/salt/omv/deploy/interfaces/30wireless.sls
  9. +71 −0 deb/openmediavault/srv/salt/omv/deploy/interfaces/40bond.sls
  10. +0 −39 deb/openmediavault/srv/salt/omv/deploy/interfaces/40wl.sls
  11. +37 −12 deb/openmediavault/srv/salt/omv/deploy/interfaces/50vlan.sls
  12. +6 −4 deb/openmediavault/srv/salt/omv/deploy/interfaces/default.sls
  13. +0 −68 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/bond.j2
  14. +13 −0 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/bond_netdev.j2
  15. +61 −0 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/bond_network.j2
  16. +0 −61 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/en.j2
  17. +0 −9 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/lo.j2
  18. +0 −62 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/vlan.j2
  19. +6 −0 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/vlan_netdev.j2
  20. +60 −0 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/vlan_network.j2
  21. +60 −0 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/wired_network.j2
  22. +60 −0 deb/openmediavault/srv/salt/omv/deploy/interfaces/files/wireless_network.j2
  23. +7 −7 deb/openmediavault/srv/salt/omv/deploy/{interfaces/05defaults.sls → resolvconf/default.sls}
  24. +21 −0 deb/openmediavault/srv/salt/omv/deploy/resolvconf/init.sls
  25. +9 −11 deb/openmediavault/srv/salt/omv/{deploy/interfaces/10lo.sls → task/network/default.sls}
  26. +21 −0 deb/openmediavault/srv/salt/omv/task/network/init.sls
  27. +56 −0 deb/openmediavault/srv/salt/omv/task/network/interface/delete.sls
  28. +28 −0 deb/openmediavault/usr/share/openmediavault/confdb/migrations.d/conf_5.0.0.sh
  29. +0 −3 deb/openmediavault/usr/share/openmediavault/datamodels/conf.system.network.interface.json
  30. +0 −16 deb/openmediavault/usr/share/openmediavault/datamodels/rpc.network.json
  31. +10 −16 deb/openmediavault/usr/share/openmediavault/engined/module/interfaces.inc
  32. +7 −7 deb/openmediavault/usr/share/openmediavault/engined/rpc/network.inc
  33. +0 −1 deb/openmediavault/usr/share/openmediavault/firstaid/modules.d/10configure_network.py
  34. +0 −1 deb/openmediavault/usr/share/openmediavault/templates/config.xml
  35. +75 −47 deb/openmediavault/usr/share/php/openmediavault/system/net/networkinterface.inc
  36. +4 −0 deb/openmediavault/usr/share/php/openmediavault/system/net/networkinterfacebackend/vlan.inc
  37. +11 −9 deb/openmediavault/usr/share/php/openmediavault/system/net/networkinterfacebond.inc
  38. +44 −0 deb/openmediavault/usr/share/php/openmediavault/system/net/networkinterfacevlan.inc
  39. +0 −10 deb/openmediavault/var/www/openmediavault/js/omv/module/admin/system/network/Interfaces.js
  40. +2 −1 vagrant/Vagrantfile
  41. +3 −0 vagrant/install.sh
@@ -6,6 +6,7 @@ openmediavault (5.0) unstable; urgency=low
will not only create the configuration files, it will also take care
about to start/stop/restart the services.
* Issue #93: Use chrony instead of ntpd.
* Issue #146: Use systemd to configure the network.
-- Volker Theile <volker.theile@openmediavault.org> Tue, 08 May 2018 22:06:11 +0200
@@ -10,16 +10,16 @@ Package: openmediavault
Architecture: all
Depends: ${perl:Depends}, libjs-extjs6, php-fpm, libpam-modules, php-json,
php-cgi, php-cli, php-mbstring, php-pam, sudo, ethtool, python3-dialog,
acl, ifenslave, resolvconf, iproute2, xfsprogs, jfsutils, ntfs-3g, hdparm,
sdparm, ifupdown, mdadm, postfix, libsasl2-modules, bsd-mailx, python3-dbus,
acl, iproute2, xfsprogs, jfsutils, ntfs-3g, hdparm,
sdparm, mdadm, postfix, libsasl2-modules, bsd-mailx, python3-dbus,
cpufrequtils, rsyslog, logrotate, smartmontools, openssl, openssh-server,
uuid, tzdata, nfs-kernel-server, proftpd-basic, lsb-release,
wget, util-linux, samba, samba-common-bin, rsync, apt-utils,
avahi-daemon, libnss-mdns, iptables, monit, acpid, beep, php-bcmath,
gdisk, rrdtool, collectd, cron, anacron, cron-apt, quota, php-xml,
quotatool, whiptail, lvm2, watchdog, ca-certificates, perl, libjson-perl,
liblocale-po-perl, proftpd-mod-vroot, libjavascript-minifier-xs-perl,
coreutils, xmlstarlet, mount, parted, bash, diffutils, lsof,
coreutils, xmlstarlet, mount, parted, bash, diffutils, lsof, isc-dhcp-client,
socat, rrdcached, locales, nginx, bash-completion, python3,
python3-apt, pm-utils, wpasupplicant, systemd, systemd-sysv, btrfs-progs,
samba-vfs-modules, pciutils, python3-pyudev, python3-natsort, jq, chrony,
@@ -95,6 +95,7 @@ case "$1" in
# Setup all services.
####################################################################
echo "Updating service units ..."
# Stop/Disable various services.
deb-systemd-helper disable chrony.service
deb-systemd-invoke stop chrony.service || :
deb-systemd-helper disable smartmontools.service
@@ -114,6 +115,12 @@ case "$1" in
# The salt-minion service does not need to be running when
# running a masterless minion setup.
deb-systemd-invoke stop salt-minion.service || :
# Enable/Start various services.
deb-systemd-helper enable systemd-networkd.service
deb-systemd-invoke start systemd-networkd.service || :
deb-systemd-helper enable systemd-resolved.service
deb-systemd-invoke start systemd-resolved.service || :
fi
# Create public/private SSH key pair for user root.
@@ -166,7 +173,7 @@ case "$1" in
echo "Deploying service configurations ..."
omv-salt deploy run --quiet mdadm cpufrequtils cronapt watchdog \
monit rrdcached avahi ssh nginx collectd phpfpm issue sysctl \
acpid
acpid resolvconf
fi
########################################################################
@@ -24,6 +24,10 @@
import re
import subprocess
# Import Salt libs
import salt.utils.network
from salt.utils.decorators.jinja import jinja_filter
def _get_config(args):
"""
Use the CLI tool to query the database. As soon as Salt is Python 3
@@ -75,3 +79,11 @@ def is_ipv6_enabled():
# Filter unwanted interfaces.
lines = [l for l in lines if not re.match(r'^\s+lo$', l)]
return len(lines) > 0
@jinja_filter('network_prefix_len')
def get_net_size(mask):
"""
Turns an IPv4 netmask into it's corresponding prefix length
(255.255.255.0 -> 24 as in 192.168.1.10/24).
"""
return salt.utils.network.get_net_size(mask)
@@ -17,14 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
configure_interfaces:
file.managed:
- name: "/etc/network/interfaces"
- contents:
- "{{ pillar['headers']['auto_generated'] }}"
- "{{ pillar['headers']['warning'] }}"
- ""
- ""
- user: root
- group: root
- mode: 644
remove_systemd_networkd_config_files:
module.run:
- file.find:
- path: "/etc/systemd/network/"
- iname: "openmediavault-*"
- delete: "f"
@@ -18,22 +18,26 @@
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
# Documentation/Howto:
# https://docs.saltstack.com/en/latest/ref/states/all/salt.states.network.html
# https://github.com/saltstack/salt/blob/develop/salt/states/network.py
# https://github.com/saltstack/salt/blob/develop/salt/modules/debian_ip.py
# https://github.com/saltstack/salt/blob/develop/salt/templates/debian_ip/debian_eth.jinja
# https://www.freedesktop.org/software/systemd/man/systemd.network.html
# https://wiki.archlinux.org/index.php/Systemd-networkd
# https://manpages.debian.org/systemd/systemd.link.5.en.html
{% set dns = salt['omv.get_config']('conf.system.network.dns') %}
{% set interfaces = salt['omv.get_config_by_filter'](
'conf.system.network.interface',
'{"operator": "stringEquals", "arg0": "type", "arg1": "ethernet"}') %}
configure_interfaces_en:
file.append:
- name: "/etc/network/interfaces"
- sources:
- salt://{{ slspath }}/files/en.j2
{% for interface in interfaces %}
configure_interface_wired_{{ interface.devicename }}_network:
file.managed:
- name: "/etc/systemd/network/openmediavault-{{ interface.devicename }}.network"
- source:
- salt://{{ slspath }}/files/wired_network.j2
- template: jinja
- context:
dns: {{ dns | json }}
interfaces: {{ interfaces | json }}
interface: {{ interface | json }}
- user: root
- group: root
- mode: 644
{% endfor %}

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,66 @@
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2018 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
# Documentation/Howto:
# https://wiki.archlinux.org/index.php/Systemd-networkd#Wireless_adapter
# https://www.linkedin.com/pulse/using-systemd-networkd-manage-your-network-ajibola-okubanjo
# https://remy.grunblatt.org/using-systemd-networkd-with-wpa_supplicant-to-manage-wireless-network-configuration.html
{% set interfaces = salt['omv.get_config_by_filter'](
'conf.system.network.interface',
'{"operator": "stringEquals", "arg0": "type", "arg1": "wireless"}') %}
{% for interface in interfaces %}
configure_interface_wireless_{{ interface.devicename }}_network:
file.managed:
- name: "/etc/systemd/network/openmediavault-{{ interface.devicename }}.network"
- source:
- salt://{{ slspath }}/files/wireless_network.j2
- template: jinja
- context:
interface: {{ interface | json }}
- user: root
- group: root
- mode: 644
configure_wpa_supplicant_{{ interface.devicename }}:
file.managed:
- name: "/etc/wpa_supplicant/wpa_supplicant-{{ interface.devicename }}.conf"
- contents: |
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
eapol_version=1
ap_scan=1
fast_reauth=1
network={
ssid="{{ interface.wpassid }}"
psk="{{ interface.wpapsk }}"
}
- user: root
- group: root
- mode: 640
restart_wpa_supplicant_{{ interface.devicename }}:
service.running:
- name: wpa_supplicant@{{ interface.devicename }}
- enable: True
{% endfor %}
@@ -0,0 +1,71 @@
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2018 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
# Documentation/Howto:
# https://wiki.debian.org/Bonding
# https://forum.manjaro.org/t/how-to-create-lacp-802-3ad-bond-using-systemd-networkd/14655
# https://kerlilow.me/blog/setting-up-systemd-networkd-with-bonding/
{% set interfaces = salt['omv.get_config_by_filter'](
'conf.system.network.interface',
'{"operator": "stringEquals", "arg0": "type", "arg1": "bond"}') %}
{% for interface in interfaces %}
configure_interface_bond_{{ interface.devicename }}_netdev:
file.managed:
- name: "/etc/systemd/network/openmediavault-{{ interface.devicename }}.netdev"
- source:
- salt://{{ slspath }}/files/bond_netdev.j2
- template: jinja
- context:
interface: {{ interface | json }}
- user: root
- group: root
- mode: 644
configure_interface_bond_{{ interface.devicename }}_network:
file.managed:
- name: "/etc/systemd/network/openmediavault-{{ interface.devicename }}.network"
- source:
- salt://{{ slspath }}/files/bond_network.j2
- template: jinja
- context:
interface: {{ interface | json }}
- user: root
- group: root
- mode: 644
{% for slave in interface.slaves.split(',') %}
configure_interface_bond_{{ slave }}_network:
file.touch:
- name: "/etc/systemd/network/openmediavault-{{ slave }}.network"
ini.options_present:
- name: "/etc/systemd/network/openmediavault-{{ slave }}.network"
- separator: "="
- sections:
Match:
Name: {{ slave }}
Network:
Bond: {{ interface.devicename }}
{% endfor %}
{% endfor %}

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit fba28ea

Please sign in to comment.