3

I want to setup a big amount of servers using cloning. After the initial image was applied, I want to run a configuration script. The cloning will be done through hard disk replication by the hardware vendor.

Steps:

  1. Hardware vendor builds new server
  2. Hardware ships with hard drives having the initial image
  3. Server is setup at final location
  4. Server boots.
  5. Server runs initial configuration script.
  6. Server reboots.

What are the approaches to implement step 5 and 6 meeting the requirements below?

  • Ubuntu 12.04 LTS
  • Script should start and run without user interaction when the machine is turned on.
  • Script should run after all daemons started.
  • Script should output status on console.
  • Script should allow user input on error conditions.

2 Answers 2

1

I have not tried this approach but it sounds like what you are looking for. The tool is called UbuntuPostInstall.

It can be downloaded as part of the post install and/or deployed afterwards. It also makes use of a config file with the choices already backed in which can be also downloaded as part of it's startup. You can read more on the main page of the tool, it's a bit too much to include in an answer here.

Invoking

They show 2 methods which you can use to invoke it:

download .cfg file from network

$ sudo ./ubuntu-12.04-postinstall.py -c https://raw.github.com/nicolargo/ubuntupostinstall/master/ubuntu-12.04-gnomeshel

use local file

$ sudo ./ubuntu-12.04-postinstall.py -c mycfg.cfg

pre/post actions

These sections allow you to run custom scripts either before anything happens (the preactions) and/or after everything else has completed (postactions).

Packages & Repositories

You can either install or remove packages, or use it to add additional PPAs for access to 3rd party APT repositories.

Logging

Given it's a Python script you could run the output of this script through the tee command and have the output directed to both a file as well as the console.

2
  • Thanks for the comprehensive reply. However, I am still wondering how to implement the actual scheduling bit. Meaning how/what component/where can I best run the "sudo ./ubuntu-12.04-postinstall.py -c mycfg.cfg" given the requirements listed inthe OP. Commented Sep 9, 2013 at 21:48
  • @Alex - understood. Let me research this a bit more and see if I can come up with some additional ideas. Commented Sep 9, 2013 at 22:17
0

The /etc/rc.local file is supposed to be guaranteed to be the last initscript executed, although I'm not sure this is so on ubuntu. You can call your config script from rc.local, then mv the file on successful completion so it doesn't run on reboot (or similar option).

For console output with systemd, I had to create a file that explicitly told the service to log to both console and syslog. IIRC, ubuntu uses upstart and maybe this will help: https://askubuntu.com/questions/115034/debugging-console-output-and-upstart-scripts

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.