Skip to content

Commit

Permalink
Initial copy from puppet
Browse files Browse the repository at this point in the history
Made changes that make module not GitHub specific.
  • Loading branch information
Tom Krouper committed Jul 22, 2016
1 parent 11390ac commit e478fa7
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 0 deletions.
9 changes: 9 additions & 0 deletions files/etc/logrotate.d/orchestrator
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/var/log/orchestrator.log {
daily
rotate 7
missingok
ifempty
compress
nodelaycompress
copytruncate
}
3 changes: 3 additions & 0 deletions files/etc/orchestrator_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Managed by puppet: do not edit directly!
#
# Add profile specific information needed for orchestrator
16 changes: 16 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#

class orchestrator::config inherits orchestrator {

# Create a merged together set of options. Rightmost hashes win over left. Requires stdlib
$options = merge($orchestrator::config_defaults, $orchestrator::config_override)

file { $orchestrator::config:
ensure => file,
owner => 0,
group => 0,
mode => '0644',
content => template($orchestrator::config_template),
}

}
40 changes: 40 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# MySQL orchestrator: For managing replication and failover.
#
class orchestrator (
$config = $orchestrator::params::config,
$config_defaults = $orchestrator::params::config_defaults,
$config_override = {},
$config_template = $orchestrator::params::config_template,
$package_ensure = $orchestrator::params::package_ensure,
$package_manage = $orchestrator::params::package_manage,
$package_name = $orchestrator::params::package_name,
$service_enable = $orchestrator::params::service_enable,
$service_ensure = $orchestrator::params::service_ensure,
$service_manage = $orchestrator::params::service_manage,
$service_name = $orchestrator::params::service_name,
) inherits orchestrator::params {

validate_absolute_path($config)
validate_string($config_template)
validate_string($package_ensure)
validate_bool($package_manage)
validate_array($package_name)
validate_bool($service_enable)
validate_string($service_ensure)
validate_bool($service_manage)
validate_string($service_name)

# Concept pulled from: https://github.com/puppetlabs/puppetlabs-ntp/blob/master/manifests/init.pp#L98
#
# Anchor this as per #8040 - this ensures that classes won't float off and
# mess everything up. You can read about this at:
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
anchor { 'orchestrator::begin': } ->
class { '::orchestrator::install': } ->
class { '::orchestrator::config': } ~>
class { '::orchestrator::my_cnf': } ~>
class { '::orchestrator::service': } ->
anchor { 'orchestrator::end': }

}
12 changes: 12 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
class orchestrator::install inherits orchestrator {

if $orchestrator::package_manage {

package { $orchestrator::package_name:
ensure => $orchestrator::package_ensure,
}

}

}
12 changes: 12 additions & 0 deletions manifests/my_cnf.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
class orchestrator::my_cnf inherits orchestrator {

file { $orchestrator::topology_cnf:
content => template("puppet-orchestrator-for-mysql/${orchestrator::topology_cnf}.erb"),
mode => '0644',
}
file { $orchestrator::srv_cnf:
content => template("puppet-orchestrator-for-mysql/${orchestrator::srv_cnf}.erb"),
mode => '0644',
}
}
153 changes: 153 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#
class orchestrator::params {

$config = '/etc/orchestrator.conf.json'
$config_template = 'orchestrator/orchestrator.conf.json.erb'
$package_ensure = 'present'
$package_manage = true
$package_name = [ 'orchestrator' ]
$service_enable = true
$service_ensure = 'running'
$service_manage = true
$service_name = 'orchestrator'
$srv_cnf = '/etc/mysql/orchestrator_srv.cnf'
$topology_cnf = '/etc/mysql/orchestrator.cnf'

$config_defaults = {
'Debug' => true,
'EnableSyslog' => false,
'ListenAddress' => ':3000',
'AgentsServerPort' => ':3001',
'MySQLTopologyCredentialsConfigFile' => $topology_cnf,
'MySQLTopologySSLPrivateKeyFile' => '',
'MySQLTopologySSLCertFile' => '',
'MySQLTopologySSLCAFile' => '',
'MySQLTopologySSLSkipVerify' => true,
'MySQLTopologyUseMutualTLS' => false,
'MySQLTopologyMaxPoolConnections' => 3,
'DatabaselessMode__experimental' => false,
'MySQLOrchestratorHost' => 'myorchestrator.backend.master.mcompany.com',
'MySQLOrchestratorPort' => 3306,
'MySQLOrchestratorDatabase' => 'orchestrator',
'MySQLOrchestratorCredentialsConfigFile' => $srv_cnf,
'MySQLOrchestratorSSLPrivateKeyFile' => '',
'MySQLOrchestratorSSLCertFile' => '',
'MySQLOrchestratorSSLCAFile' => '',
'MySQLOrchestratorSSLSkipVerify' => true,
'MySQLOrchestratorUseMutualTLS' => false,
'MySQLConnectTimeoutSeconds' => 1,
'DefaultInstancePort' => 3306,
'SlaveLagQuery' => '',
'SlaveStartPostWaitMilliseconds' => 1000,
'DiscoverByShowSlaveHosts' => true,
'InstancePollSeconds' => 5,
'ReadLongRunningQueries' => false,
'BinlogFileHistoryDays' => 10,
'UnseenInstanceForgetHours' => 240,
'SnapshotTopologiesIntervalHours' => 0,
'InstanceBulkOperationsWaitTimeoutSeconds' => 10,
'ActiveNodeExpireSeconds' => 5,
'HostnameResolveMethod' => 'default',
'MySQLHostnameResolveMethod' => '@@hostname',
'SkipBinlogServerUnresolveCheck' => true,
'ExpiryHostnameResolvesMinutes' => 60,
'RejectHostnameResolvePattern' => '',
'ReasonableReplicationLagSeconds' => 10,
'ProblemIgnoreHostnameFilters' => [],
'VerifyReplicationFilters' => false,
'MaintenanceOwner' => 'orchestrator',
'ReasonableMaintenanceReplicationLagSeconds' => 20,
'MaintenanceExpireMinutes' => 10,
'MaintenancePurgeDays' => 365,
'CandidateInstanceExpireMinutes' => 60,
'AuditLogFile' => '/var/log/orchestrator-audit.log',
'AuditToSyslog' => false,
'AuditPageSize' => 20,
'AuditPurgeDays' => 365,
'RemoveTextFromHostnameDisplay' => '.mycompany.com:3306',
'ReadOnly' => false,
'AuthenticationMethod' => '',
'HTTPAuthUser' => '',
'HTTPAuthPassword' => '',
'AuthUserHeader' => '',
'PowerAuthUsers' => ['*'],
'ClusterNameToAlias' => {
'127.0.0.1' => 'test suite'
},
'AccessTokenUseExpirySeconds' => 60,
'AccessTokenExpiryMinutes' => 1440,
'DetectClusterAliasQuery' => '',
'DetectClusterDomainQuery' => '',
'DataCenterPattern' => '',
'PhysicalEnvironmentPattern' => '',
'PromotionIgnoreHostnameFilters' => [],
'ServeAgentsHttp' => false,
'AgentsUseSSL' => false,
'AgentsUseMutualTLS' => false,
'AgentSSLSkipVerify' => false,
'AgentSSLPrivateKeyFile' => '',
'AgentSSLCertFile' => '',
'AgentSSLCAFile' => '',
'AgentSSLValidOUs' => [],
'UseSSL' => false,
'UseMutualTLS' => false,
'SSLSkipVerify' => false,
'SSLPrivateKeyFile' => '',
'SSLCertFile' => '',
'SSLCAFile' => '',
'SSLValidOUs' => [],
'StatusEndpoint' => '/api/status',
'StatusSimpleHealth' => true,
'StatusOUVerify' => false,
'HttpTimeoutSeconds' => 60,
'AgentPollMinutes' => 60,
'AgentAutoDiscover' => false,
'UnseenAgentForgetHours' => 6,
'StaleSeedFailMinutes' => 60,
'SeedAcceptableBytesDiff' => 8192,
'PseudoGTIDPattern' => '`heartbeat` [(]ts, server_id, file, position, relay_master_log_file, exec_master_log_pos[)] VALUES',
'PseudoGTIDPatternIsFixedSubstring' => false,
'PseudoGTIDMonotonicHint' => 'heartbeat',
'DetectPseudoGTIDQuery' => 'select count(*)>0 as pseudo_gtid_exists from github_meta.heartbeat where ts > NOW() - INTERVAL 2 DAY;',
'BinlogEventsChunkSize' => 10000,
'BufferBinlogEvents' => true,
'SkipBinlogEventsContaining' => [],
'ReduceReplicationAnalysisCount' => false,
'FailureDetectionPeriodBlockMinutes' => 60,
'RecoveryPollSeconds' => 5,
'RecoveryPeriodBlockSeconds' => 600,
'RecoveryIgnoreHostnameFilters' => [],
'RecoverMasterClusterFilters' => [
'_master_pattern_'
],
'RecoverIntermediateMasterClusterFilters' => [
'_intermediate_master_pattern_'
],
'OnFailureDetectionProcesses' => [
"echo 'Detected {failureType} on {failureCluster}. Affected replicas: {countSlaves}' >> /tmp/recovery.log"
],
'PreFailoverProcesses' => [
"echo 'Will recover from {failureType} on {failureCluster}' >> /tmp/recovery.log"
],
'PostFailoverProcesses' => [
"echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
],
'PostUnsuccessfulFailoverProcesses' => [],
'PostMasterFailoverProcesses' => [
"echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Promoted: {successorHost}:{successorPort}' >> /tmp/recovery.log"
],
'PostIntermediateMasterFailoverProcesses' => [
"echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
],
'CoMasterRecoveryMustPromoteOtherCoMaster' => true,
'DetachLostSlavesAfterMasterFailover' => true,
'ApplyMySQLPromotionAfterMasterFailover' => false,
'MasterFailoverLostInstancesDowntimeMinutes' => 60,
'PostponeSlaveRecoveryOnLagMinutes' => 10,
'OSCIgnoreHostnameFilters' => [],
'GraphitePollSeconds' => 60,
'GraphiteAddr' => '',
'GraphitePath' => '',
'GraphiteConvertHostnameDotsToUnderscores' => true,
}
}
21 changes: 21 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
class orchestrator::service inherits orchestrator {

if ! ($orchestrator::service_ensure in [ 'running', 'stopped' ]) {
fail('service_ensure parameter must be running or stopped')
}

if $orchestrator::service_manage == true {

service { 'orchestrator':
ensure => $orchestrator::service_ensure,
enable => $orchestrator::service_enable,
hasrestart => true,
hasstatus => true,
name => $orchestrator::service_name,
subscribe => File[$orchestrator::config],
}

}

}
3 changes: 3 additions & 0 deletions templates/etc/mysql/orchestrator.cnf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[client]
user=<%= @user %>
password=%<%= @password %>%
3 changes: 3 additions & 0 deletions templates/etc/mysql/orchestrator.conf.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%
require 'json'
%><%= JSON.pretty_generate(@options).gsub(/"([0-9]+)",$/, '\1,').gsub(/[:] "([0-9]+)"$/, ': \1') %>

0 comments on commit e478fa7

Please sign in to comment.