Project

General

Profile

Actions

Bug #36036

open

Please add $interface[subnet][prefix]

Added by Han Boetes over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

I just set up a puppet class for systemd-networkd, see below
The problem is, the $interface array doesn't contain prefix. It does have networkmask (/255.255.255.0), but systemd-networkd wants prefix (/24).

  $::foreman_interfaces.each |$interface| {
    if ($interface[primary] == true) {
      $content = @("EOT")
[Match]
Name=${interface[identifier]}
[Network]
Address=${interface[ip]}/${interface[subnet][prefix]}
Gateway=${interface[subnet][gateway]}
DNS=${interface[subnet][dns_primary]}
DNS=${interface[subnet][dns_secondary]}

# ${interface}                                                                                                                 
|EOT
      systemd::network{"${interface[identifier]}.network":
        content         => $content,
        restart_service => false,
      }
    }
  }

Which results in:

[Match]
Name=eno2
[Network]
Address=10.10.11.224/
Gateway=10.10.10.1
DNS=10.10.10.11
DNS=10.10.10.12

Therefore my kind request to add ${interface[subnet][prefix]} to the exported variables.

Actions #1

Updated by Han Boetes over 1 year ago

With some help from bastelfreak @IRC I hacked around the issue like this:

  $::foreman_interfaces.each |$interface| {
    if ($interface[primary] == true) {
      $prefix = extlib::netmask_to_cidr($interface[subnet][mask])
      $content = @("EOT")
[Match]
Name=${interface[identifier]}
[Network]
Address=${interface[ip]}/${prefix}
Gateway=${interface[subnet][gateway]}
DNS=${interface[subnet][dns_primary]}
DNS=${interface[subnet][dns_secondary]}

# ${interface}                                                                                                                 
|EOT
      systemd::network{"${interface[identifier]}.network":
        content         => $content,
        restart_service => false,
      }
    }
  }

But I hope you agree with me having ${interface[subnet][prefix]} would be nicer.

Actions

Also available in: Atom PDF