Switch requires for wait-for-settle into resource collectors
This makes requiring that exec optional (only if it's in the resource catalog), instead of needing that logic for the require and the variable. Also, wait-for-settle has an explicit dependency to start before any pacemaker resource, property, constraint and bundle; so there is less code repetition. Change-Id: I61f3393b88b65d29e2f2a5fdf6c2e2a112bfc9a1
This commit is contained in:
parent
d0f421d342
commit
790c37f6b5
|
@ -114,14 +114,13 @@ define pacemaker::constraint::base (
|
|||
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
Exec<| title == 'wait-for-settle' |> -> Exec<| tag == 'pacemaker_constraint' |>
|
||||
if($ensure == absent) {
|
||||
if($constraint_type == 'location') {
|
||||
$name_cleaned = regsubst($name, '(:)', '.', 'G')
|
||||
exec { "Removing location constraint ${name}":
|
||||
command => "/usr/sbin/pcs constraint location remove ${name_cleaned}",
|
||||
onlyif => "/usr/sbin/pcs constraint location show --full | grep ${name_cleaned}",
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
tag => [ 'pacemaker', 'pacemaker_constraint'],
|
||||
|
@ -130,7 +129,6 @@ define pacemaker::constraint::base (
|
|||
exec { "Removing ${constraint_type} constraint ${name}":
|
||||
command => "/usr/sbin/pcs constraint ${constraint_type} remove ${first_resource_cleaned} ${second_resource_cleaned}",
|
||||
onlyif => "/usr/sbin/pcs constraint ${constraint_type} show | grep ${first_resource_cleaned} | grep ${second_resource_cleaned}",
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
tag => [ 'pacemaker', 'pacemaker_constraint'],
|
||||
|
@ -143,7 +141,6 @@ define pacemaker::constraint::base (
|
|||
exec { "Creating colocation constraint ${name}":
|
||||
command => "/usr/sbin/pcs constraint colocation add ${first_resource_cleaned} ${second_resource_cleaned} ${score}",
|
||||
unless => "/usr/sbin/pcs constraint colocation show | grep ${first_resource_cleaned} | grep ${second_resource_cleaned} > /dev/null 2>&1",
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
tag => [ 'pacemaker', 'pacemaker_constraint'],
|
||||
|
@ -153,7 +150,6 @@ define pacemaker::constraint::base (
|
|||
exec { "Creating order constraint ${name}":
|
||||
command => "/usr/sbin/pcs constraint order ${first_action} ${first_resource_cleaned} then ${second_action} ${second_resource_cleaned} ${_constraint_params}",
|
||||
unless => "/usr/sbin/pcs constraint order show | grep ${first_resource_cleaned} | grep ${second_resource_cleaned} > /dev/null 2>&1",
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
tag => [ 'pacemaker', 'pacemaker_constraint'],
|
||||
|
@ -164,7 +160,6 @@ define pacemaker::constraint::base (
|
|||
exec { "Creating location constraint ${name}":
|
||||
command => "/usr/sbin/pcs constraint location add ${name} ${first_resource_cleaned} ${location} ${score}",
|
||||
unless => "/usr/sbin/pcs constraint location show | grep ${first_resource_cleaned} > /dev/null 2>&1",
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
tag => [ 'pacemaker', 'pacemaker_constraint'],
|
||||
|
|
|
@ -63,10 +63,6 @@ define pacemaker::constraint::colocation (
|
|||
$tries = 1,
|
||||
$try_sleep = 0,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
|
||||
pcmk_constraint {"colo-${source}-${target}":
|
||||
ensure => $ensure,
|
||||
constraint_type => colocation,
|
||||
|
@ -74,7 +70,6 @@ define pacemaker::constraint::colocation (
|
|||
location => $target,
|
||||
score => $score,
|
||||
master_slave => $master_slave,
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
}
|
||||
|
|
|
@ -58,18 +58,13 @@ define pacemaker::constraint::location (
|
|||
$tries = 1,
|
||||
$try_sleep = 0,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
pcmk_constraint {"loc-${resource}-${location}":
|
||||
ensure => $ensure,
|
||||
constraint_type => location,
|
||||
resource => $resource,
|
||||
location => $location,
|
||||
score => $score,
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,9 +71,6 @@ define pacemaker::constraint::order (
|
|||
$tries = 1,
|
||||
$try_sleep = 0,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
$first_resource_cleaned = regsubst($first_resource, '(:)', '.', 'G')
|
||||
$second_resource_cleaned = regsubst($second_resource, '(:)', '.', 'G')
|
||||
|
||||
|
@ -85,7 +82,6 @@ define pacemaker::constraint::order (
|
|||
first_action => $first_action,
|
||||
second_action => $second_action,
|
||||
constraint_params => $constraint_params,
|
||||
require => $pcmk_require,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
}
|
||||
|
|
|
@ -226,5 +226,8 @@ class pacemaker::corosync(
|
|||
command => "${::pacemaker::pcs_bin} status | grep -q 'partition with quorum' > /dev/null 2>&1",
|
||||
unless => "${::pacemaker::pcs_bin} status | grep -q 'partition with quorum' > /dev/null 2>&1",
|
||||
}
|
||||
|
||||
Exec<| title == 'wait-for-settle' |> -> Pcmk_constraint<||>
|
||||
Exec<| title == 'wait-for-settle' |> -> Pcmk_resource<||>
|
||||
Exec<| title == 'wait-for-settle' |> -> Pcmk_property<||>
|
||||
Exec<| title == 'wait-for-settle' |> -> Pcmk_bundle<||>
|
||||
}
|
||||
|
|
|
@ -71,10 +71,6 @@ define pacemaker::property (
|
|||
fail('When present, must provide value')
|
||||
}
|
||||
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
|
||||
pcmk_property { "property-${node}-${property}":
|
||||
ensure => $ensure,
|
||||
property => $property,
|
||||
|
@ -83,6 +79,5 @@ define pacemaker::property (
|
|||
force => $force,
|
||||
tries => $tries,
|
||||
try_sleep => $try_sleep,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,9 +130,6 @@ define pacemaker::resource::bundle(
|
|||
# target-dir=/var/log options=ro storage-map id=bar-storage-test
|
||||
# source-dir=/foo target-dir=/bar options=wr
|
||||
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
pcmk_bundle { $name:
|
||||
ensure => $ensure,
|
||||
image => $image,
|
||||
|
@ -148,6 +145,5 @@ define pacemaker::resource::bundle(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location_rule => $location_rule,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,9 +128,6 @@ define pacemaker::resource::filesystem(
|
|||
default => "device=${device} directory=${directory} fstype=${fstype} options=\"${fsoptions}\"",
|
||||
}
|
||||
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
pcmk_resource { $resource_id:
|
||||
ensure => $ensure,
|
||||
resource_type => 'Filesystem',
|
||||
|
@ -145,6 +142,5 @@ define pacemaker::resource::filesystem(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location_rule => $location_rule,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,9 +126,6 @@ define pacemaker::resource::ip(
|
|||
# pcs dislikes colons from IPv6 addresses. Replacing them with dots.
|
||||
$resource_name = regsubst($ip_address, '(:)', '.', 'G')
|
||||
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
pcmk_resource { "ip-${resource_name}":
|
||||
ensure => $ensure,
|
||||
resource_type => 'IPaddr2',
|
||||
|
@ -140,7 +137,6 @@ define pacemaker::resource::ip(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location_rule => $location_rule,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -110,9 +110,6 @@ define pacemaker::resource::lsb(
|
|||
$verify_on_create = false,
|
||||
$location_rule = undef,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
pcmk_resource { $name:
|
||||
ensure => $ensure,
|
||||
resource_type => "lsb:${service_name}",
|
||||
|
@ -127,6 +124,5 @@ define pacemaker::resource::lsb(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location => $location_rule,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,9 +116,6 @@ define pacemaker::resource::ocf(
|
|||
$verify_on_create = false,
|
||||
$location_rule = undef,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
pcmk_resource { $name:
|
||||
ensure => $ensure,
|
||||
resource_type => "ocf:${ocf_agent_name}",
|
||||
|
@ -134,6 +131,5 @@ define pacemaker::resource::ocf(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location_rule => $location_rule,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,10 +96,6 @@ define pacemaker::resource::remote(
|
|||
$verify_on_create = false,
|
||||
$location_rule = undef,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
|
||||
pcmk_resource { $name:
|
||||
ensure => $ensure,
|
||||
resource_type => 'remote',
|
||||
|
@ -113,6 +109,5 @@ define pacemaker::resource::remote(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location_rule => $location_rule,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,9 +130,6 @@ define pacemaker::resource::route(
|
|||
default => " gateway=${gateway}"
|
||||
}
|
||||
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
pcmk_resource { "route-${name}":
|
||||
ensure => $ensure,
|
||||
resource_type => 'Route',
|
||||
|
@ -145,7 +142,6 @@ define pacemaker::resource::route(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location_rule => $location_rule,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -112,9 +112,6 @@ define pacemaker::resource::service(
|
|||
) {
|
||||
include ::pacemaker::params
|
||||
$res = "pacemaker::resource::${::pacemaker::params::services_manager}"
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
|
||||
create_resources($res,
|
||||
{ "${name}" => {
|
||||
|
@ -131,10 +128,6 @@ define pacemaker::resource::service(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location_rule => $location_rule,
|
||||
# https://github.com/voxpupuli/puppet-lint-absolute_classname-check/issues/9
|
||||
# lint:ignore:relative_classname_inclusion
|
||||
require => $pcmk_require,
|
||||
# lint:endignore
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -110,9 +110,6 @@ define pacemaker::resource::systemd(
|
|||
$verify_on_create = false,
|
||||
$location_rule = undef,
|
||||
) {
|
||||
# We do not want to require Exec['wait-for-settle'] when we run this
|
||||
# from a pacemaker remote node
|
||||
$pcmk_require = str2bool($::pcmk_is_remote) ? { true => [], false => Exec['wait-for-settle'] }
|
||||
pcmk_resource { $name:
|
||||
ensure => $ensure,
|
||||
resource_type => "systemd:${service_name}",
|
||||
|
@ -127,6 +124,5 @@ define pacemaker::resource::systemd(
|
|||
try_sleep => $try_sleep,
|
||||
verify_on_create => $verify_on_create,
|
||||
location_rule => $location_rule,
|
||||
require => $pcmk_require,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue