GithubHelp home page GithubHelp logo

githubixx / ansible-role-hetzner-floating-ip Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 0.0 24 KB

This Ansible role adds a floating IP (v4 and/or v6) to a Hetzner Cloud host. Additionally you can change the source IP to the floating IP (which may be important for mailserver).

License: GNU General Public License v3.0

Shell 59.55% Jinja 40.45%
ansible ubuntu hetzner hetzner-cloud network floating-ip interface cloud linux

ansible-role-hetzner-floating-ip's Introduction

ansible-role-hetzner-floating-ip

This Ansible role adds a floating IP (v4 and/or v6) to a Hetzner Cloud host. Additionally you can change the source IP to the floating IP.

Versions

I tag every release and try to stay with semantic versioning. If you want to use the role I recommend to checkout the latest tag. The master branch is basically development while the tags mark stable releases. But in general I try to keep master in good shape too.

Requirements

A Hetzner Cloud VM and a floating IP

Changelog

see CHANGELOG.md

Installation

  • Directly download from Github (Change into Ansible roles directory before cloning. You can figure out the role path by using ansible-config dump | grep DEFAULT_ROLES_PATH command): git clone https://github.com/githubixx/ansible-role-hetzner-floating-ip.git githubixx.hetzner_floating_ip

  • Via ansible-galaxy command and download directly from Ansible Galaxy: ansible-galaxy install role githubixx.hetzner_floating_ip

  • Create a requirements.yml file with the following content (this will download the role from Github) and install with ansible-galaxy role install -r requirements.yml (change version if needed):

---
roles:
  - name: githubixx.hetzner_floating_ip
    src: https://github.com/githubixx/ansible-role-hetzner-floating-ip.git
    version: 4.0.0

Role Variables

These variables can be defined in group_vars or host_vars:

# Filename that contains the floating v4 IP configuration in
# "/etc/network/interfaces.d/". ".cfg" suffix will be appended
# automatically.
hetzner_floating_ipv4_filename: "99-floating-ipv4"

# Filename that contains the floating v6 IP configuration in
# "/etc/network/interfaces.d/". ".cfg" suffix will be appended
# automatically.
hetzner_floating_ipv6_filename: "99-floating-ipv6"

Just adding the variables above isn't enough. If you just define this variables nothing will be deployed. Additionally you need to set a few variables per host in host_vars. E.g. to add a IPv4 floating IP and use this floating IP as source IP you can add this variable and settings:

hetzner_floating_ipv4_options:
  - { option: "method",  value: "static" }
  - { option: "address", value: "12.23.34.45" }
  - { option: "netmask", value: "32" }
  - { option: "post-up", value: "ip route del default; ip route add default dev eth0 via 172.31.1.1 src 12.23.34.45" }

Using the examples above a file called /etc/netplan/99-floating-ipv4.yaml will be created with this content:

network:
  version: 2
  ethernets:
    eth0:
      addresses:
      - 12.23.34.45/32

{ option: "method", value: "static" } has no effect in this case. And the post-up hook will be located in /etc/network/if-post-up.d/99-floating-ipv4:

#!/bin/sh

ip route del default; ip route add default dev eth0 via 172.31.1.1 src 12.23.34.45

Here is a example for a IPv6 interface:

hetzner_floating_ipv6_options:
  - { option: "method",  value: "static" }
  - { option: "address", value: "2a01:4f8:1111:1111::1" }
  - { option: "netmask", value: "64" }

The resulting files will be located at /etc/netplan/99-floating-ipv6.yaml and /etc/network/if-post-up.d/99-floating-ipv6.

Example Playbook

- hosts: floating-ip-hosts
  roles:
    - githubixx.hetzner_floating_ip

License

GNU GENERAL PUBLIC LICENSE Version 3

Author Information

http://www.tauceti.blog

ansible-role-hetzner-floating-ip's People

Contributors

githubixx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.