Skip to content

Commit

Permalink
Merge pull request #130 from dreezey/add-vip-carp-unicast
Browse files Browse the repository at this point in the history
Add VIP CARP Unicast Support
  • Loading branch information
ansibleguy authored Jan 5, 2025
2 parents 896b031 + 1c7c257 commit fccc341
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/module_utils/main/interface_vip.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Vip(BaseModule):
FIELDS_CHANGE = [
'address', 'mode', 'expand', 'bind', 'gateway', 'password', 'vhid',
'advertising_base', 'advertising_skew', 'description', 'interface',
'peer', 'peer6',
]
FIELDS_ALL = FIELDS_CHANGE
FIELDS_TRANSLATE = {
Expand Down
12 changes: 12 additions & 0 deletions plugins/modules/interface_vip.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def run_module():
description='For some interface types a gateway is required to configure an '
'IP Alias (ppp/pppoe/tun), leave this field empty for all other interface types'
),
peer=dict(
type='str', required=False,
description='Destination address to use when announcing, defaults to multicast, '
'but can be configured as unicast address when multicast can not be '
'used (for example with cloud providers)'
),
peer6=dict(
type='str', required=False,
description='Destination address to use when announcing, defaults to multicast, '
'but can be configured as unicast address when multicast can not be '
'used (for example with cloud providers)'
),
password=dict(
type='str', required=False, aliases=['pwd'],
description='VHID group password', no_log=True,
Expand Down
1 change: 1 addition & 0 deletions tests/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
loop:
- {int: 'lan', ip: '192.168.1.1/30'}
- {int: 'opt1', ip: '192.168.2.1/24'}
- {int: 'opt1', ip: '2001:db8::1/128'}

- name: Cleanup vlan interfaces
ansibleguy.opnsense.interface_vlan:
Expand Down
72 changes: 72 additions & 0 deletions tests/interface_vip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,77 @@
not opn7.changed
when: not ansible_check_mode

- name: Adding 3 - unicast peer
ansibleguy.opnsense.interface_vip:
interface: 'opt1'
address: '192.168.2.1/24'
mode: 'carp'
peer: '192.168.3.3'
vhid: 10
password: 'top_secret'
advertising_base: 2
advertising_skew: 1
bind: false
register: opn_carpuni1
failed_when: >
opn_carpuni1.failed or
not opn_carpuni1.changed
- name: Removing 3
ansibleguy.opnsense.interface_vip:
interface: 'opt1'
address: '192.168.2.1/24'
state: 'absent'
register: opn_carpuni2
failed_when: >
opn_carpuni2.failed or
not opn_carpuni2.changed
when: not ansible_check_mode

- name: Adding 4 - unicast peer6
ansibleguy.opnsense.interface_vip:
interface: 'opt1'
address: '2001:db8::1/128'
mode: 'carp'
peer6: '2001:db8::3'
vhid: 10
password: 'top_secret'
advertising_base: 2
advertising_skew: 1
bind: false
register: opn_carpuni3
failed_when: >
opn_carpuni3.failed or
not opn_carpuni3.changed
- name: Adding 4 - nothing changed
ansibleguy.opnsense.interface_vip:
interface: 'opt1'
address: '2001:db8::1/128'
mode: 'carp'
peer6: '2001:db8::3'
vhid: 10
password: 'top_secret'
advertising_base: 2
advertising_skew: 1
bind: false
register: opn_carpuni4
failed_when: >
opn_carpuni4.failed or
opn_carpuni4.changed
when: not ansible_check_mode

- name: Removing 4
ansibleguy.opnsense.interface_vip:
interface: 'opt1'
address: '2001:db8::1/128'
state: 'absent'
register: opn_carpuni4
failed_when: >
opn_carpuni4.failed or
not opn_carpuni4.changed
when: not ansible_check_mode

- name: Listing
ansibleguy.opnsense.list:
register: opn8
Expand All @@ -110,6 +181,7 @@
loop:
- {int: 'lan', ip: '192.168.1.1/30'}
- {int: 'opt1', ip: '192.168.2.1/24'}
- {int: 'opt1', ip: '2001:db8::1/128'}
when: not ansible_check_mode

- name: Listing
Expand Down

0 comments on commit fccc341

Please sign in to comment.