Browse Source

initial commit

devel
Bernd Zeimetz 3 years ago
commit
89d9629676

+ 9
- 0
.fixtures.yml View File

@@ -0,0 +1,9 @@
fixtures:
repositories:
stdlib:
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib'
concat:
repo: 'git://github.com/puppetlabs/puppetlabs-concat'
ref: '2.1.0'
symlinks:
'collectd': "#{source_dir}"

+ 11
- 0
.gitignore View File

@@ -0,0 +1,11 @@
pkg/
Gemfile.lock
vendor/
spec/fixtures/
.vagrant/
.bundle/
coverage/
log/
.idea/
*.iml
*.swp

+ 1
- 0
.msync.yml View File

@@ -0,0 +1 @@
modulesync_config_version: '0.12.1'

+ 11
- 0
.nodeset.yml View File

@@ -0,0 +1,11 @@
---
default_set: 'ubuntu-server-12042-x64'
sets:
'centos-64-x64':
nodes:
"main.foo.vm":
prefab: 'centos-64-x64'
'ubuntu-server-12042-x64':
nodes:
"main.foo.vm":
prefab: 'ubuntu-server-12042-x64'

+ 2
- 0
.rspec View File

@@ -0,0 +1,2 @@
--format documentation
--color

+ 508
- 0
.rubocop.yml View File

@@ -0,0 +1,508 @@
require: rubocop-rspec
AllCops:
TargetRubyVersion: 1.9
Include:
- ./**/*.rb
Exclude:
- vendor/**/*
- .vendor/**/*
- pkg/**/*
- spec/fixtures/**/*
Lint/ConditionPosition:
Enabled: True

Lint/ElseLayout:
Enabled: True

Lint/UnreachableCode:
Enabled: True

Lint/UselessComparison:
Enabled: True

Lint/EnsureReturn:
Enabled: True

Lint/HandleExceptions:
Enabled: True

Lint/LiteralInCondition:
Enabled: True

Lint/ShadowingOuterLocalVariable:
Enabled: True

Lint/LiteralInInterpolation:
Enabled: True

Style/HashSyntax:
Enabled: True

Style/RedundantReturn:
Enabled: True

Lint/AmbiguousOperator:
Enabled: True

Lint/AssignmentInCondition:
Enabled: True

Style/SpaceBeforeComment:
Enabled: True

Style/AndOr:
Enabled: True

Style/RedundantSelf:
Enabled: True

# Method length is not necessarily an indicator of code quality
Metrics/MethodLength:
Enabled: False

# Module length is not necessarily an indicator of code quality
Metrics/ModuleLength:
Enabled: False

Style/WhileUntilModifier:
Enabled: True

Lint/AmbiguousRegexpLiteral:
Enabled: True

Lint/Eval:
Enabled: True

Lint/BlockAlignment:
Enabled: True

Lint/DefEndAlignment:
Enabled: True

Lint/EndAlignment:
Enabled: True

Lint/DeprecatedClassMethods:
Enabled: True

Lint/Loop:
Enabled: True

Lint/ParenthesesAsGroupedExpression:
Enabled: True

Lint/RescueException:
Enabled: True

Lint/StringConversionInInterpolation:
Enabled: True

Lint/UnusedBlockArgument:
Enabled: True

Lint/UnusedMethodArgument:
Enabled: True

Lint/UselessAccessModifier:
Enabled: True

Lint/UselessAssignment:
Enabled: True

Lint/Void:
Enabled: True

Style/AccessModifierIndentation:
Enabled: True

Style/AccessorMethodName:
Enabled: True

Style/Alias:
Enabled: True

Style/AlignArray:
Enabled: True

Style/AlignHash:
Enabled: True

Style/AlignParameters:
Enabled: True

Metrics/BlockNesting:
Enabled: True

Style/AsciiComments:
Enabled: True

Style/Attr:
Enabled: True

Style/BracesAroundHashParameters:
Enabled: True

Style/CaseEquality:
Enabled: True

Style/CaseIndentation:
Enabled: True

Style/CharacterLiteral:
Enabled: True

Style/ClassAndModuleCamelCase:
Enabled: True

Style/ClassAndModuleChildren:
Enabled: False

Style/ClassCheck:
Enabled: True

# Class length is not necessarily an indicator of code quality
Metrics/ClassLength:
Enabled: False

Style/ClassMethods:
Enabled: True

Style/ClassVars:
Enabled: True

Style/WhenThen:
Enabled: True

Style/WordArray:
Enabled: True

Style/UnneededPercentQ:
Enabled: True

Style/Tab:
Enabled: True

Style/SpaceBeforeSemicolon:
Enabled: True

Style/TrailingBlankLines:
Enabled: True

Style/SpaceInsideBlockBraces:
Enabled: True

Style/SpaceInsideBrackets:
Enabled: True

Style/SpaceInsideHashLiteralBraces:
Enabled: True

Style/SpaceInsideParens:
Enabled: True

Style/LeadingCommentSpace:
Enabled: True

Style/SpaceBeforeFirstArg:
Enabled: True

Style/SpaceAfterColon:
Enabled: True

Style/SpaceAfterComma:
Enabled: True

Style/SpaceAfterMethodName:
Enabled: True

Style/SpaceAfterNot:
Enabled: True

Style/SpaceAfterSemicolon:
Enabled: True

Style/SpaceAroundEqualsInParameterDefault:
Enabled: True

Style/SpaceAroundOperators:
Enabled: True

Style/SpaceBeforeBlockBraces:
Enabled: True

Style/SpaceBeforeComma:
Enabled: True

Style/CollectionMethods:
Enabled: True

Style/CommentIndentation:
Enabled: True

Style/ColonMethodCall:
Enabled: True

Style/CommentAnnotation:
Enabled: True

# 'Complexity' is very relative
Metrics/CyclomaticComplexity:
Enabled: False

Style/ConstantName:
Enabled: True

Style/Documentation:
Enabled: False

Style/DefWithParentheses:
Enabled: True

Style/PreferredHashMethods:
Enabled: True

Style/DotPosition:
EnforcedStyle: trailing

Style/DoubleNegation:
Enabled: True

Style/EachWithObject:
Enabled: True

Style/EmptyLineBetweenDefs:
Enabled: True

Style/IndentArray:
Enabled: True

Style/IndentHash:
Enabled: True

Style/IndentationConsistency:
Enabled: True

Style/IndentationWidth:
Enabled: True

Style/EmptyLines:
Enabled: True

Style/EmptyLinesAroundAccessModifier:
Enabled: True

Style/EmptyLiteral:
Enabled: True

# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Enabled: False

Style/MethodCallParentheses:
Enabled: True

Style/MethodDefParentheses:
Enabled: True

Style/LineEndConcatenation:
Enabled: True

Style/TrailingWhitespace:
Enabled: True

Style/StringLiterals:
Enabled: True

Style/TrailingCommaInArguments:
Enabled: True

Style/TrailingCommaInLiteral:
Enabled: True

Style/GlobalVars:
Enabled: True

Style/GuardClause:
Enabled: True

Style/IfUnlessModifier:
Enabled: True

Style/MultilineIfThen:
Enabled: True

Style/NegatedIf:
Enabled: True

Style/NegatedWhile:
Enabled: True

Style/Next:
Enabled: True

Style/SingleLineBlockParams:
Enabled: True

Style/SingleLineMethods:
Enabled: True

Style/SpecialGlobalVars:
Enabled: True

Style/TrivialAccessors:
Enabled: True

Style/UnlessElse:
Enabled: True

Style/VariableInterpolation:
Enabled: True

Style/VariableName:
Enabled: True

Style/WhileUntilDo:
Enabled: True

Style/EvenOdd:
Enabled: True

Style/FileName:
Enabled: True

Style/For:
Enabled: True

Style/Lambda:
Enabled: True

Style/MethodName:
Enabled: True

Style/MultilineTernaryOperator:
Enabled: True

Style/NestedTernaryOperator:
Enabled: True

Style/NilComparison:
Enabled: True

Style/FormatString:
Enabled: True

Style/MultilineBlockChain:
Enabled: True

Style/Semicolon:
Enabled: True

Style/SignalException:
Enabled: True

Style/NonNilCheck:
Enabled: True

Style/Not:
Enabled: True

Style/NumericLiterals:
Enabled: True

Style/OneLineConditional:
Enabled: True

Style/OpMethod:
Enabled: True

Style/ParenthesesAroundCondition:
Enabled: True

Style/PercentLiteralDelimiters:
Enabled: True

Style/PerlBackrefs:
Enabled: True

Style/PredicateName:
Enabled: True

Style/RedundantException:
Enabled: True

Style/SelfAssignment:
Enabled: True

Style/Proc:
Enabled: True

Style/RaiseArgs:
Enabled: True

Style/RedundantBegin:
Enabled: True

Style/RescueModifier:
Enabled: True

# based on https://github.com/voxpupuli/modulesync_config/issues/168
Style/RegexpLiteral:
EnforcedStyle: percent_r
Enabled: True

Lint/UnderscorePrefixedVariableName:
Enabled: True

Metrics/ParameterLists:
Enabled: False

Lint/RequireParentheses:
Enabled: True

Style/SpaceBeforeFirstArg:
Enabled: True

Style/ModuleFunction:
Enabled: True

Lint/Debugger:
Enabled: True

Style/IfWithSemicolon:
Enabled: True

Style/Encoding:
Enabled: True

Style/BlockDelimiters:
Enabled: True

Style/MultilineBlockLayout:
Enabled: True

# 'Complexity' is very relative
Metrics/AbcSize:
Enabled: False

# 'Complexity' is very relative
Metrics/PerceivedComplexity:
Enabled: False

Lint/UselessAssignment:
Enabled: True

Style/ClosingParenthesisIndentation:
Enabled: True

# RSpec

# We don't use rspec in this way
RSpec/DescribeClass:
Enabled: False

# Example length is not necessarily an indicator of code quality
RSpec/ExampleLength:
Enabled: False

RSpec/NamedSubject:
Enabled: False

+ 50
- 0
.travis.yml View File

@@ -0,0 +1,50 @@
---
sudo: false
language: ruby
cache: bundler
bundler_args: --without system_tests development
before_install:
- bundle -v
- rm Gemfile.lock || true
- gem update --system
- gem update bundler
- gem --version
- bundle -v
script:
- 'bundle exec rake $CHECK'
matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test
- rvm: 2.1
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.2
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=build
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=rubocop
- rvm: 2.3.1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test
- rvm: 2.4.0-preview1
env: PUPPET_VERSION="~> 4.0" STRICT_VARIABLES="yes" CHECK=test
allow_failures:
- rvm: 2.4.0-preview1
notifications:
email: false
deploy:
provider: puppetforge
user: bzed
password:
secure: "ZInnboKjJg1ZN62Pb6t1tY2qPt0NEZWOlp+vo/CzY/Jxeoh8WdWVAVLyn6ay2/aPm0lgLYLNgHLEdB0qyZvgKXdajAjuZdVsrl5jAh/AoRTVpVTVx4YmpbFUxruO6DZcu3i5er3pKy5vuZjbdRhPBwObC4ImHJItS4FOt2aKb640s3nRk+AkM/pAoGOtpOzVLVDG/Wy/539MjQfvJ/qNlUBipSDkxshFRhq18rO/cg9yETCO1M7hG2qZgvqaX64jVhUs9nni+y9EMFdEGMIGULueALZ63aA9Bo/24q40mIDmMHF79eTNBhUCfugbXM5fYzwzVY+2NtEEgPmMY68/yCR0nN8fgWfenq69nUwS4/a2ThiCFswZftJRnCSqME2ZDPdhcwvo1cIDOKN3YPTn5bMbSG8wMt63o5viEU8hZoILNZUDpY+SkEUX1nIeNxWRr+paho3jX/PNHoaaZudt7ET57i7h+9Zt7UzhHRJ88yiL6LE6OACaluAH/9b+MhnquFd/h8zfL1AENuMnKyGmhXc1qoaCnSvzKb6qs65WSJq1gKY5dbrLCPlYnleMO4zb3p6o527RUrlX0fL8acas/QXc2RjiYw50kC4c+7MZcOtIteDiMfAoDbRi1cm9AHl/abh5eqEU5/4je3ePhVKa05TS2RgW3r493ykCQe3E8qk="
on:
tags: true
# all_branches is required to use tags
all_branches: true
# Only publish if our main Ruby target builds
rvm: 2.3.1

+ 63
- 0
Gemfile View File

@@ -0,0 +1,63 @@
source ENV['GEM_SOURCE'] || "https://rubygems.org"

def location_for(place, fake_version = nil)
if place =~ /^(git[:@][^#]*)#(.*)/
[fake_version, { :git => $1, :branch => $2, :require => false }].compact
elsif place =~ /^file:\/\/(.*)/
['>= 0', { :path => File.expand_path($1), :require => false }]
else
[place, { :require => false }]
end
end

group :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'rspec-puppet', :require => false, :git => 'https://github.com/rodjek/rspec-puppet.git'
gem 'rspec-puppet-facts', :require => false
gem 'rspec-puppet-utils', :require => false
gem 'puppet-lint-absolute_classname-check', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
gem 'puppet-lint-version_comparison-check', :require => false
gem 'puppet-lint-classes_and_types_beginning_with_digits-check', :require => false
gem 'puppet-lint-unquoted_string-check', :require => false
gem 'puppet-lint-variable_contains_upcase', :require => false
gem 'metadata-json-lint', :require => false
gem 'puppet-blacksmith', :require => false
gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git'
gem 'puppet-strings', :require => false, :git => 'https://github.com/puppetlabs/puppetlabs-strings.git'
gem 'rubocop-rspec', '~> 1.6', :require => false if RUBY_VERSION >= '2.3.0'
gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0'
gem 'puppet-lint', '2.0.0'
end

group :development do
gem 'travis', :require => false
gem 'travis-lint', :require => false
gem 'guard-rake', :require => false
end

group :system_tests do
if beaker_version = ENV['BEAKER_VERSION']
gem 'beaker', *location_for(beaker_version)
end
if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
gem 'beaker-rspec', *location_for(beaker_rspec_version)
else
gem 'beaker-rspec', :require => false
end
gem 'beaker-puppet_install_helper', :require => false
end



if facterversion = ENV['FACTER_GEM_VERSION']
gem 'facter', facterversion.to_s, :require => false, :groups => [:test]
else
gem 'facter', :require => false, :groups => [:test]
end

ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 4.0' : puppetversion = ENV['PUPPET_VERSION'].to_s
gem 'puppet', puppetversion, :require => false, :groups => [:test]

# vim: syntax=ruby

+ 83
- 0
README.md View File

@@ -0,0 +1,83 @@
# percona

#### Table of Contents

1. [Description](#description)
1. [Setup - The basics of getting started with percona](#setup)
* [What percona affects](#what-percona-affects)
* [Setup requirements](#setup-requirements)
* [Beginning with percona](#beginning-with-percona)
1. [Usage - Configuration options and additional functionality](#usage)
1. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
1. [Limitations - OS compatibility, etc.](#limitations)
1. [Development - Guide for contributing to the module](#development)

## Description

Start with a one- or two-sentence summary of what the module does and/or what
problem it solves. This is your 30-second elevator pitch for your module.
Consider including OS/Puppet version it works with.

You can give more descriptive information in a second paragraph. This paragraph
should answer the questions: "What does this module *do*?" and "Why would I use
it?" If your module has a range of functionality (installation, configuration,
management, etc.), this is the time to mention it.

## Setup

### What percona affects **OPTIONAL**

If it's obvious what your module touches, you can skip this section. For
example, folks can probably figure out that your mysql_instance module affects
their MySQL instances.

If there's more that they should know about, though, this is the place to mention:

* A list of files, packages, services, or operations that the module will alter,
impact, or execute.
* Dependencies that your module automatically installs.
* Warnings or other important notices.

### Setup Requirements **OPTIONAL**

If your module requires anything extra before setting up (pluginsync enabled,
etc.), mention it here.

If your most recent release breaks compatibility or requires particular steps
for upgrading, you might want to include an additional "Upgrading" section
here.

### Beginning with percona

The very basic steps needed for a user to get the module up and running. This
can include setup steps, if necessary, or it can be an example of the most
basic use of the module.

## Usage

This section is where you describe how to customize, configure, and do the
fancy stuff with your module here. It's especially helpful if you include usage
examples and code samples for doing things with your module.

## Reference

Here, include a complete list of your module's classes, types, providers,
facts, along with the parameters for each. Users refer to this section (thus
the name "Reference") to find specific details; most users don't read it per
se.

## Limitations

This is where you list OS compatibility, version compatibility, etc. If there
are Known Issues, you might want to include them under their own heading here.

## Development

Since your module is awesome, other users will want to play with it. Let them
know what the ground rules for contributing are.

## Release Notes/Contributors/Etc. **Optional**

If you aren't using changelog, put your release notes here (though you should
consider using changelog). You can also add any additional sections you feel
are necessary or important to include here. Please use the `## ` header.

+ 44
- 0
Rakefile View File

@@ -0,0 +1,44 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet_blacksmith/rake_tasks'
require 'voxpupuli/release/rake_tasks'
require 'puppet-strings/rake_tasks'

if RUBY_VERSION >= '2.3.0'
require 'rubocop/rake_task'

RuboCop::RakeTask.new(:rubocop) do |task|
# These make the rubocop experience maybe slightly less terrible
task.options = ['-D', '-S', '-E']
end
end

PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{check}:%{KIND}:%{message}'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('relative')
PuppetLint.configuration.send('disable_140chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_documentation')
PuppetLint.configuration.send('disable_single_quote_string_with_variables')

exclude_paths = %w(
pkg/**/*
vendor/**/*
.vendor/**/*
spec/**/*
)
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths

desc 'Run acceptance tests'
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end

desc 'Run tests metadata_lint, lint, syntax, spec'
task test: [
:metadata_lint,
:lint,
:syntax,
:spec,
]
# vim: syntax=ruby

+ 10
- 0
files/server/clustercheck.socket View File

@@ -0,0 +1,10 @@
[Unit]
Description=MySQL Clustercheck Socket for HAProxy

[Socket]
ListenStream=9200
ReusePort=true
Accept=true

[Install]
WantedBy=sockets.target

+ 7
- 0
files/server/clustercheck@.service View File

@@ -0,0 +1,7 @@
[Unit]
Description=MySQL Clustercheck for HAProxy

[Service]
EnvironmentFile=/etc/default/clustercheck
StandardInput=socket
ExecStart=/usr/bin/clustercheck $CS_USER $CS_PASSWORD 1 $LOGFILE 0 $MYS_CONFIG

+ 8
- 0
lib/facter/galera_wsrep_node_address.rb View File

@@ -0,0 +1,8 @@
Facter.add("galera_wsrep_node_address") do
setcode do
wsrep_node_address = Facter::Util::Resolution.exec('mysql -ssrBe "show global variables like \'wsrep_node_address\'')
if wsrep_node_address and wsrep_node_address =~ /^wsrep_node_address/
wsrep_node_address.split('\t')[1]
end
end
end

+ 65
- 0
manifests/garbd.pp View File

@@ -0,0 +1,65 @@
class percona::garbd(
$clustername,
) {

class { '::percona::server::nodes' :
clustername => $clustername
}


$galera_nodes = regsubst(
pick(
getvar("::percona_cluster_${clustername}"),
''
),
',$',
''
)

if ($galera_nodes and !empty($galera_nodes)) {
ensure_packages('percona-xtradb-cluster-garbd-3')

# work around having a buggy init script.
# with some luck they'll ship a systemd service for jessie at some point
service { 'garbd.service' :
ensure => running,
provider => systemd,
hasrestart => true,
status => '/etc/init.d/garbd status',
hasstatus => false,
start => '/bin/systemctl restart garbd.service',
require => File['/var/lib/galera'],
}

file { '/etc/default/garbd' :
ensure => file,
owner => root,
group => root,
mode => '0644',
content => template('percona/garbd/defaults.erb'),
notify => Service['garbd.service'],
}

file_line { 'fix-garbd-init-script' :
path => '/etc/init.d/garbd',
line => 'exit $?',
match => '^exit 0',
notify => Exec['garbd-systemctl-daemon-reload'],
}
exec { 'garbd-systemctl-daemon-reload' :
path => $::path,
refreshonly => true,
command => 'systemctl daemon-reload',
}

file { '/var/lib/galera' :
ensure => directory,
owner => nobody,
group => root,
mode => '0750',
}
} else {
notify { '$galera_nodes is empty - no idea where to connect to yet' : }
}

}

+ 48
- 0
manifests/init.pp View File

@@ -0,0 +1,48 @@
# Class: percona
# ===========================
#
# Full description of class percona here.
#
# Parameters
# ----------
#
# Document parameters here.
#
# * `sample parameter`
# Explanation of what this parameter affects and what it defaults to.
# e.g. "Specify one or more upstream ntp servers as an array."
#
# Variables
# ----------
#
# Here you should define a list of variables that this module would require.
#
# * `sample variable`
# Explanation of how this variable affects the function of this class and if
# it has a default. e.g. "The parameter enc_ntp_servers must be set by the
# External Node Classifier as a comma separated list of hostnames." (Note,
# global variables should be avoided in favor of class parameters as
# of Puppet 2.6.)
#
# Examples
# --------
#
# @example
# class { 'percona':
# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
# }
#
# Authors
# -------
#
# Author Name <author@domain.com>
#
# Copyright
# ---------
#
# Copyright 2016 Your name here, unless otherwise noted.
#
class percona {


}

+ 15
- 0
manifests/server.pp View File

@@ -0,0 +1,15 @@
class percona::server(
$clustername,
$wsrep_node_address = $::ipaddress,
) {

::percona::server::nodes::export { $wsrep_node_address :
clustername => $clustername
}

class { '::percona::server::nodes' :
clustername => $clustername
}


}

+ 60
- 0
manifests/server/clustercheck.pp View File

@@ -0,0 +1,60 @@
# clustercheck.pp

class percona::server::clustercheck (
$user,
$password,
$logfile = '/var/log/clustercheck.log',
$mysqlconfig = '/etc/mysql/my.cnf',
) {
$options = {
'CS_USER' => $user,
'CS_PASSWORD' => $password,
'LOGFILE' => $logfile,
'MYS_CONFIG' => $mysqlconfig,
}
file{'/etc/systemd/system/clustercheck.socket':
ensure => file,
source => 'puppet:///modules/percona/server/clustercheck.socket',
require => File['/etc/systemd/system/clustercheck@.service'],
notify => [Service['clustercheck.socket'], Exec['clusterchk-systemctl-daemon-reload']],
}
file{'/etc/systemd/system/clustercheck@.service':
ensure => file,
source => 'puppet:///modules/percona/server/clustercheck@.service',
require => File['/etc/default/clustercheck'],
notify => [Service['clustercheck.socket'], Exec['clusterchk-systemctl-daemon-reload']],
}
file{'/etc/systemd/system/clustercheck.service':
ensure => absent,
force => true,
notify => Exec['clusterchk-systemctl-daemon-reload'],
}
file{'/etc/default/clustercheck':
ensure => file,
content => join( join_keys_to_values($options,'='),"\n"),
}
service{'clustercheck.socket':
ensure => running,
provider => 'systemd',
require => File['/etc/systemd/system/clustercheck.socket'],
subscribe => Exec['clusterchk-systemctl-daemon-reload'],
}
exec{'clusterchk-systemctl-daemon-reload':
path => $::path,
refreshonly => true,
command => 'systemctl daemon-reload',
}
mysql_user{ "${user}@localhost" :
ensure => 'present',
password_hash => mysql_password($password),
require => Class['mysql::server'],
}
mysql_grant { "${user}@localhost/*.*":
ensure => 'present',
options => ['GRANT'],
privileges => ['PROCESS'],
table => '*.*',
user => "${user}@localhost",
require => Mysql_user['clusterchk@localhost'],
}
}

+ 137
- 0
manifests/server/haproxy.pp View File

@@ -0,0 +1,137 @@
class percona::server::haproxy(
$clustername,
$haproxy_global_options = {},
$haproxy_defaults_options = {},
$haproxy_backend_options = {},
$haproxy_socket = '/run/haproxy/admin.sock',
$haproxy_readonly_frontend_bind = { "${::galera_wsrep_node_address}::3307" => [] },
$haproxy_readwrite_frontend_bind = { "${::galera_wsrep_node_address}::3308" => [] },
$haproxy_balancermember_options = 'check port 9200 inter 12000 rise 3 fall 3 weight 100',
){

ensure_packages('hatop')

$clusternodes = getvar("::percona_cluster_${clustername}")
$clusternodes_array = split($clusternodes, ',')

if ($clusternodes_array
and $::galera_wsrep_node_address
and !empty($clusternodes_array)
and $clusternodes_array[0] == $::galera_wsrep_node_address
) {
$rw_backend = true
} else {
$rw_backend = false
}


$haproxy_default_global_options = {
'log' => [
'/var/lib/haproxy/dev/log local0',
"${::conova_basics::syslog_server}:515 local0",
],
'chroot' => '/var/lib/haproxy',
'stats' => "socket ${haproxy_socket} level admin mode 0660",
'user' => 'haproxy',
'group' => 'haproxy',
'ulimit-n' => '65536',
'maxconn' => '32000',
}

$haproxy_default_defaults_options = {
'log' => 'global',
'mode' => 'http',
'timeout' => [
'connect 5s',
'client 28800s',
'server 28800s',
],
'option' => [
'log-health-checks',
'dontlognull',
'tcplog',
'redispatch',
],
'retries' => 3,
'maxconn' => '32000',
}

$haproxy_default_backend_options = {
'mode' => 'tcp',
'balance' => 'roundrobin',
option => [
'tcplog',
'httpchk',
],
'maxconn' => '2048',
}

class { '::haproxy' :
global_options => deep_merge(
$haproxy_default_global_options,
$haproxy_global_options
),
defaults_options => deep_merge(
$haproxy_default_defaults_options,
$haproxy_defaults_options,
),
}


Haproxy::Backend{
options => deep_merge(
$haproxy_default_backend_options,
$haproxy_backend_options,
),
collect_exported => false,
require => Service['clustercheck.socket'],
}

::haproxy::frontend{"${clustername}-ro":
bind => $haproxy_readonly_frontend_bind,
mode => 'tcp',
options => {
'default_backend' => "${clustername}-ro",
},
}

::haproxy::frontend{"${clustername}-rw":
bind => $haproxy_readwrite_frontend_bind,
mode => 'tcp',
options => {
'default_backend' => "${clustername}-rw",
},
}

::haproxy::backend{"${clustername}-ro": }
::haproxy::backend{"${clustername}-rw": }

Haproxy::Balancermember <<| listening_service == "${clustername}-ro" and tag == 'bzed-percona_cluster' |>>
Haproxy::Balancermember <<| listening_service == "${clustername}-rw" and tag == 'bzed-percona_cluster' |>>

@@::haproxy::balancermember{"${::hostname}-ro":
listening_service => "${clustername}-ro",
ports => 3306,
ipaddresses => $::galera_wsrep_node_address,
server_names => $::hostname,
options => $haproxy_balancermember_options,
tag => 'bzed-percona_cluster',
}

if $rw_backend {
$rw_backup = ''
} else {
$rw_backup = 'backup'
}

@@::haproxy::balancermember{"${::hostname}-rw":
listening_service => "${clustername}-rw",
ports => 3306,
ipaddresses => $::galera_wsrep_node_address,
server_names => $::hostname,
options => "${haproxy_balancermember_options} ${rw_backup}",
tag => 'bzed-percona_cluster',
}


}

+ 15
- 0
manifests/server/nodes.pp View File

@@ -0,0 +1,15 @@
class percona::server::nodes(
$clustername,
) {
$target = "/etc/facter/facts.d/percona_cluster_${clustername}.txt"
concat { $target:
ensure => present,
}
concat::fragment { 'header':
target => $target,
content => "percona_cluster_${clustername}=",
order => '01'
}

Concat::Fragment <<| target == $target and tag == 'bzed-percona_cluster' |>>
}

+ 13
- 0
manifests/server/nodes/export.pp View File

@@ -0,0 +1,13 @@
define percona::server::nodes::export(
$clustername,
$galera_wsrep_node_address = $name,
) {
$target = "/etc/facter/facts.d/percona_cluster_${clustername}.txt"
@@concat::fragment { $::fqdn:
target => $target,
content => "${galera_wsrep_node_address},",
order => '10',
tag => 'bzed-percona_cluster',
}
}


+ 23
- 0
metadata.json View File

@@ -0,0 +1,23 @@
{
"name": "bzed-percona",
"version": "0.1.0",
"author": "bzed",
"summary": "Percona XtraDB Cluster setup",
"license": "Apache-2.0",
"source": "https://github.com/bzed/bzed-percona",
"project_page": "https://github.com/bzed/bzed-percona",
"issues_url": "https://github.com/bzed/bzed-percona/issues",
"dependencies": [
{"name":"puppetlabs-concat","version_requirement":">= 2.1.0"},
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
],
"data_provider": null,
"operatingsystem_support": [
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"8"
]
}
]
}

+ 7
- 0
spec/classes/init_spec.rb View File

@@ -0,0 +1,7 @@
require 'spec_helper'
describe 'percona' do

context 'with default values for all parameters' do
it { should contain_class('percona') }
end
end

+ 1
- 0
spec/spec_helper.rb View File

@@ -0,0 +1 @@
require 'puppetlabs_spec_helper/module_spec_helper'

+ 18
- 0
templates/garbd/defaults.erb View File

@@ -0,0 +1,18 @@
### MANAGE BY PUPPET
# EDITING DOES NOT MAKE SENSE, YOU FOOL.


# A space-separated list of node addresses (address[:port]) in the cluster
GALERA_NODES="<%= @galera_nodes -%>"

# Galera cluster name, should be the same as on the rest of the nodes.
GALERA_GROUP="<%= @clustername -%>"

# Optional Galera internal options string (e.g. SSL settings)
# see http://www.codership.com/wiki/doku.php?id=galera_parameters
GALERA_OPTIONS="pc.wait_prim=no"

# Log file for garbd. Optional, by default logs to syslog
# Deprecated for CentOS7, use journalctl to query the log for garbd
# LOG_FILE=""


+ 12
- 0
tests/init.pp View File

@@ -0,0 +1,12 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation
# errors and view a log of events) or by fully applying the test in a virtual
# environment (to compare the resulting system state to the desired state).
#
# Learn more about module testing here:
# https://docs.puppetlabs.com/guides/tests_smoke.html
#
include ::percona

Loading…
Cancel
Save