Skip to content

Commit

Permalink
learn about routes
Browse files Browse the repository at this point in the history
  • Loading branch information
akerl committed Jan 1, 2024
1 parent 74fb69c commit fbcab69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 11 additions & 7 deletions manifests/systemd.pp
Expand Up @@ -61,13 +61,17 @@
}
}

$facts['networking']['interfaces'].each |String $iface, Any $value| {
unless $iface in $bridge_children or $iface in $bridges or $iface in $vlans or $ignore.any |$item| { $iface.match($item) } {
file { "/etc/systemd/network/${iface}.network":
ensure => file,
content => template('network/interface.network.erb'),
notify => Service['systemd-networkd'],
}
$real_interfaces = $facts['networking']['interfaces'].filter |String $iface, Any $value| {
!($iface in $bridge_children or $iface in $bridges or $iface in $vlans or $ignore.any |$item| { $iface.match($item) })
}

$primary_interface = sort($real_interfaces)[0]

$real_interfaces.each |String $iface, Any $value|
file { "/etc/systemd/network/${iface}.network":
ensure => file,
content => template('network/interface.network.erb'),
notify => Service['systemd-networkd'],
}
}
service { 'systemd-networkd':
Expand Down
3 changes: 3 additions & 0 deletions templates/interface.network.erb
Expand Up @@ -11,3 +11,6 @@ VLAN=<%= vlan_name %>

[DHCPv4]
UseDNS=no
<% if @iface == @primary_interface -%>
RouteMetric=1000
<% end -%>

0 comments on commit fbcab69

Please sign in to comment.