Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add manage_network to manage networks in code #340

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rwaffen
Copy link
Member

@rwaffen rwaffen commented Apr 25, 2023

add manage_network so that one can define networks in code like one can do it with unit_files and manage_unit.

missing:

  • maybe more complex types to check the *_entry in manage_network like in manage_unit.
  • assert_Type does somehow not work in my local tests (Says its expecting a Resource Statement but got String)

early tests with code like this seem to work

include systemd

systemd::manage_network { 'myhome.network':
  match_entry   => {
    'Name' => 'enp0s8',
  },
  network_entry => {
    'Address' => '10.1.1.1/24',
    'Gateway' => '10.1.1.1',
  },
  address_entry => {
    'Address' => '10.1.1.2',
  },
}

Copy link
Contributor

@traylenator traylenator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate it is WIP still.

# @param address_entry key value pairs for [Address] section of the unit file
#
define systemd::manage_network (
Enum['file', 'absent'] $ensure = 'file',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of module uses present and absent . The fact it a file is a hidden detail.

mode => $mode,
show_diff => $show_diff,
restart_service => $restart_service,
content => epp('systemd/network.epp', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than a new template the existing unit.epp could be extended to just support [Match], [Network] and [Address].

You would get manage_unit and manage_dropin of a network for free in the process. manage_unit .
manage_unit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but wouldn't it get to overloaded, with dropin, units and networks? the initial 3 *_entry are only a subset, netword offers a lot more. so i thought better have it separated. otherwise you will never get a PR done if you have to check alle the influence you change could have?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easier to deal with the interaction in a common layer.

Template does need refactoring to loop over the section rather than enumerate them but that just strengthens case for one template.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯_(ツ)_/¯ i also can add my stuff there, if this is whats needed to merge this in the end. i'm personally just not a big fand off such über-templates.

@trefzer
Copy link
Contributor

trefzer commented Oct 29, 2024

@rwaffen are you still working on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants