Skip to content

Commit

Permalink
Fix order parameter contains invalid characters error
Browse files Browse the repository at this point in the history
  • Loading branch information
arioch committed May 28, 2015
1 parent 5e32b78 commit 5720e4a
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 14 deletions.
6 changes: 4 additions & 2 deletions manifests/lvs/real_server.pp
Expand Up @@ -36,15 +36,17 @@
$port,
$options = {},
) {
$_name = regsubst($name, '[:\/\n]', '')

if ( ! is_ip_address($ip_address) ) {
fail('Invalid IP address')
}

validate_re($port, '^[0-9]{1,5}$', "Invalid port: ${port}")

concat::fragment { "keepalived.conf_lvs_real_server_${name}":
concat::fragment { "keepalived.conf_lvs_real_server_${_name}":
target => "${::keepalived::config_dir}/keepalived.conf",
content => template('keepalived/lvs_real_server.erb'),
order => "250-${virtual_server}-${name}",
order => "250-${virtual_server}-${_name}",
}
}
11 changes: 6 additions & 5 deletions manifests/lvs/virtual_server.pp
Expand Up @@ -95,6 +95,7 @@
$tcp_check = undef,
$virtualhost = undef,
) {
$_name = regsubst($name, '[:\/\n]', '')

if ( ! is_ip_address($ip_address) ) {
fail('Invalid IP address')
Expand Down Expand Up @@ -142,19 +143,19 @@
)
}

concat::fragment { "keepalived.conf_lvs_virtual_server_${name}":
concat::fragment { "keepalived.conf_lvs_virtual_server_${_name}":
target => "${::keepalived::config_dir}/keepalived.conf",
content => template('keepalived/lvs_virtual_server.erb'),
order => "250-${name}-000",
order => "250-${_name}-000",
}

concat::fragment { "keepalived.conf_lvs_virtual_server_${name}-footer":
concat::fragment { "keepalived.conf_lvs_virtual_server_${_name}-footer":
target => "${::keepalived::config_dir}/keepalived.conf",
content => "}\n",
order => "250-${name}",
order => "250-${_name}",
}

if $collect_exported {
Keepalived::Lvs::Real_server <<| virtual_server == $name |>>
Keepalived::Lvs::Real_server <<| virtual_server == $_name |>>
}
}
4 changes: 3 additions & 1 deletion manifests/vrrp/instance.pp
Expand Up @@ -166,14 +166,16 @@
$dont_track_primary = false,

) {
$_name = regsubst($name, '[:\/\n]', '')

if (!is_integer($priority) or $priority < 1 or $priority > 254) {
fail('priority must be an integer 1 >= and <= 254')
}
if (!is_integer($virtual_router_id) or $virtual_router_id < 1 or $virtual_router_id > 255) {
fail('virtual_router_id must be an integer >= 1 and <= 255')
}

concat::fragment { "keepalived.conf_vrrp_instance_${name}":
concat::fragment { "keepalived.conf_vrrp_instance_${_name}":
ensure => $ensure,
target => "${::keepalived::config_dir}/keepalived.conf",
content => template('keepalived/vrrp_instance.erb'),
Expand Down
4 changes: 3 additions & 1 deletion manifests/vrrp/script.pp
Expand Up @@ -27,6 +27,8 @@
$rise = undef,
$no_weight = false,
) {
$_name = regsubst($name, '[:\/\n]', '')

if ! $script {
fail 'No script provided.'
}
Expand All @@ -39,7 +41,7 @@
}
}

concat::fragment { "keepalived.conf_vrrp_script_${name}":
concat::fragment { "keepalived.conf_vrrp_script_${_name}":
target => "${::keepalived::config_dir}/keepalived.conf",
content => template('keepalived/vrrp_script.erb'),
order => '002',
Expand Down
4 changes: 3 additions & 1 deletion manifests/vrrp/sync_group.pp
Expand Up @@ -32,7 +32,9 @@
$smtp_alert = undef,
$nopreempt = undef,
) {
concat::fragment { "keepalived.conf_vrrp_sync_group_${name}":
$_name = regsubst($name, '[:\/\n]', '')

concat::fragment { "keepalived.conf_vrrp_sync_group_${_name}":
ensure => $ensure,
target => "${::keepalived::config_dir}/keepalived.conf",
content => template('keepalived/vrrp_sync_group.erb'),
Expand Down
2 changes: 1 addition & 1 deletion templates/lvs_virtual_server.erb
@@ -1,4 +1,4 @@
group <%= name %> {
group <%= @_name %> {

virtual_server <%= @ip_address %> <%= port %>
Expand Down
2 changes: 1 addition & 1 deletion templates/vrrp_instance.erb
@@ -1,4 +1,4 @@
vrrp_instance <%= @name %> {
vrrp_instance <%= @_name %> {
interface <%= @interface %>
state <%= @state %>
virtual_router_id <%= @virtual_router_id %>
Expand Down
2 changes: 1 addition & 1 deletion templates/vrrp_script.erb
@@ -1,4 +1,4 @@
vrrp_script <%= @name %> {
vrrp_script <%= @_name %> {
script "<%= @script %>"
interval <%= @interval %>
<%- unless @no_weight -%>
Expand Down
2 changes: 1 addition & 1 deletion templates/vrrp_sync_group.erb
@@ -1,4 +1,4 @@
vrrp_sync_group <%= @name %> {
vrrp_sync_group <%= @_name %> {
group {
<%- Array(@group).each do |vrrp_instance| -%>
<%= vrrp_instance %>
Expand Down

0 comments on commit 5720e4a

Please sign in to comment.