Skip to content

Commit

Permalink
Merge pull request #342 from dlucredativ/lvs_sync_daemon
Browse files Browse the repository at this point in the history
Add support for lvs_sync_daemon
  • Loading branch information
bastelfreak authored Jun 4, 2024
2 parents 71fcb98 + c01c3e9 commit 1c01868
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 43 deletions.
28 changes: 28 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Work in progress, supports:

### Data types

* [`Keepalived::Global_defs::Lvs_sync_daemon`](#Keepalived--Global_defs--Lvs_sync_daemon): Defines parameters for lvs_sync_daemon as documented in `man 5 keepalived.conf`
* [`Keepalived::Options`](#Keepalived--Options): keepalived::options
* [`Keepalived::Vrrp::Instance::VRule`](#Keepalived--Vrrp--Instance--VRule): Translates directly to rules to be added as per `ip-rule(8)`

Expand Down Expand Up @@ -343,6 +344,7 @@ The following parameters are available in the `keepalived::global_defs` class:
* [`dynamic_interfaces`](#-keepalived--global_defs--dynamic_interfaces)
* [`vrrp_notify_fifo`](#-keepalived--global_defs--vrrp_notify_fifo)
* [`vrrp_notify_fifo_script`](#-keepalived--global_defs--vrrp_notify_fifo_script)
* [`lvs_sync_daemon`](#-keepalived--global_defs--lvs_sync_daemon)

##### <a name="-keepalived--global_defs--notification_email"></a>`notification_email`

Expand Down Expand Up @@ -688,6 +690,14 @@ Set the vrrp_notify_fifo_script option.

Default value: `undef`

##### <a name="-keepalived--global_defs--lvs_sync_daemon"></a>`lvs_sync_daemon`

Data type: `Optional[Keepalived::Global_defs::Lvs_sync_daemon]`

Set the lvs_sync_daemon option.

Default value: `undef`

### <a name="keepalived--install"></a>`keepalived::install`

Install keepalived package
Expand Down Expand Up @@ -1865,6 +1875,24 @@ Default value: `false`

## Data types

### <a name="Keepalived--Global_defs--Lvs_sync_daemon"></a>`Keepalived::Global_defs::Lvs_sync_daemon`

Defines parameters for lvs_sync_daemon as documented in `man 5 keepalived.conf`

Alias of

```puppet
Struct[{
interface => String[1],
vrrp_instance => String[1],
Optional[id] => Integer[0, 255],
Optional[maxlen] => Integer[1, 65507],
Optional[port] => Stdlib::Port,
Optional[ttl] => Integer[1, 255],
Optional[group] => Stdlib::IP::Address,
}]
```

### <a name="Keepalived--Options"></a>`Keepalived::Options`

keepalived::options
Expand Down
89 changes: 46 additions & 43 deletions manifests/global_defs.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,50 +87,53 @@
#
# @param vrrp_notify_fifo_script Set the vrrp_notify_fifo_script option.
#
# @param lvs_sync_daemon Set the lvs_sync_daemon option.
#
class keepalived::global_defs (
$notification_email = undef,
$notification_email_from = undef,
$smtp_server = undef,
$smtp_connect_timeout = undef,
$router_id = undef,
$script_user = undef,
$enable_script_security = undef,
$enable_snmp_keepalived = undef,
$enable_snmp_vrrp = undef,
$enable_snmp_checker = undef,
$enable_snmp_rfc = undef,
$enable_snmp_rfcv2 = undef,
$enable_snmp_rfcv3 = undef,
$enable_traps = undef,
Boolean $enable_dbus = false,
Optional[Boolean] $vrrp_higher_prio_send_advert = undef,
Optional[Boolean] $vrrp_min_garp = undef,
Optional[Integer] $vrrp_garp_lower_prio_repeat = undef,
Optional[Integer] $vrrp_garp_master_delay = undef,
Optional[Integer] $vrrp_garp_master_refresh = undef,
Optional[Integer] $vrrp_garp_master_repeat = undef,
Optional[Integer] $vrrp_garp_master_refresh_repeat = undef,
Optional[Integer] $vrrp_garp_lower_prio_delay = undef,
Optional[Float] $vrrp_startup_delay = undef,
Optional[Integer] $bfd_rlimit_rttime = undef,
Optional[Integer] $checker_rlimit_rttime = undef,
Optional[Integer] $vrrp_rlimit_rttime = undef,
Optional[Integer[-20, 19]] $bfd_priority = undef,
Optional[Integer[-20, 19]] $checker_priority = undef,
Optional[Integer[-20, 19]] $vrrp_priority = undef,
Optional[Integer[1, 99]] $bfd_rt_priority = undef,
Optional[Integer[1, 99]] $checker_rt_priority = undef,
Optional[Integer[1, 99]] $vrrp_rt_priority = undef,
Boolean $bfd_no_swap = false,
Boolean $checker_no_swap = false,
Boolean $vrrp_no_swap = false,
Boolean $vrrp_check_unicast_src = false,
Optional[Integer[2, 3]] $vrrp_version = undef,
Optional[Integer[-1, 99]] $max_auto_priority = undef,
Boolean $dynamic_interfaces = false,
Optional[Stdlib::Absolutepath] $vrrp_notify_fifo = undef,
Optional[Stdlib::Absolutepath] $vrrp_notify_fifo_script = undef,
$snmp_socket = 'unix:/var/agentx/master',
$notification_email = undef,
$notification_email_from = undef,
$smtp_server = undef,
$smtp_connect_timeout = undef,
$router_id = undef,
$script_user = undef,
$enable_script_security = undef,
$enable_snmp_keepalived = undef,
$enable_snmp_vrrp = undef,
$enable_snmp_checker = undef,
$enable_snmp_rfc = undef,
$enable_snmp_rfcv2 = undef,
$enable_snmp_rfcv3 = undef,
$enable_traps = undef,
Boolean $enable_dbus = false,
Optional[Boolean] $vrrp_higher_prio_send_advert = undef,
Optional[Boolean] $vrrp_min_garp = undef,
Optional[Integer] $vrrp_garp_lower_prio_repeat = undef,
Optional[Integer] $vrrp_garp_master_delay = undef,
Optional[Integer] $vrrp_garp_master_refresh = undef,
Optional[Integer] $vrrp_garp_master_repeat = undef,
Optional[Integer] $vrrp_garp_master_refresh_repeat = undef,
Optional[Integer] $vrrp_garp_lower_prio_delay = undef,
Optional[Float] $vrrp_startup_delay = undef,
Optional[Integer] $bfd_rlimit_rttime = undef,
Optional[Integer] $checker_rlimit_rttime = undef,
Optional[Integer] $vrrp_rlimit_rttime = undef,
Optional[Integer[-20, 19]] $bfd_priority = undef,
Optional[Integer[-20, 19]] $checker_priority = undef,
Optional[Integer[-20, 19]] $vrrp_priority = undef,
Optional[Integer[1, 99]] $bfd_rt_priority = undef,
Optional[Integer[1, 99]] $checker_rt_priority = undef,
Optional[Integer[1, 99]] $vrrp_rt_priority = undef,
Boolean $bfd_no_swap = false,
Boolean $checker_no_swap = false,
Boolean $vrrp_no_swap = false,
Boolean $vrrp_check_unicast_src = false,
Optional[Integer[2, 3]] $vrrp_version = undef,
Optional[Integer[-1, 99]] $max_auto_priority = undef,
Boolean $dynamic_interfaces = false,
Optional[Stdlib::Absolutepath] $vrrp_notify_fifo = undef,
Optional[Stdlib::Absolutepath] $vrrp_notify_fifo_script = undef,
$snmp_socket = 'unix:/var/agentx/master',
Optional[Keepalived::Global_defs::Lvs_sync_daemon] $lvs_sync_daemon = undef,
) {
concat::fragment { 'keepalived.conf_globaldefs':
target => "${keepalived::config_dir}/keepalived.conf",
Expand Down
41 changes: 41 additions & 0 deletions spec/classes/keepalived_global_defs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,47 @@
)
}
end

describe 'with parameter lvs_sync_daemon (minimal)' do
let(:params) do
{
lvs_sync_daemon: {
'interface' => 'eth0',
'vrrp_instance' => 'VRRP',
}
}
end

it {
is_expected.to \
contain_concat__fragment('keepalived.conf_globaldefs').with(
'content' => %r{lvs_sync_daemon eth0 VRRP$}
)
}
end

describe 'with parameter lvs_sync_daemon (full)' do
let(:params) do
{
lvs_sync_daemon: {
'interface' => 'eth0',
'vrrp_instance' => 'VRRP',
'id' => 42,
'maxlen' => 4711,
'port' => 8848,
'ttl' => 128,
'group' => '192.0.2.1',
}
}
end

it {
is_expected.to \
contain_concat__fragment('keepalived.conf_globaldefs').with(
'content' => %r{lvs_sync_daemon eth0 VRRP id 42 maxlen 4711 port 8848 ttl 128 group 192\.0\.2\.1$}
)
}
end
end
end
end
6 changes: 6 additions & 0 deletions templates/globaldefs.erb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ global_defs {
<%- if @vrrp_notify_fifo_script -%>
vrrp_notify_fifo_script <%= @vrrp_notify_fifo_script %>
<%- end -%>
<%- if @lvs_sync_daemon -%>
lvs_sync_daemon <%= @lvs_sync_daemon['interface'] %> <%= @lvs_sync_daemon['vrrp_instance'] -%>
<%- %w(id maxlen port ttl group).each do |key| -%>
<%- if @lvs_sync_daemon.has_key?(key) %> <%= key %> <%= @lvs_sync_daemon[key] -%><% end -%>
<%- end %>
<%- end -%>

}

10 changes: 10 additions & 0 deletions types/global_defs/lvs_sync_daemon.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @summary Defines parameters for lvs_sync_daemon as documented in `man 5 keepalived.conf`
type Keepalived::Global_defs::Lvs_sync_daemon = Struct[{
interface => String[1],
vrrp_instance => String[1],
Optional[id] => Integer[0, 255],
Optional[maxlen] => Integer[1, 65507],
Optional[port] => Stdlib::Port,
Optional[ttl] => Integer[1, 255],
Optional[group] => Stdlib::IP::Address,
}]

0 comments on commit 1c01868

Please sign in to comment.