Created
February 4, 2015 09:47
-
-
Save bodepd/f5e1213395851b18f5be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [check_type] Type of check to run, accepts http, tcp, and proc | |
# [tags] Defaults tags to use for registered services | |
# [leader] Whether the specified node is the cluster leader | |
# [dep_resources] Resources that should not be eecuted on non-leader nodes until | |
# they can connect to the leader | |
# [follower_fail] If followers have failed to find a leader | |
define rjil::leader_orchestrator( | |
$port = -1, | |
$check_type = 'tcp', | |
$tags = ['real', 'contrail'], | |
$laader = false, | |
$dep_resources = [], | |
$follower_fail = false, | |
) { | |
if $leader { | |
# tag ourselves as the cluster leader | |
$service_tags = concat($tags, ['leader']) | |
} else { | |
$service_tags = $tags | |
# Block until leader address resolves (this ensures that we should | |
# only fail at most once) | |
ensure_resource('rjil::service_blocker', "leader.${name}", {}) | |
Rjil::Service_blocker["leader.${name}"] -> $dep_resources | |
runtime_fail {"${name}_no_leader": | |
fail => $follower_fail, | |
message => "Zookeeper list should contain at least 2 entries for non-leaders, only contained ${cluster_with_self}", | |
before => $dep_resources, | |
require => Rjil::Service_blocker["leader.${name}"] | |
} | |
} | |
rjil::test::check { $name: | |
type => $check_type, | |
address => '127.0.0.1', | |
port => $port, | |
} | |
rjil::jiocloud::consul::service { $name: | |
port => $port, | |
tags => $service_tags, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment