1

I am running a HyperV environment with Ubuntu 14.04 server running in generation 1 guests setups. It runs nicely.

I want to be able to clone the system (while shut down), give it a new name, and have the new system reconfigure itself slightly - different static IP, different LVS setup, different Apache2 setup, etc. I am doing that by copying over the appropriate configuration files (i.e. the system has multiple copies, it replaces files like /etc/network/interfaces with the right one)

I cannot find an appropriate place in upstart to do this. Doing it before local-file-systems the file system is not available read/write. Doing it after, e.g. in if-pre-up.d during network startup collides with the system's own configuration (i.e. I'm replacing /etc/network/interfaces after it has started using it).

It is not desirable to have it fully boot and run a script as it will pop up on the network with an IP conflict, potentially affecting the parent of this clone. So I want to do it during boot.

I have somewhat gotten this to work by rebooting a second time from if-pre-up.d, after moving the files, before allowing it to finish coming up. But that seems a bit wrong for various reasons, not the least of which it then stops in grub (or whatever that boot screen is) and requires an ENTER key. [I've posted a question on this elsewhere, if you can help with that, please answer there.]

Is there an appropriate place in upstart's sequence that I can overwrite network interface files (and related service files like keepaloved, apache2, haproxy) and have them processed normally?

2

I have continued to beat on this and have it working, though it is not pretty.

I put in a if-pre-up.d script, and took OUT the eth0 device from /etc/interfaces (which is the device I want to configure).

Then when this fires (which may be multiple times), I manually configure eth0 with ip command lines (e.g. ip addr, ip route, etc.). I also wrote the /etc/resolvconf file for dns servers.

I added a line at the beginning which notices if eth0 is already configured and exits, so if it runs multiple times I only do the work once. Doing command line configuration and leaving eth0 out of /etc/interfaces keeps it from conflicting with the normal configuration of eth0.

It's ugly, but I was unable to find an appropriate point in upstart between the local filesystem being configured, but before the network configuration started. At least in theory I could change the associated /etc/init files so I could insert such a step, but that seems fragile, especially during updates.

The result is a self configuring guest that can run in Hyper-V, look at its host name, and configure itself - IP addresses, other startup/config files, etc. In this way I can clone one copy to many, and get all sorts of different setups driven by a simple script.

This works... but I would sure welcome a better answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.