/ansible-hetzner-dev-bootstrap

Ansible role to bootstrap the installed system on a Hetzner dedicated servers with Storage Box, vSwitch and Failover support.

Primary LanguageHTMLMIT LicenseMIT

Hetzner Robot Server Boostrap Ansible Role


Build Status Ansible Galaxy Ansible Quality Score MIT License

Ansible role to bootstrap the installed system on a Hetzner dedicated servers with Storage Box, vSwitch and Failover support.

Introduction

This role is useful during my lessons specifically for practicing on the Hetzner servers. There are also 2 other useful roles: hetzner_install_image and install_python .

Ansible

This role was tested against Ansible version 2.8 2.9 2.10 . The supported platforms are

  • Debian
    • buster
    • stretch
  • Ubuntu
    • focal
    • bionic
    • xenial
  • Centos
    • 8

Variables

Vswitch configuration example

group_vars:
  all:
    vswitch: true # enable vswitch networking
    vswitch_id: 14567 # vwitch id
    robotws:
      user: hetzuser # webservice user
      password: hetzpass # webservice pass

host_vars:
  target1:
    vswitch_ip: 10.0.0.11
  target2:
    vswitch_ip: 10.0.0.12

By default the ansible user will be created

group_vars:
  all:
    admin_user:
      name: ansible
      group: wheel
      authorized_key_file: "{{ lookup('env','HOME') + '/.ssh/id_rsa.pub' }}"
      sudo: true

If you have a storagebox, mount it with

group_vars:
  all:
    davfs2_mounts:
      - name: u12345.your-storagebox.de
        fstype: davfs
        src: https://u12345.your-storagebox.de
        path: /mnt/storagebox
        user: u12345
        password: u12345password

Testing

Molecule with vagrant are being used. Since this project will configure the ssh daemon and networking, docker can't be supported.

Requirements for testing:

# install qemu/libvirt and bridge-utils needed for virtualization
sudo apt-get update && sudo apt-get install -y bridge-utils dnsmasq-base ebtables libvirt-bin libvirt-dev qemu-kvm qemu-utils ruby-dev

# install vagrant 2.2.10
sudo wget -nv https://releases.hashicorp.com/vagrant/2.2.10/vagrant_2.2.10_x86_64.deb
sudo dpkg -i vagrant_2.2.10_x86_64.deb

# install vagrant libvirt plugin
sudo vagrant plugin install vagrant-libvirt

Running the tests:

# linting will first also fetch the requirements
pipenv run molecule lint

sudo -E pipenv run molecule create

sudo -E pipenv run molecule converge

sudo -E pipenv run molecule destroy