Skip to content

Commit e478fa7

Browse files
author
Tom Krouper
committed
Initial copy from puppet
Made changes that make module not GitHub specific.
1 parent 11390ac commit e478fa7

File tree

10 files changed

+272
-0
lines changed

10 files changed

+272
-0
lines changed

files/etc/logrotate.d/orchestrator

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/var/log/orchestrator.log {
2+
daily
3+
rotate 7
4+
missingok
5+
ifempty
6+
compress
7+
nodelaycompress
8+
copytruncate
9+
}

files/etc/orchestrator_profile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Managed by puppet: do not edit directly!
2+
#
3+
# Add profile specific information needed for orchestrator

manifests/config.pp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
3+
class orchestrator::config inherits orchestrator {
4+
5+
# Create a merged together set of options. Rightmost hashes win over left. Requires stdlib
6+
$options = merge($orchestrator::config_defaults, $orchestrator::config_override)
7+
8+
file { $orchestrator::config:
9+
ensure => file,
10+
owner => 0,
11+
group => 0,
12+
mode => '0644',
13+
content => template($orchestrator::config_template),
14+
}
15+
16+
}

manifests/init.pp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# MySQL orchestrator: For managing replication and failover.
3+
#
4+
class orchestrator (
5+
$config = $orchestrator::params::config,
6+
$config_defaults = $orchestrator::params::config_defaults,
7+
$config_override = {},
8+
$config_template = $orchestrator::params::config_template,
9+
$package_ensure = $orchestrator::params::package_ensure,
10+
$package_manage = $orchestrator::params::package_manage,
11+
$package_name = $orchestrator::params::package_name,
12+
$service_enable = $orchestrator::params::service_enable,
13+
$service_ensure = $orchestrator::params::service_ensure,
14+
$service_manage = $orchestrator::params::service_manage,
15+
$service_name = $orchestrator::params::service_name,
16+
) inherits orchestrator::params {
17+
18+
validate_absolute_path($config)
19+
validate_string($config_template)
20+
validate_string($package_ensure)
21+
validate_bool($package_manage)
22+
validate_array($package_name)
23+
validate_bool($service_enable)
24+
validate_string($service_ensure)
25+
validate_bool($service_manage)
26+
validate_string($service_name)
27+
28+
# Concept pulled from: https://github.com/puppetlabs/puppetlabs-ntp/blob/master/manifests/init.pp#L98
29+
#
30+
# Anchor this as per #8040 - this ensures that classes won't float off and
31+
# mess everything up. You can read about this at:
32+
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
33+
anchor { 'orchestrator::begin': } ->
34+
class { '::orchestrator::install': } ->
35+
class { '::orchestrator::config': } ~>
36+
class { '::orchestrator::my_cnf': } ~>
37+
class { '::orchestrator::service': } ->
38+
anchor { 'orchestrator::end': }
39+
40+
}

manifests/install.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
class orchestrator::install inherits orchestrator {
3+
4+
if $orchestrator::package_manage {
5+
6+
package { $orchestrator::package_name:
7+
ensure => $orchestrator::package_ensure,
8+
}
9+
10+
}
11+
12+
}

manifests/my_cnf.pp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
class orchestrator::my_cnf inherits orchestrator {
3+
4+
file { $orchestrator::topology_cnf:
5+
content => template("puppet-orchestrator-for-mysql/${orchestrator::topology_cnf}.erb"),
6+
mode => '0644',
7+
}
8+
file { $orchestrator::srv_cnf:
9+
content => template("puppet-orchestrator-for-mysql/${orchestrator::srv_cnf}.erb"),
10+
mode => '0644',
11+
}
12+
}

manifests/params.pp

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#
2+
class orchestrator::params {
3+
4+
$config = '/etc/orchestrator.conf.json'
5+
$config_template = 'orchestrator/orchestrator.conf.json.erb'
6+
$package_ensure = 'present'
7+
$package_manage = true
8+
$package_name = [ 'orchestrator' ]
9+
$service_enable = true
10+
$service_ensure = 'running'
11+
$service_manage = true
12+
$service_name = 'orchestrator'
13+
$srv_cnf = '/etc/mysql/orchestrator_srv.cnf'
14+
$topology_cnf = '/etc/mysql/orchestrator.cnf'
15+
16+
$config_defaults = {
17+
'Debug' => true,
18+
'EnableSyslog' => false,
19+
'ListenAddress' => ':3000',
20+
'AgentsServerPort' => ':3001',
21+
'MySQLTopologyCredentialsConfigFile' => $topology_cnf,
22+
'MySQLTopologySSLPrivateKeyFile' => '',
23+
'MySQLTopologySSLCertFile' => '',
24+
'MySQLTopologySSLCAFile' => '',
25+
'MySQLTopologySSLSkipVerify' => true,
26+
'MySQLTopologyUseMutualTLS' => false,
27+
'MySQLTopologyMaxPoolConnections' => 3,
28+
'DatabaselessMode__experimental' => false,
29+
'MySQLOrchestratorHost' => 'myorchestrator.backend.master.mcompany.com',
30+
'MySQLOrchestratorPort' => 3306,
31+
'MySQLOrchestratorDatabase' => 'orchestrator',
32+
'MySQLOrchestratorCredentialsConfigFile' => $srv_cnf,
33+
'MySQLOrchestratorSSLPrivateKeyFile' => '',
34+
'MySQLOrchestratorSSLCertFile' => '',
35+
'MySQLOrchestratorSSLCAFile' => '',
36+
'MySQLOrchestratorSSLSkipVerify' => true,
37+
'MySQLOrchestratorUseMutualTLS' => false,
38+
'MySQLConnectTimeoutSeconds' => 1,
39+
'DefaultInstancePort' => 3306,
40+
'SlaveLagQuery' => '',
41+
'SlaveStartPostWaitMilliseconds' => 1000,
42+
'DiscoverByShowSlaveHosts' => true,
43+
'InstancePollSeconds' => 5,
44+
'ReadLongRunningQueries' => false,
45+
'BinlogFileHistoryDays' => 10,
46+
'UnseenInstanceForgetHours' => 240,
47+
'SnapshotTopologiesIntervalHours' => 0,
48+
'InstanceBulkOperationsWaitTimeoutSeconds' => 10,
49+
'ActiveNodeExpireSeconds' => 5,
50+
'HostnameResolveMethod' => 'default',
51+
'MySQLHostnameResolveMethod' => '@@hostname',
52+
'SkipBinlogServerUnresolveCheck' => true,
53+
'ExpiryHostnameResolvesMinutes' => 60,
54+
'RejectHostnameResolvePattern' => '',
55+
'ReasonableReplicationLagSeconds' => 10,
56+
'ProblemIgnoreHostnameFilters' => [],
57+
'VerifyReplicationFilters' => false,
58+
'MaintenanceOwner' => 'orchestrator',
59+
'ReasonableMaintenanceReplicationLagSeconds' => 20,
60+
'MaintenanceExpireMinutes' => 10,
61+
'MaintenancePurgeDays' => 365,
62+
'CandidateInstanceExpireMinutes' => 60,
63+
'AuditLogFile' => '/var/log/orchestrator-audit.log',
64+
'AuditToSyslog' => false,
65+
'AuditPageSize' => 20,
66+
'AuditPurgeDays' => 365,
67+
'RemoveTextFromHostnameDisplay' => '.mycompany.com:3306',
68+
'ReadOnly' => false,
69+
'AuthenticationMethod' => '',
70+
'HTTPAuthUser' => '',
71+
'HTTPAuthPassword' => '',
72+
'AuthUserHeader' => '',
73+
'PowerAuthUsers' => ['*'],
74+
'ClusterNameToAlias' => {
75+
'127.0.0.1' => 'test suite'
76+
},
77+
'AccessTokenUseExpirySeconds' => 60,
78+
'AccessTokenExpiryMinutes' => 1440,
79+
'DetectClusterAliasQuery' => '',
80+
'DetectClusterDomainQuery' => '',
81+
'DataCenterPattern' => '',
82+
'PhysicalEnvironmentPattern' => '',
83+
'PromotionIgnoreHostnameFilters' => [],
84+
'ServeAgentsHttp' => false,
85+
'AgentsUseSSL' => false,
86+
'AgentsUseMutualTLS' => false,
87+
'AgentSSLSkipVerify' => false,
88+
'AgentSSLPrivateKeyFile' => '',
89+
'AgentSSLCertFile' => '',
90+
'AgentSSLCAFile' => '',
91+
'AgentSSLValidOUs' => [],
92+
'UseSSL' => false,
93+
'UseMutualTLS' => false,
94+
'SSLSkipVerify' => false,
95+
'SSLPrivateKeyFile' => '',
96+
'SSLCertFile' => '',
97+
'SSLCAFile' => '',
98+
'SSLValidOUs' => [],
99+
'StatusEndpoint' => '/api/status',
100+
'StatusSimpleHealth' => true,
101+
'StatusOUVerify' => false,
102+
'HttpTimeoutSeconds' => 60,
103+
'AgentPollMinutes' => 60,
104+
'AgentAutoDiscover' => false,
105+
'UnseenAgentForgetHours' => 6,
106+
'StaleSeedFailMinutes' => 60,
107+
'SeedAcceptableBytesDiff' => 8192,
108+
'PseudoGTIDPattern' => '`heartbeat` [(]ts, server_id, file, position, relay_master_log_file, exec_master_log_pos[)] VALUES',
109+
'PseudoGTIDPatternIsFixedSubstring' => false,
110+
'PseudoGTIDMonotonicHint' => 'heartbeat',
111+
'DetectPseudoGTIDQuery' => 'select count(*)>0 as pseudo_gtid_exists from github_meta.heartbeat where ts > NOW() - INTERVAL 2 DAY;',
112+
'BinlogEventsChunkSize' => 10000,
113+
'BufferBinlogEvents' => true,
114+
'SkipBinlogEventsContaining' => [],
115+
'ReduceReplicationAnalysisCount' => false,
116+
'FailureDetectionPeriodBlockMinutes' => 60,
117+
'RecoveryPollSeconds' => 5,
118+
'RecoveryPeriodBlockSeconds' => 600,
119+
'RecoveryIgnoreHostnameFilters' => [],
120+
'RecoverMasterClusterFilters' => [
121+
'_master_pattern_'
122+
],
123+
'RecoverIntermediateMasterClusterFilters' => [
124+
'_intermediate_master_pattern_'
125+
],
126+
'OnFailureDetectionProcesses' => [
127+
"echo 'Detected {failureType} on {failureCluster}. Affected replicas: {countSlaves}' >> /tmp/recovery.log"
128+
],
129+
'PreFailoverProcesses' => [
130+
"echo 'Will recover from {failureType} on {failureCluster}' >> /tmp/recovery.log"
131+
],
132+
'PostFailoverProcesses' => [
133+
"echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
134+
],
135+
'PostUnsuccessfulFailoverProcesses' => [],
136+
'PostMasterFailoverProcesses' => [
137+
"echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Promoted: {successorHost}:{successorPort}' >> /tmp/recovery.log"
138+
],
139+
'PostIntermediateMasterFailoverProcesses' => [
140+
"echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
141+
],
142+
'CoMasterRecoveryMustPromoteOtherCoMaster' => true,
143+
'DetachLostSlavesAfterMasterFailover' => true,
144+
'ApplyMySQLPromotionAfterMasterFailover' => false,
145+
'MasterFailoverLostInstancesDowntimeMinutes' => 60,
146+
'PostponeSlaveRecoveryOnLagMinutes' => 10,
147+
'OSCIgnoreHostnameFilters' => [],
148+
'GraphitePollSeconds' => 60,
149+
'GraphiteAddr' => '',
150+
'GraphitePath' => '',
151+
'GraphiteConvertHostnameDotsToUnderscores' => true,
152+
}
153+
}

manifests/service.pp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
class orchestrator::service inherits orchestrator {
3+
4+
if ! ($orchestrator::service_ensure in [ 'running', 'stopped' ]) {
5+
fail('service_ensure parameter must be running or stopped')
6+
}
7+
8+
if $orchestrator::service_manage == true {
9+
10+
service { 'orchestrator':
11+
ensure => $orchestrator::service_ensure,
12+
enable => $orchestrator::service_enable,
13+
hasrestart => true,
14+
hasstatus => true,
15+
name => $orchestrator::service_name,
16+
subscribe => File[$orchestrator::config],
17+
}
18+
19+
}
20+
21+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[client]
2+
user=<%= @user %>
3+
password=%<%= @password %>%
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<%
2+
require 'json'
3+
%><%= JSON.pretty_generate(@options).gsub(/"([0-9]+)",$/, '\1,').gsub(/[:] "([0-9]+)"$/, ': \1') %>

0 commit comments

Comments
 (0)