Deploy a Hetzner server in under three minutes

In the process of automation for my private server infrastructure I came along the task to install the base operating system with as less user interaction as possible. As I primary use Hetzner servers for my infrastructure I found an easy way to do this. When you have a Hetzner server you can boot your server into a rescue life system. There you can do all kinds of administration to fix your system or you can install a complete new one. There is a script called installimage in the rescue system which can be used to install different operating systems. Usually the script opens an editor where you configure your server and then it bootstraps your system. But as manual configuration really sucks in an automated environment I decided to write an ansible playbook to do this for me.

With this playbook it takes under three minutes to complete a Debian Jessie installation:

$ time ansible-playbook deploy_debian_hetzner.yml -e 'target_host=server.example.com'
PLAY [server.example.com] *************************************************

TASK [setup] *******************************************************************
ok: [server.example.com]

TASK [copy ssh key] ************************************************************
changed: [server.example.com]

TASK [run installimage] ********************************************************
changed: [server.example.com]

TASK [remove dummy lv] *********************************************************
changed: [server.example.com]

TASK [mount root file system] **************************************************
changed: [server.example.com]

TASK [remove dummy lv mount] ***************************************************
changed: [server.example.com]

TASK [unmount root file system] ************************************************
ok: [server.example.com]

TASK [reboot host] *************************************************************
changed: [server.example.com]

TASK [wait for host to be up again] ********************************************
ok: [server.example.com -> localhost]

PLAY RECAP *********************************************************************
server.example.com    : ok=9    changed=6    unreachable=0    failed=0   


real	2m51.937s
user	0m17.600s
sys	0m3.130s

You can find the full playbook and detailed instructions at GitHub. If you extend the playbook for more use cases feel free to open a pull request.

Über Max Rosin

Fotograf, Informatikstudent und Blogger. Mehr zu mir, gibt es hier
Dieser Beitrag wurde unter Tech abgelegt und mit , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.