Defined Type: keepalived::vrrp::instance

Defined in:
manifests/vrrp/instance.pp

Summary

Configure VRRP instance

Overview

Examples:

May be specified as either:
a) ip address (or array of IP addresses)
   e.g. `'10.0.0.1'`
b) a hash (or array of hashes) containing
   extra properties
   e.g. `{ 'ip' => '10.0.0.1', 'label' => 'webvip' }`
   Supported properties: dev, brd, label, scope.
May be specified as a hash (or array of hashes)
  containing extra properties
    e.g. `{ 'src' => '10.0.0.1',
            'to' => '192.168.30.0/24',
            'via' => '10.0.0.254',
            'metric' => '15' }`
Supported properties: src, to, via, dev, scope, table, metric
May be specified as a hash (or array of hashes)
   containing extra properties
   e.g. `{ 'from' => '10.0.0.1',
           'via' => '10.0.0.254',
           'lookup' => 'customroute',
           'metric' => '15' }`
   Supported properties: from, to, dev, lookup, metric
May be specified as either:
a) ip address (or array of IP addresses)
   e.g. `'10.0.0.1'`
b) a hash (or array of hashes) containing
   extra properties
e.g. `{ 'ip'=>'10.0.0.1', 'scope'=>'local' }`
Supported properties: dev, brd, label, scope.

Parameters:

  • interface (Any)

    Define which interface to listen on.

  • priority (Integer[1,254])

    Set instance priority.

  • state (Any)

    Set instance state.

  • virtual_ipaddress_int (Any) (defaults to: undef)

    Set interface for VIP to be assigned to,

  • virtual_ipaddress (Any) (defaults to: undef)

    Set floating IP address.

  • virtual_routes (Any) (defaults to: undef)

    Set floating routes.

  • virtual_rules (Optional[Array[Keepalived::Vrrp::Instance::VRule]]) (defaults to: undef)

    Set floating rules.

  • virtual_ipaddress_excluded (Any) (defaults to: undef)

    For cases with large numbers (eg 200) of IPs on the same interface. To decrease the number of packets sent in adverts, you can exclude most IPs from adverts.

  • virtual_router_id (Integer[1,255])

    Set virtual router id.

  • auth_type (Any) (defaults to: undef)

    Set authentication method.

  • auth_pass (Optional[Variant[String, Sensitive[String]]]) (defaults to: undef)

    Authentication password.

  • track_script (Any) (defaults to: undef)

    Define which script to run to track service states.

  • track_process (Optional[Array[String[1]]]) (defaults to: undef)

    Define which process trackers to run.

  • track_interface (Any) (defaults to: undef)

    Define which interface(s) to monitor. Go to FAULT state if one of these interfaces goes down. May be specified as either:

    a) interface name
    b) array of interfaces names
    
  • lvs_interface (Any) (defaults to: undef)

    Define lvs_sync_daemon_interface.

  • smtp_alert (Any) (defaults to: false)

    Send status alerts via SMTP. Requires user provided in SMTP settings in keepalived::global_defs class.

  • nopreempt (Any) (defaults to: false)

    Allows the lower priority machine to maintain the master role, when a higher priority machine comes back online. NOTE: For this to work, the initial state of this entry must be BACKUP

  • preempt_delay (Any) (defaults to: undef)

    Seconds after startup until preemption Range: 0 to 1,000 NOTE: For this to work, the initial state of this entry must be BACKUP

  • advert_int (Any) (defaults to: 1)

    The interval between VRRP packets

  • garp_master_delay (Any) (defaults to: 5)

    The delay for gratuitous ARP after transition to MASTER

  • garp_master_refresh (Any) (defaults to: undef)

    Repeat gratuitous ARP after transition to MASTER this often.

  • notify_script_master (Any) (defaults to: undef)

    Define the notify master script.

  • notify_script_backup (Any) (defaults to: undef)

    Define the notify backup script.

  • notify_script_fault (Any) (defaults to: undef)

    Define the notify fault script.

  • notify_script_stop (Any) (defaults to: undef)

    Define the notify stop script.

  • notify_script (Any) (defaults to: undef)

    Define the notify script.

  • multicast_source_ip (Any) (defaults to: undef)

    default IP for binding vrrpd is the primary IP on interface. If you want to hide the location of vrrpd, use this IP as src_addr for multicast vrrp packets.

  • notify_script_master_rx_lower_pri (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Define the notify_master_rx_lower_pri script. This is executed if a master receives an advert with priority lower than the master’s advert.

  • unicast_source_ip (Optional[Stdlib::IP::Address]) (defaults to: undef)

    default IP for binding vrrpd is the primary IP on interface. If you want to hide the location of vrrpd, use this IP as src_addr for unicast vrrp packets.

  • unicast_peers (Variant[Array[Stdlib::IP::Address], Stdlib::IP::Address]) (defaults to: [])

    Do not send VRRP adverts over VRRP multicast group. Instead send adverts to the list of ip addresses using a unicast design fashion.

    May be specified as an array with ip addresses

  • dont_track_primary (Any) (defaults to: false)

    Tells keepalived to ignore VRRP interface faults. Can be useful on setup where two routers are connected directly to each other on the interface used for VRRP. Without this feature the link down caused by one router crashing would also inspire the other router to lose (or not gain) MASTER state, since it was also tracking link status. Default: false.

  • use_vmac (Any) (defaults to: false)

    Use virtual MAC address for virtual IP addresses.

  • vmac_xmit_base (Any) (defaults to: true)

    When using virtual MAC addresses transmit and receive VRRP messaged on the underlying interface whilst ARP will happen from the the VMAC interface.

  • native_ipv6 (Boolean) (defaults to: false)

    Force instance to use IPv6 (when mixed IPv4 and IPv6 config)

  • garp_lower_prio_repeat (Optional[Integer]) (defaults to: undef)
  • higher_prio_send_advert (Optional[Boolean]) (defaults to: undef)
  • collect_unicast_peers (Boolean) (defaults to: false)


184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'manifests/vrrp/instance.pp', line 184

define keepalived::vrrp::instance (
  $interface,
  Integer[1,254] $priority,
  $state,
  Integer[1,255] $virtual_router_id,
  $virtual_ipaddress                                                      = undef,
  $auth_type                                                              = undef,
  Optional[Variant[String, Sensitive[String]]] $auth_pass                 = undef,
  $track_script                                                           = undef,
  Optional[Array[String[1]]] $track_process                               = undef,
  $track_interface                                                        = undef,
  $lvs_interface                                                          = undef,
  $virtual_ipaddress_int                                                  = undef,
  $virtual_ipaddress_excluded                                             = undef,
  $virtual_routes                                                         = undef,
  Optional[Array[Keepalived::Vrrp::Instance::VRule]] $virtual_rules       = undef,
  $smtp_alert                                                             = false,
  $nopreempt                                                              = false,
  $preempt_delay                                                          = undef,
  $advert_int                                                             = 1,
  $garp_master_delay                                                      = 5,
  $garp_master_refresh                                                    = undef,
  Optional[Integer] $garp_lower_prio_repeat                               = undef,
  Optional[Boolean] $higher_prio_send_advert                              = undef,
  Optional[Stdlib::Absolutepath] $notify_script_master_rx_lower_pri       = undef,
  $notify_script_master                                                   = undef,
  $notify_script_backup                                                   = undef,
  $notify_script_fault                                                    = undef,
  $notify_script_stop                                                     = undef,
  $notify_script                                                          = undef,
  $multicast_source_ip                                                    = undef,
  Optional[Stdlib::IP::Address] $unicast_source_ip                        = undef,
  Variant[Array[Stdlib::IP::Address], Stdlib::IP::Address] $unicast_peers = [],
  Boolean $collect_unicast_peers                                          = false,
  $dont_track_primary                                                     = false,
  $use_vmac                                                               = false,
  $vmac_xmit_base                                                         = true,
  Boolean $native_ipv6                                                    = false,
) {
  $_name = regsubst($name, '[:\/\n]', '')
  $unicast_peer_array = [$unicast_peers].flatten
  $auth_pass_unsensitive = if $auth_pass =~ Sensitive {
    $auth_pass.unwrap
  } else {
    $auth_pass
  }

  concat::fragment { "keepalived.conf_vrrp_instance_${_name}":
    target  => "${keepalived::config_dir}/keepalived.conf",
    content => template('keepalived/vrrp_instance.erb'),
    order   => "100-${_name}-000",
  }

  if size($unicast_peer_array) > 0 or $collect_unicast_peers {
    concat::fragment { "keepalived.conf_vrrp_instance_${_name}_upeers_header":
      target  => "${keepalived::config_dir}/keepalived.conf",
      content => "  unicast_peer {\n",
      order   => "100-${_name}-010",
    }

    if $collect_unicast_peers {
      if $unicast_source_ip != undef {
        $unicast_src = $unicast_source_ip
      } else {
        $unicast_src = inline_template("<%= scope.lookupvar('::ipaddress_${interface}') -%>")
      }

      @@keepalived::vrrp::unicast_peer { "${name}_${unicast_src}":
        instance   => $name,
        ip_address => $unicast_src,
      }
      Keepalived::Vrrp::Unicast_peer <<| instance == $name and title != $unicast_src |>>
    }

    if size($unicast_peer_array) > 0 {
      $unicast_peer_array.each | $_peer | {
        keepalived::vrrp::unicast_peer { "${name}_${_peer}":
          instance   => $name,
          ip_address => $_peer,
        }
      }
    }

    concat::fragment { "keepalived.conf_vrrp_instance_${_name}_upeers_footer":
      target  => "${keepalived::config_dir}/keepalived.conf",
      content => "  }\n\n",
      order   => "100-${_name}-030",
    }
  }

  concat::fragment { "keepalived.conf_vrrp_instance_${_name}_footer":
    target  => "${keepalived::config_dir}/keepalived.conf",
    content => "}\n\n",
    order   => "100-${_name}-zzz",
  }
}