NetworkManager on Server-Type Machines (or, why our initscripts suck)

Thomas: first, you can use NM on simple servers, or you can revert to the ‘network’ service.  But there shouldn’t be anything preventing you from using NM on a server.  We’ve tried hard to expand NM’s capabilities in that direction while still retaining the ease-of-use everyone is accustomed to.

But let’s examine your issue.  NM starts the network asynchronously, while ‘service network’ does not.  That obviously means that by the time the system gets to drbd’s init script, the network may or may not be up yet.  The typical solution to this on Fedora is to set NETWORKWAIT=yes in /etc/sysconfig/network, which causes NM’s initscript to block for 30 seconds or until a network connection is brought up (whichever is first).  Or better, drop a dispatcher script into /etc/NetworkManager/dispatcher.d that kicks drbd when the network goes up or down.  Quite a few Fedora services already have these, even sendmail!

‘man NetworkManager’ has more information on dispatcher scripts.  NM runs scripts in /etc/NetworkManager/dispatcher.d when various network events occur, which you can use to kick drbd to life when the network comes up or goes down.

The main problem is initscripts and daemons that simply aren’t smart enough to figure out what resources they require (like network connectivity) and wait until that requirement is available to them.  Instead, they quit.  And since we don’t have a real event system yet (though Upstart promises to be that) the services don’t get restarted when their resources become available.

In a perfect world, the initscript would parse the config file, figure out that it needs ‘eth0′ to be connected (or maybe just some interface with the IP address 52.67.89.3).  Then, when NM brings up eth0 or when some interface gets 52.67.89.3, Upstart would look through that initscripts dependencies, notice that they are now fulfilled, and start the service.  When eth0 goes down, Upstart stops the service.  Kittens frolic in the sweet fields of clover.

Next, you probably want to make sure that your connections are ‘system’ connections, that is available to all users and before login.  For Fedora, this means creating a typical ifcfg file for your network configuration, which NetworkManager will then pick up and use to activate your device at boot time.  You can do this either by creating the ifcfg file yourself, or using nm-connection-editor and checking the “Available to all users” button.  See this wiki page for more information.

Comments are closed.