Use this role to base provision your hetzner machines with the hetzner installimage script and your public ssh key (but all automated through ansible).
This role requires you to have a server at hetzner.de and some api credentials as well as your provisioning key uploaded to the hetzner robot. Read more about that under https://wiki.hetzner.de/index.php/Robot_Webservice
Also for security reasons, the role will not reboot and install the machine, if it can't access it and check for the existance of a hostcode file. Therefor you need to have your provisioning key allready installed on the machine(s) you want to install (can be done through robot).
The following variables are suggested to be set within your ansible.cfg file
[defaults]
inventory = __YOUR_INVENTORY__
forks = 1
host_key_checking = false
private_key_file = __YOUR_HETZNER_PROVISIONING_KEY__
remote_user = root
roles_path = __PATH_TO_YOUR_GALAXY_ROLES__
[ssh_connection]
pipelining = True
scp_if_ssh = True
control_path = %(directory)s/%%h-%%r
The default set of variables defines the installimage and needs at best to be overwritten in group_vars/host_vars
hetzner_installimage_install_drives:
- DRIVE1 /dev/sda
- DRIVE2 /dev/sdb
hetzner_installimage_install_raid:
- SWRAID 1
- SWRAIDLEVEL 1
hetzner_installimage_install_bootloader: grub
hetzner_installimage_install_hostname: Debian-87-jessie-64-minimal
hetzner_installimage_install_partitions:
- PART swap swap 32G
- PART /boot ext4 1G
- PART / ext4 all
hetzner_installimage_install_image: /root/.oldroot/nfs/images/Ubuntu-1604-xenial-64-minimal.tar.gz
The following mandatory variables need to be set in group_vars/host_vars to allow communication with the webservice and deployment of the public key
hetzner_installimage_webservice_username: username
hetzner_installimage_webservice_password: password
hetzner_installimage_key_fingerprint: 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff
The following variable can be set optionally, to set the hostname within the hetzner robot
hetzner_server_name: __YOUR_SERVER_NAME__
- hosts: hetzner
roles:
- { role: andrelohmann.hetzner_installimage }
- Install a new machine
- Enter your hetzner robot (robot.your-server.de)
- Order a new server
- Select your operating system
- Select your provisioning key
- Run the hetzner_installimge role
- Install an existing machine
- Enter your hetzner robot (robot.your-server.de)
- Select the machine
- Select "Linux"
- Select your provisioning key
- Reset the machine
- Run the hetzner_installimge role
- Install an allready provisioned machine
- Enter the machine
- Delete /etc/hostcode
- Run the hetzner_installimge role
If you are sure, you will not accidentally purge a running machine, allready in use, you can directly run the role with the extra variable --extra-vars "{ hetzner_installimage_ignore_hostcode: True }". This way the role will not check the machine for an existing /etc/hostcode file but will also not prevent the machine from being purged accidentally!
The OS images are located in the folder /root/.oldroot/nfs/images/ inside the rescue system. The following images are available at 25 Oct 2019:
- Archlinux-2017-64-minimal.tar.gz
- archlinux-latest-64-minimal.tar.gz
- CentOS-610-64-minimal.tar.gz
- CentOS-76-64-minimal.tar.gz
- CoreOS-1298-64-production.bin.bz2
- Debian-101-buster-64-LAMP.tar.gz
- Debian-101-buster-64-minimal.tar.gz
- Debian-811-jessie-64-minimal.tar.gz
- Debian-911-stretch-64-minimal.tar.gz
- Ubuntu-1604-xenial-64-minimal-no-hwe.tar.gz
- Ubuntu-1604-xenial-64-minimal.tar.gz
- Ubuntu-1804-bionic-64-minimal.tar.gz
- Ubuntu-1804-bionic-64-nextcloud.tar.gz
- Ubuntu-1904-disco-64-minimal.tar.gz
MIT