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:
parent
f150d93161
commit
39ffd4a33b
@ -54,3 +54,29 @@
|
|||||||
- name: Set keyboard layout to Turkish Q
|
- name: Set keyboard layout to Turkish Q
|
||||||
ansible.builtin.command: localectl set-keymap trq
|
ansible.builtin.command: localectl set-keymap trq
|
||||||
when: "'trq' not in localectl_status.stdout"
|
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
|
||||||
|
|||||||
2
ansible/test/host_vars/iklim-app-01/vars.yml
Normal file
2
ansible/test/host_vars/iklim-app-01/vars.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
hetzner_floating_ip: "49.12.116.113"
|
||||||
|
hetzner_primary_interface: "eth0"
|
||||||
Loading…
x
Reference in New Issue
Block a user