Skip to content

Feature request, systemd-networkd support #13085

Closed

Description

@aboe76

I would love to see saltstack network module to be able to create
systemd-networkd files

more information:
http://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html
http://www.freedesktop.org/software/systemd/man/systemd.network.html
http://www.freedesktop.org/software/systemd/man/systemd.netdev.html
http://www.freedesktop.org/software/systemd/man/systemd.link.html

and an overview:
http://coreos.com/blog/intro-to-systemd-networkd/

The reason for this module is easy, an unified way to set network interface on all
systemd enabled operating systems, redhat/archlinux/suse/fedora
and in the future: debian

This is my setup on archlinux using a bridge and dhcp failover
The numbering is the order in which systemd-networkd parses the files

/etc/systemd/network:
10-bridge.network
30-bridge.netdev
40-dhcp.network
20-static.network
/etc/systemd/network/10-bridge.network 
[Match]
Name=br0

[Network]
Address=xxx.xxx.xxx.xxx/24
Gateway=xxx.xxx.xxx.xxx
/etc/systemd/network/20-static.network 
[Match]
MACAddress=xx:xx:xx:xx:xx:xx
Name=xxxxxx

[Network]
Bridge=br0
/etc/systemd/network/30-bridge.netdev 
[NetDev]
Name=br0
Kind=bridge
/etc/systemd/network/40-dhcp.network 
[Match]
Name=*

[Network]
DHCP=yes

Activity

  1. gtmanfred commented on May 28, 2014

    @gtmanfred
    Contributor

    I use this... I am working on it soonish...

    @gtmanfred

  2. aboe76 commented on May 28, 2014

    @aboe76
    ContributorAuthor

    Ow I would love to test it

  3. added this to the Approved milestone on May 28, 2014
  4. aboe76 commented on Feb 16, 2015

    @aboe76
    ContributorAuthor

    salt has the potential to be able to do it with salt.states.ini_manage
    http://docs.saltstack.com/en/latest/ref/states/all/salt.states.ini_manage.html

    it only needs to learn about the systemd network/netdev and link files and the options
    for network files: http://www.freedesktop.org/software/systemd/man/systemd.network.html
    for link files: http://www.freedesktop.org/software/systemd/man/systemd.link.html
    fo netdev files: http://www.freedesktop.org/software/systemd/man/systemd.netdev.html

    example:

    /etc/systemd/network/10-bridge.network:
      ini.options_present:
        - sections:
            Match:
              Name: 'br0'
            Network:
              Address: 'xxx.xxx.xxx.xxx/24'
              Gateway: 'xxx.xxx.xxx.xxx'
    
    /etc/systemd/network/20-static.network:
      ini.options_present:
        - sections:
            Match:
              Name: 'eth0'
            Network:
              Description: 'bridge'
              Bridge: 'br0'
    
    /etc/systemd/network/30-bridge.netdev:
      ini.options_present:
        - sections:
            NetDev:
              Name: 'br0'
              Kind: 'bridge'
    
    /etc/systemd/network/40-dhcp.network:
      ini.options_present:
        - sections:
            Match:
              Name: '*'
            Network:
              DHCP: 'both'
    
  5. gtmanfred commented on Feb 16, 2015

    @gtmanfred
    Contributor

    That is a good way to do it, but unfortunately doesn't start the networks.

    I want to get to it, where we do this by passing an ini_settings.present to

    http://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.state.html#salt.modules.state.template_str

    Directly in a networkd module to setup the file and then start the networking.

    temp = json.dump({
      '/etc/systemd/network/40-dhcp.network': {
        'ini.options_present': [
          {'sections': { 'NetDev': {'Name': 'br0', 'Kind': 'bridge'}}}
        ]
      }
    })
    salt['state.template_str'](temp)
    

    something like that.

  6. eliasp commented on Mar 22, 2015

    @eliasp
    Contributor

    After having used systemd-networkd for quite some time without Salt on my Gentoo boxes, I started playing a bit with it on CentOS 7 using Salt to handle it:

    Using the lnykryn/systemd COPR repository to get a reasonable systemd-version (CentOS 7 ships the quite outdated 208):

    # RHEL7/CentOS7 ships the quite outdated systemd version 208
    # The RedHat developer Lukas Nykryn provides a COPR with newer versions
    {% if grains['os'] in ('RedHat', 'CentOS') %}
    systemd-copr:
      pkgrepo.managed:
        - humanname:           Builds of newer systemd versions for CentOS7/RHEL7
        - baseurl:             http://copr-be.cloud.fedoraproject.org/results/lnykryn/systemd/{{ repotype }}-{{ salt['grains.get']('osmajorrelease', 'unknown') }}-$basearch/
        - gpgkey:              https://copr-be.cloud.fedoraproject.org/results/lnykryn/systemd/pubkey.gpg
        - gpgcheck:            1   
        - skip_if_unavailable: True
        - enabled:             1   
        - order:               1   
    
    systemd-packages:
      pkg.latest:
        - pkgs:
          - systemd
          - systemd-networkd
        - require:
          - pkgrepo: systemd-copr
    {% endif %}

    And then the handling of the actual systemd-networkd stuff, where the configuration is created based on Pillar data:

    {% for netservice in ['network', 'NetworkManager'] %}
    # make sure conflicting services are stopped before systemd-networkd takes over
    disable-netservice-{{ netservice }}:
      service.dead:
        - name: {{ netservice }}
        - enable: false
        - require_in:
          - service: systemd-networkd
    {% endfor %}
    
    # when there are ifcfg-* files left over, they can prevent renaming
    # of interfaces via *.link files - just wipe the whole network-scripts
    # directory as it isn't needed anymore and can otherwise be re-created
    # via network.managed - right? ;)
    /etc/sysconfig/network-scripts:
      file.absent:
        - require_in:
          - service: systemd-networkd
    
    systemd-networkd:
      service.running:
        - enable: true
        - require:
          - pkgrepo: systemd-copr
          - pkg: systemd-packages
    
    /etc/systemd/network:
      file.directory:
        - user: systemd-network
        - group: systemd-network
        - mode: '0774'
    
    {% set links = salt['pillar.get']('linux:network:links') %}
    {% if links is defined and links %}
      {% for link, linkdata in links.iteritems() %}
    # prefixing the config files with 00- gives them precedence
    # over global files, such as 99-default.link
    /etc/systemd/network/00-{{ link }}.link:
      ini.sections_present:
        - sections: {{ linkdata|yaml }}
        - require:
          - file: /etc/systemd/network
        - watch_in:
          - service: systemd-networkd
      {% endfor %}
    {% endif %}
    
    {% set netdevs = salt['pillar.get']('linux:network:netdevs') %}
    {% if netdevs is defined and netdevs %}
      {% for netdev, netdevdata in netdevs.iteritems() %}
    /etc/systemd/network/00-{{ netdev }}.netdev:
      ini.sections_present:
        - sections: {{ netdevdata|yaml }}
        - require:
          - file: /etc/systemd/network
        - watch_in:
          - service: systemd-networkd
      {% endfor %}
    {% endif %}
    
    {% set networks = salt['pillar.get']('linux:network:networks') %}
    {% if networks is defined and networks %}
      {% for network, networkdata in networks.iteritems() %}
    /etc/systemd/network/00-{{ network }}.network:
      ini.sections_present:
        - sections: {{ networkdata|yaml }}
        - require:
          - file: /etc/systemd/network
        - watch_in:
          - service: systemd-networkd
      {% endfor %}
    {% endif %}

    The major problem with this approach using the ini state/module is, that ini.sections_present can't handle the weirdness that systemd's INI files are - using non-unique sections (e.g. multiple [Network] per *.network file) and non-unique keys (e.g. multiple DNS=).
    So either the ini state/module needs to be adapted to allow a non-strict mode where a section/key might have multiple instances or the creation of the systemd-networkd config files needs to be done without using the ini state/module.

    This all is still rather rough and CentOS7 specific, but maybe it provides some useful information for others to continue with systemd-networkd support.

  7. aboe76 commented on Feb 6, 2016

    @aboe76
    ContributorAuthor

    is this still being worked on?

  8. eliasp commented on Feb 8, 2016

    @eliasp
    Contributor

    @aboe76 I didn't continue further than what I described in my previous post and unfortunately won't in the foreseeable future.

  9. alexminder commented on Oct 7, 2016

    @alexminder

    Is the feature request is alive?
    There are no ways to configure network on new versions fo Linux OSs.
    The feature is very usefull.
    Today almost every recent Linux host based on systemd and for servers systemd-networkd is prefered network configure tool.
    I use self-made workaround based on ini/file states, but it ugly and works bad.

  10. epcim commented on Jun 5, 2017

    @epcim
    Contributor

    @alexminder commented on Oct 7, 2016, 10:42 AM GMT+2:

    Is the feature request is alive?

    There are no ways to configure network on new versions fo Linux OSs.

    The feature is very usefull.

    Today almost every recent Linux host based on systemd and for servers systemd-networkd is prefered network configure tool.

    I use self-made workaround based on ini/file states, but it ugly and works bad.

    can you pls share link to your workaround?

    personally, systemd network support is desired, it's alternative to network module but it became a mainstream.

    question is what way to enforce such support as it may be in conflict with NetworkManager or some other configurations already on a system.

  11. vtolstov commented on Aug 10, 2017

    @vtolstov
    Contributor

    please share you work, i can take this and may be finish

  12. gtmanfred commented on Aug 10, 2017

    @gtmanfred
    Contributor

    I don't currently have any work on this unfortunately.

  13. alexminder commented on Aug 11, 2017

    @alexminder

    I use self-made workaround based on ini/file states, but it ugly and works bad.

    can you pls share link to your workaround?

    My state for systemd-networkd: https://github.com/alexminder/systemd-networkd_saltstack_state

  14. stale commented on Dec 4, 2018

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

    If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

  15. 10 remaining items

  16. waynegemmell commented on May 31, 2021

    @waynegemmell
    Contributor

    ^ I linked that the incorrect issue.

  17. Lillecarl commented on Jan 24, 2023

    @Lillecarl

    @eliasp @OrangeDog netplan is written in Python, salt would depend on the pip package netplan. Standing on the shoulders of a mature network configuration library rather than building one from scratch sounds sane to me.

    There's also ifupdown2 and ifupdown-ng, though salt people would probably prefer YAML.

    The fact that netplan doesn't unconfigure things when you apply is an issue, at least on systemd-networkd which I've rendered to. Can be solved with extra logic for unconfiguration.

    ifupdown2 unconfigures things it doesn't own anymore (used in CumulusLinux).

  18. dmurphy18 commented on Jul 11, 2023

    @dmurphy18
    Contributor

    Closing this since the original issue was about systemd-network in 2014, and has morphed into a discussion on netplan support. If still interested in this, please open an issue addressing netplan support on Debian / Ubuntu platforms with the current onedir packaging in mind and mark it a 'Feature Request'.

  19. OrangeDog commented on Jul 12, 2023

    @OrangeDog
    Contributor

    Well systemd-networkd is still not supported. The netplan suggestion was just a suggestion of how to implement it. None of this has been completed,

  20. dmurphy18 commented on Jul 13, 2023

    @dmurphy18
    Contributor

    @OrangeDog Given this is almost 10 years old, The OS involved have changed, systemd has been updated, and Python 2 is in the rear-view mirror, I would prefer to have a new issue for systemd-network support on the recent releases and recent OSes than use an almost 10 year old issue to drive the fix. Hmmm! now let me see , did RHEL 5 support systemd ???? :joke:

    @aboe76 Are you still interested in a fix for systemd-network support, if so, please open a new request with current OSes and versions of Salt. Apologies for this having dragged on for so long, came across the issue in a cleanup sweep. Re-closing this issue due to its age and information being very out of date.
    @OrangeDog If you want to open a new issue for the systemd-network with current OSes and versions of Salt, that would also be good too.
    Tag me in the new issue so it gets my attention.

  21. OrangeDog commented on Jul 13, 2023

    @OrangeDog
    Contributor

    Just because it's been ignored for ten years doesn't mean it's changed. None of the information is out of date. All that making a new issue would do is hide the fact that it's taken so very long.

  22. dmurphy18 commented on Jul 13, 2023

    @dmurphy18
    Contributor

    @OrangeDog not hiding the taking so long, just wanting up to date facts, and wheezy is long gone, want what happens on Debian 10 or 11 or 12 etc.

  23. OrangeDog commented on Jul 13, 2023

    @OrangeDog
    Contributor

    Again, there is zero out-of-date information on this ticket.

  24. dmurphy18 commented on Jul 13, 2023

    @dmurphy18
    Contributor

    @OrangeDog Trust but verify lol :)

  25. stappersg commented on Jul 13, 2023

    @stappersg
  26. OrangeDog commented on Jul 13, 2023

    @OrangeDog
    Contributor

    Rather than pointlessly close the ticket and open a new one, why didn't you just ask, or even better verify it yourself?

  27. dmurphy18 commented on Jul 13, 2023

    @dmurphy18
    Contributor

    @OrangeDog Get a new issue with the matters filled out, for example [FEATURE REQUEST] in the title, all the new labels pulled in to manage it, template filled out so searches etc can check on keywords etc. Basically get the issue with all the new templated information so can filter etc., and manage issues / prs etc that an issue from 2014 would not have, but included the ref to the old issue so can go check it out if needed.

    Nothing nefarious, just trying to get the issue into a modern format so that tools will work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions