Просмотр исходного кода

Add linux.network.systemd support

feature/network_systemd
Petr Michalec 7 лет назад
Родитель
Сommit
eb14b55257
Аккаунт пользователя с таким Email не найден
7 измененных файлов: 150 добавлений и 0 удалений
  1. +36
    -0
      .kitchen.vagrant.yml
  2. +30
    -0
      README.rst
  3. +8
    -0
      linux/files/systemd-network.conf
  4. +3
    -0
      linux/map.jinja
  5. +3
    -0
      linux/network/init.sls
  6. +43
    -0
      linux/network/systemd.sls
  7. +27
    -0
      tests/pillar/network.sls

+ 36
- 0
.kitchen.vagrant.yml Просмотреть файл

@@ -0,0 +1,36 @@
---
driver:
name: vagrant
vm_hostname: linux.ci.local
use_sudo: false
customize:
memory: 1024


provisioner:
name: salt_solo
salt_install: bootstrap
salt_bootstrap_url: https://bootstrap.saltstack.com
salt_version: latest
require_chef: false
log_level: error
formula: linux
grains:
noservices: true
state_top:
base:
"*":
- linux
pillars:
top.sls:
base:
"*":
- linux

platforms:
- name: ubuntu-16.04
- name: ubuntu-14.04
- name: centos-7.3
- name: centos-6.8

# vim: ft=yaml sw=2 ts=2 sts=2 tw=125

+ 30
- 0
README.rst Просмотреть файл

@@ -906,6 +906,36 @@ of available options under send, supersede, prepend, append refer to dhcp-option
reject:
- 192.33.137.211

Linux network systemd settings:

.. code-block:: yaml

linux:
network:
...
systemd:
link:
10-iface-dmz:
Match:
MACAddress: c8:5b:67:fa:1a:af
OriginalName: eth0
Link:
Name: dmz0
netdev:
20-bridge-dmz:
match:
name: dmz0
network:
mescription: bridge
bridge: br-dmz0
network:
# works with lowercase, keys are by default capitalized
40-dhcp:
match:
name: '*'
network:
DHCP: yes


Configure global environment variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 8
- 0
linux/files/systemd-network.conf Просмотреть файл

@@ -0,0 +1,8 @@
{%- from "linux/map.jinja" import system with context -%}
{%- for section, options in settings.iteritems() %}

[{{ section[0].upper() + section[1:] }}]
{%- for option, value in options.iteritems() %}
{{ option[0].upper() + option[1:] }}={{ value }}
{%- endfor %}
{%- endfor %}

+ 3
- 0
linux/map.jinja Просмотреть файл

@@ -100,6 +100,7 @@
'ovs_pkgs': ['openvswitch-switch'],
'hostname_file': '/etc/hostname',
'network_manager': False,
'systemd': {},
'interface': {},
'interface_params': interface_params,
'bridge': 'none',
@@ -115,6 +116,7 @@
'ovs_pkgs': ['openvswitch-switch', 'bridge-utils'],
'dpdk_pkgs': ['dpdk', 'dpdk-dev', 'dpdk-dkms', 'dpdk-igb-uio-dkms', 'dpdk-rte-kni-dkms'],
'network_manager': False,
'systemd': {},
'interface': {},
'interface_params': interface_params,
'bridge': 'none',
@@ -129,6 +131,7 @@
'ovs_pkgs': ['openvswitch-switch', 'bridge-utils'],
'hostname_file': '/etc/sysconfig/network',
'network_manager': False,
'systemd': {},
'interface': {},
'interface_params': interface_params,
'bridge': 'none',

+ 3
- 0
linux/network/init.sls Просмотреть файл

@@ -13,6 +13,9 @@ include:
{%- if network.dhclient is defined %}
- linux.network.dhclient
{%- endif %}
{%- if network.systemd|length > 0 %}
- linux.network.systemd
{%- endif %}
{%- if network.interface|length > 0 %}
- linux.network.interface
{%- endif %}

+ 43
- 0
linux/network/systemd.sls Просмотреть файл

@@ -0,0 +1,43 @@
{%- from "linux/map.jinja" import network with context %}
{%- if network.enabled and grains.get('init', None) == 'systemd' %}

{%- if network.systemd is mapping %}
{%- for config_type, configs in network.systemd.iteritems() %}

{%- if config_type == 'link' %}
/etc/udev/rules.d/80-net-setup-link.rules:
file.managed:
- makedirs: True
- content: ""
{%- endif %}

{%- for config_name, config in configs.iteritems() %}
linux_network_systemd_networkd_{{ config_type }}_config_{{ config_name }}:
file.managed:
- name: /etc/systemd/network/{{ config_name }}.{{ config_type }}
- source: salt://linux/files/systemd-network.conf
- template: jinja
- makedirs: True
- defaults:
settings: {{ config }}
- watch_in:
- module: linux_network_systemd_reload
- module: linux_network_systemd_networkd
{%- endfor %}
{%- endfor %}

linux_network_systemd_reload:
module.wait:
- name: service.systemctl_reload

linux_network_systemd_networkd:
service.running:
- name: systemd-networkd
- init_delay: 10
- enable: True
- reload: True
- watch:
- module: linux_network_systemd_reload

{%- endif %}
{%- endif %}

+ 27
- 0
tests/pillar/network.sls Просмотреть файл

@@ -88,3 +88,30 @@ linux:
# initial_interval: 12
# reject:
# - 10.0.4.0/24
systemd:
link:
10-iface-dmz:
match:
type: eth
# MACAddress: c8:5b:7f:a5:1a:da
# OriginalName: eth0
link:
name: dmz0
netdev:
20-bridge:
NetDev:
Name: br0
Kind: bridge
20-bridge-dmz:
# test all lowercase
match:
name: dmz0
network:
description: bridge
bridge: br-dmz0
network:
40-dhcp:
Match:
Name: '*'
Network:
DHCP: yes

Загрузка…
Отмена
Сохранить