feat(ansible/base): configure Hetzner floating IP via systemd service

Add hetzner-floating-ip.service systemd unit to base role so that
the floating IP is bound to eth0 on every boot. The task is
conditional (runs only when hetzner_floating_ip is defined in
host_vars). Add 49.12.116.113 as the floating IP for iklim-app-01
in test host_vars.
This commit is contained in:
Murat ÖZDEMİR 2026-05-14 14:03:06 +03:00
parent f150d93161
commit 39ffd4a33b
2 changed files with 28 additions and 0 deletions

View File

@ -54,3 +54,29 @@
- name: Set keyboard layout to Turkish Q
ansible.builtin.command: localectl set-keymap trq
when: "'trq' not in localectl_status.stdout"
- name: Deploy Hetzner floating IP systemd service
ansible.builtin.copy:
dest: /etc/systemd/system/hetzner-floating-ip.service
mode: "0644"
content: |
[Unit]
Description=Hetzner Floating IP
After=network.target
[Service]
Type=oneshot
ExecStart=/sbin/ip addr replace {{ hetzner_floating_ip }}/32 dev {{ hetzner_primary_interface | default('eth0') }}
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
when: hetzner_floating_ip is defined
- name: Enable and start Hetzner floating IP service
ansible.builtin.systemd:
name: hetzner-floating-ip
enabled: yes
state: started
daemon_reload: yes
when: hetzner_floating_ip is defined

View File

@ -0,0 +1,2 @@
hetzner_floating_ip: "49.12.116.113"
hetzner_primary_interface: "eth0"