Skip to content

Commit

Permalink
Improve keepalived-install-example.yml
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Eamixs and evrardjp authored Feb 27, 2023
1 parent baf17b0 commit 07b46e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/keepalived-install-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
# -
keepalived_instances:
internal:
interface: "{{ vrrp_nic | default('eth0') }}"
interface: "{{ vrrp_nic | default(ansible_default_ipv4.interface, true) }}"
# You can also use your own variable to determine which node is master and who
state: "{{ (groups['keepalived'].index(inventory_hostname) == 0) | ternary('MASTER','BACKUP') }}"
virtual_router_id: 42
# I advise you to define your own priority per node, instead of a generic all or nothing.
# Especially if you have more than two nodes.
priority: "{{ inventory_hostname == groups['keepalived'][0] | ternary('250', '0') }}"
priority: "{{ (inventory_hostname == groups['keepalived'][0]) | ternary('250', '100') }}"
# Do not forget to define the VIPs, and their CIDR.
vips:
- "192.168.33.2/24 dev {{ vrrp_nic | default('eth0') }}"
- "192.168.33.2/24 dev {{ vrrp_nic | default(ansible_default_ipv4.interface, true) }}"
tasks:
- name: Include ansible-keepalived
ansible.builtin.include_role:
Expand Down

0 comments on commit 07b46e0

Please sign in to comment.