How can I auto-install and -configure a Linux system?

1

There are a number of programs I always install on any new Linux installation (e.g. hd-idle, zsh, ruby); and a number of configuration tasks I always perform (e.g. custom zshrc).

Not wanting to do this by hand every time I install a Linux machine, I'm looking for some kind of automation tool for the purpose. I've looked at things like Salt, Ansible, FAI and such, but they're really complicated - plus they're more intended for mass-administration of hundreds of machines.

I need a way to define a set of templates, put them on a flash drive, and execute them on the target machine.

I was planning to write a program for the purpose, but this plan is fraught with problems. So, I'm hoping to find an existing solution to the problem, that someone else has already created.

(The only programming language guaranteed to work on any system is bash. But bash is horrible to work in.)

Sod Almighty

Posted 2016-12-05T00:54:01.893

Reputation: 462

Answers

2

The answer depends on the distro selected. For example, Debian (and derivatives like Ubuntu, Mint, etc.) accept a seedfile while can be loaded during the install for a fully automated procedure. It is quite often used in tandem with a pxe server for network installations.

Here is an Ubuntu reference:
Q: How do I create a completely unattended install of Ubuntu?
A: https://askubuntu.com/questions/122505/how-do-i-create-a-completely-unattended-install-of-ubuntu

Mark

Posted 2016-12-05T00:54:01.893

Reputation: 211

The solution should be distro-agnostic. Presumably the templates would need to account for things like systemd-based distros being different from init.d-based distros, but still. Besides, the partitioning phase of the installation should still be performed by the user, so a totally unattended installation is not desired. – Sod Almighty – 2016-12-05T01:38:45.110

1completely distro agnostic is tricky. kickstart files are the 'right' way to do this but even that's not distro agnostic. – Journeyman Geek – 2016-12-05T02:06:00.310

Well, more mostly distro-agnostic, rather than completely. But the solution should probably be something I run after the initial Linux installation is completed; rather than some kind of unattended OS installation. – Sod Almighty – 2016-12-05T04:44:42.677

-1

If you can assume that the programs are present in the default upstream repos for your distributions, you could write some sort of a little shell script. (The below can be considered pseudo-code as I've not tested it.)

#!/bin/bash
packages_to_install="curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel"
release=`cat /etc/*-release`
case $release in
  redhat|centos) cmd="yum install"; ;;
  ubuntu|debian) cmd="apt-get install"; ;;
esac
for pkg in $packages_to_install; do
  sudo $cmd $pkg
done

I don't really love this solution, but based on your comments about ansible/salt being too complicated for you and a good Debian solution not being distro-agnostic, I think this is all you're left with.

Mort

Posted 2016-12-05T00:54:01.893

Reputation: 124

I dislike bash intensely. Plus I would need error-correction, logging, a progress indicator et al. In other words, a program several hundred lines long. In bash. No thank you. – Sod Almighty – 2016-12-05T04:46:35.910

If I limited the scope of the problem to Debian-based distros, would there be "a good Debian solution"? – Sod Almighty – 2016-12-05T04:47:05.850

If you are managing linux systems, you have to know a shell script. Period. I don't think I can help you further. – Mort – 2016-12-05T16:45:44.177

I never said I didn't know bash. I said I didn't like bash. – Sod Almighty – 2016-12-05T23:38:27.677