Skip to content

Commit

Permalink
Manually configure master IP/network/netmask (#173)
Browse files Browse the repository at this point in the history
* Manually configure master IP/network/netmask

Allow direct configuration of IP/network/netmask for DHCP/PXE.

This is important for systems where you cannot control the naming of network interfaces and
a DHCP server running on the wrong interface might have catastrophic consequences.

* mention new config options in provision.conf and error messages
  • Loading branch information
beinvisible authored and bensallen committed Feb 8, 2019
1 parent fea4d17 commit f13a377
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
7 changes: 7 additions & 0 deletions provision/etc/provision.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
# communicate with the nodes?
network device = eth1

# Alternatively configure the network addresses directly, e.g. if the
# network device name might change. This overrides the values derived
# from the 'network device' setting (if configured) one by one.
# ip address = 172.16.1.1
# ip netmask = 255.255.0.0
# ip network = 172.16.0.0

# Which DHCP server implementation should be used?
dhcp server = isc

Expand Down
8 changes: 4 additions & 4 deletions provision/lib/Warewulf/Provision/Dhcp/Isc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ persist()
my $netobj = Warewulf::Network->new();
my $config = Warewulf::Config->new("provision.conf");
my $devname = $config->get("network device");
my $ipaddr = $netobj->ipaddr($devname);
my $netmask = $netobj->netmask($devname);
my $network = $netobj->network($devname);
my $ipaddr = $config->get("ip address") // $netobj->ipaddr($devname);
my $netmask = $config->get("ip netmask") // $netobj->netmask($devname);
my $network = $config->get("ip network") // $netobj->network($devname);
my $config_template;
my $dhcpd_contents;
my %seen;
Expand All @@ -168,7 +168,7 @@ persist()


if (! $ipaddr or ! $netmask or ! $network) {
&wprint("Could not configure DHCP, check 'network device' configuration!\n");
&wprint("Could not configure DHCP, check 'network device' or 'ip address/netmask/network' configuration!\n");
return undef;
}

Expand Down
8 changes: 4 additions & 4 deletions provision/lib/Warewulf/Provision/HostsFile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ generate()

my $netdev = $config->get("network device");
my $defdomain = $config->get("use localdomain") || "yes";
my $master_ipaddr = $netobj->ipaddr($netdev);
my $master_netmask = $netobj->netmask($netdev);
my $master_network = $netobj->network($netdev);
my $master_ipaddr = $config->get("ip address") // $netobj->ipaddr($netdev);
my $master_network = $config->get("ip network") // $netobj->network($netdev);
my $master_netmask = $config->get("ip netmask") // $netobj->netmask($netdev);

if (! $master_ipaddr or ! $master_netmask or ! $master_network) {
&wprint("Could not generate hostfile, check 'network device' configuration!\n");
&wprint("Could not generate hostfile, check 'network device' or 'ip address/netmask/network' configuration!\n");
return undef;
}

Expand Down
8 changes: 4 additions & 4 deletions provision/lib/Warewulf/Provision/Pxe.pm
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ update()
my $db = Warewulf::DataStore->new();
my $config = Warewulf::Config->new("provision.conf");
my $devname = $config->get("network device");
my $master_ipaddr = $netobj->ipaddr($devname);
my $master_network = $netobj->network($devname);
my $master_netmask = $netobj->netmask($devname);
my $master_ipaddr = $config->get("ip address") // $netobj->ipaddr($devname);
my $master_network = $config->get("ip network") // $netobj->network($devname);
my $master_netmask = $config->get("ip netmask") // $netobj->netmask($devname);

if (! $master_ipaddr) {
&wprint("Could not generate PXE configurations, check 'network device' configuration!\n");
&wprint("Could not generate PXE configurations, check 'network device' or 'ip address/netmask/network' configuration!\n");
return undef;
}

Expand Down

0 comments on commit f13a377

Please sign in to comment.