nl2go.hetzner_installimage
Ansible Role: Hetzner Installimage
This Ansible Role helps you manage the operating system installation on Hetzner servers using the Hetzner Robot API.
Prerequisites
- You need an account with Hetzner Online GmbH.
- Your Hetzner Robot Webservice Account should be set up.
- Add your SSH public key in Hetzner Robot Key Management.
Requirements
Name | Type | Version | Location |
---|---|---|---|
ansible-filter | Python package | 1.0.1 | Control node |
Configuration Variables
You can set the following variables in 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
Role Variables
Use these default variables in your group_vars/host_vars
, but you can change them:
hetzner_installimage_install_bootloader: grub
hetzner_installimage_install_hostname: your-server-name-here
hetzner_installimage_install_partitions:
- PART swap swap 32G
- PART /boot ext4 1G
- PART / ext4 all
hetzner_installimage_install_image: Ubuntu-1604-xenial-64-minimal.tar.gz
The role can automatically detect RAID setups. It'll set up RAID1 with two disks or no RAID with one disk. You can also manually set RAID configurations:
hetzner_installimage_install_drives:
- DRIVE1 /dev/sda
- DRIVE2 /dev/sdb
hetzner_installimage_install_raid:
- SWRAID 1
- SWRAIDLEVEL 0
You must also provide the following variables for communication with the web service and to deploy the public key:
hetzner_installimage_webservice_username: username
hetzner_installimage_webservice_password: password
Optionally, set the server's hostname:
hetzner_installimage_server_name: __YOUR_SERVER_NAME__
If you specify hetzner_installimage_key_fingerprints
, only those keys will be installed during setup. If not, all existing keys will be used:
hetzner_installimage_key_fingerprints:
- 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff
After successfully running the playbook, the role creates a flag file on the server at /etc/hetzner_installimage_provisioned.flag
. If that file exists, tasks will be skipped unless you force the action by using this variable:
--extra-vars "{ hetzner_installimage_ignore_provisioned_flag: yes }"
Setting this variable to true
will skip checking for the flag file.
Example Playbook
- hosts: hetzner
gather_facts: no
roles:
- nl2go.hetzner_installimage
vars:
hetzner_installimage_webservice_username: "{{ hetzner_robot_api_user }}"
hetzner_installimage_webservice_password: "{{ hetzner_robot_api_pass }}"
hetzner_installimage_server_name: "{{ inventory_hostname }}"
Note: Run the role with gather_facts: no
, as the servers may not have SSH access set up yet.
Installation Steps
For a New Machine
- Enter Hetzner robot (robot.your-server.de).
- Order a new server.
- Choose your operating system.
- Select your provisioning key.
- Run the
hetzner_installimage
role.
For an Existing Machine
- Add your provisioning key to Hetzner robot via robot.your-server.de.
- Run the
hetzner_installimage
role.
For an Already Provisioned Machine
- Enter the machine.
- Delete
/etc/hetzner_installimage_provisioned.flag
or set it. - Run the
hetzner_installimage
role.
If you're sure about not removing data from an already running machine, you can bypass the flag check by running:
--extra-vars "{ hetzner_installimage_ignore_provisioned_flag: yes }"
Available Images
You can find OS images in /root/.oldroot/nfs/images/
inside the rescue system. Here are some available images (as of March 25, 2020):
- Archlinux-2017-64-minimal.tar.gz
- CentOS (various versions)
- Debian (various versions)
- Ubuntu (various versions)
If these images do not work, you can specify a custom image URL by using the hetzner_installimage_custom_image_url
variable.
Maintainers
License
Refer to the LICENSE.md file for details.
Author Information
This role was originally created by/forked from andrelohmann.
Provision your hetzner boxes with installimage by leveraging the Hetzner Robot Webservice https://robot.your-server.de/doc/webservice/en.html
ansible-galaxy install nl2go.hetzner_installimage