How to start a task before networking?

Posted by user1252434 on Ask Ubuntu See other posts from Ask Ubuntu or by user1252434
Published on 2012-06-05T08:38:28Z Indexed on 2012/06/27 15:26 UTC
Read the original article Hit count: 471

Filed under:
|

I've written an upstart task that modifies /etc/network/interfaces. (Actually a file sourced into it.) Which start on condition do I need to declare to let my task run before any networking jobs?

I've tried start on starting networking, but that's apparently too late. When I log in after booting I can see that the changes were written, but obviously they are not used: the new config states a static IP, but the boot process waits for a non-existing DHCP server (old config) to time out.

I've also tried start on starting network-interface INTERFACE=eth0, which didn't work either. IIRC there was an error in the log that the change couldn't be written.

Background: I need a VM template that can be cloned and the clones configured through a script. Among other settings, I need to give them a static IP address to access them from the host. I use guestfish to write a config file to one of the virtual disks and let a script apply these settings to the system. I don't want that disk to contain an actual system settings file. I can't modify /etc directly, because that disk is shared (copy-on-write/diff) among the clones and guestfish apparently doesn't support that type of image. I could also let them use DHCP and setup a server that assigns IP by MAC, but I'm afraid of the complexity. I could also add just another virtual disk for configuration files, but if possible I'd prefer to store settings directly on the system disk image.

Used software: Ubuntu Server 12.04, VirtualBox. The configuration modifier is a self written ruby script.

© Ask Ubuntu or respective owner

Related posts about networking

Related posts about upstart