Skip to content

Commit 07b46e0

Browse files
Eamixsevrardjp
andauthored
Improve keepalived-install-example.yml
The current example has a default hardcoded NIC set to eth0. This is a problem, as it might not be the default nic used in the system. This fixes it by using the one found in ansible facts. Co-authored-by: Jean-Philippe Evrard <evrardjp@users.noreply.github.com>
1 parent baf17b0 commit 07b46e0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/keepalived-install-example.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@
4444
# -
4545
keepalived_instances:
4646
internal:
47-
interface: "{{ vrrp_nic | default('eth0') }}"
47+
interface: "{{ vrrp_nic | default(ansible_default_ipv4.interface, true) }}"
4848
# You can also use your own variable to determine which node is master and who
4949
state: "{{ (groups['keepalived'].index(inventory_hostname) == 0) | ternary('MASTER','BACKUP') }}"
5050
virtual_router_id: 42
5151
# I advise you to define your own priority per node, instead of a generic all or nothing.
5252
# Especially if you have more than two nodes.
53-
priority: "{{ inventory_hostname == groups['keepalived'][0] | ternary('250', '0') }}"
53+
priority: "{{ (inventory_hostname == groups['keepalived'][0]) | ternary('250', '100') }}"
5454
# Do not forget to define the VIPs, and their CIDR.
5555
vips:
56-
- "192.168.33.2/24 dev {{ vrrp_nic | default('eth0') }}"
56+
- "192.168.33.2/24 dev {{ vrrp_nic | default(ansible_default_ipv4.interface, true) }}"
5757
tasks:
5858
- name: Include ansible-keepalived
5959
ansible.builtin.include_role:

0 commit comments

Comments
 (0)