Skip to content

Commit

Permalink
Merge pull request #303 from frank-f/vrrp_instance_dash_handling
Browse files Browse the repository at this point in the history
Avoid messing up fragment ordering if instance name contains dashes
  • Loading branch information
bastelfreak authored Jan 19, 2024
2 parents 41e1739 + 6a05fbb commit 87b2a42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions manifests/vrrp/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@
Boolean $use_vmac_addr = false,
Boolean $native_ipv6 = false,
) {
$_name = regsubst($name, '[:\/\n]', '')
$_name = regsubst($name, '[:\/\n]', '', 'G')
$_ordersafe = regsubst($_name, '-', '', 'G')
$unicast_peer_array = [$unicast_peers].flatten
$auth_pass_unsensitive = if $auth_pass =~ Sensitive {
$auth_pass.unwrap
Expand All @@ -252,14 +253,14 @@
concat::fragment { "keepalived.conf_vrrp_instance_${_name}":
target => "${keepalived::config_dir}/keepalived.conf",
content => template('keepalived/vrrp_instance.erb'),
order => "100-${_name}-000",
order => "100-${_ordersafe}-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",
order => "100-${_ordersafe}-010",
}

if $collect_unicast_peers {
Expand Down Expand Up @@ -288,13 +289,13 @@
concat::fragment { "keepalived.conf_vrrp_instance_${_name}_upeers_footer":
target => "${keepalived::config_dir}/keepalived.conf",
content => " }\n\n",
order => "100-${_name}-030",
order => "100-${_ordersafe}-030",
}
}

concat::fragment { "keepalived.conf_vrrp_instance_${_name}_footer":
target => "${keepalived::config_dir}/keepalived.conf",
content => "}\n\n",
order => "100-${_name}-zzz",
order => "100-${_ordersafe}-zzz",
}
}
5 changes: 3 additions & 2 deletions manifests/vrrp/unicast_peer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
) {
assert_private()

$_inst = regsubst($instance, '[:\/\n]', '')
$_inst = regsubst($instance, '[:\/\n]', '', 'G')
$_ordersafe = regsubst($_inst, '-', '', 'G')

concat::fragment { "keepalived.conf_vrrp_instance_${_inst}_upeers_peer_${ip_address}":
target => "${keepalived::config_dir}/keepalived.conf",
content => " ${ip_address}\n",
order => "100-${_inst}-020",
order => "100-${_ordersafe}-020",
}
}

0 comments on commit 87b2a42

Please sign in to comment.