diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..37a7699
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+github: [cirrax]
+custom: ["https://cirrax.com"]
diff --git a/.github/workflows/pdk.yml b/.github/workflows/pdk.yml
new file mode 100644
index 0000000..4012fa3
--- /dev/null
+++ b/.github/workflows/pdk.yml
@@ -0,0 +1,37 @@
+name: PDK
+
+on:
+ - 'push'
+ - 'pull_request'
+
+jobs:
+ validate:
+ runs-on: ubuntu-latest
+ container: puppet/pdk:latest
+ outputs:
+ puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }}
+ github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }}
+ steps:
+ - name: Install build-essential
+ run: |
+ export DEBIAN_FRONTEND=noninteractive;
+ apt-get --yes update
+ apt-get --yes install build-essential
+ - name: Check out repository code
+ uses: actions/checkout@v3
+ - name: run pdk validate
+ run: pdk validate
+
+ unit-test:
+ runs-on: ubuntu-latest
+ container: puppet/pdk:latest
+ steps:
+ - name: Install build-essential
+ run: |
+ export DEBIAN_FRONTEND=noninteractive;
+ apt-get --yes update
+ apt-get --yes install build-essential
+ - name: Check out repository code
+ uses: actions/checkout@v3
+ - name: run pdk test unit
+ run: pdk test unit
diff --git a/.gitignore b/.gitignore
index 988dcbb..3f15512 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,7 +16,7 @@
/log/
/pkg/
/spec/fixtures/manifests/
-/spec/fixtures/modules/
+/spec/fixtures/modules/*
/tmp/
/vendor/
/convert_report.txt
diff --git a/.pdkignore b/.pdkignore
index c538bea..584438f 100644
--- a/.pdkignore
+++ b/.pdkignore
@@ -16,7 +16,7 @@
/log/
/pkg/
/spec/fixtures/manifests/
-/spec/fixtures/modules/
+/spec/fixtures/modules/*
/tmp/
/vendor/
/convert_report.txt
@@ -26,20 +26,16 @@
.envrc
/inventory.yaml
/spec/fixtures/litmus_inventory.yaml
-/appveyor.yml
-/.editorconfig
/.fixtures.yml
/Gemfile
/.gitattributes
/.gitignore
-/.gitlab-ci.yml
/.pdkignore
/.puppet-lint.rc
/Rakefile
/rakelib/
/.rspec
-/.rubocop.yml
-/.travis.yml
+/..yml
/.yardopts
/spec/
/.vscode/
diff --git a/.rubocop.yml b/.rubocop.yml
index 31e8248..5be1f9f 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -4,7 +4,7 @@ require:
- rubocop-rspec
AllCops:
DisplayCopNames: true
- TargetRubyVersion: '2.5'
+ TargetRubyVersion: '2.6'
Include:
- "**/*.rb"
Exclude:
@@ -111,8 +111,14 @@ Style/MethodCalledOnDoEndBlock:
Enabled: true
Style/StringMethods:
Enabled: true
+Bundler/GemFilename:
+ Enabled: false
Bundler/InsecureProtocolSource:
Enabled: false
+Capybara/CurrentPathExpectation:
+ Enabled: false
+Capybara/VisibilityMatcher:
+ Enabled: false
Gemspec/DuplicatedAssignment:
Enabled: false
Gemspec/OrderedDependencies:
@@ -287,11 +293,9 @@ Performance/UriDefaultParser:
Enabled: false
RSpec/Be:
Enabled: false
-RSpec/Capybara/CurrentPathExpectation:
- Enabled: false
RSpec/Capybara/FeatureMethods:
Enabled: false
-RSpec/Capybara/VisibilityMatcher:
+RSpec/ContainExactly:
Enabled: false
RSpec/ContextMethod:
Enabled: false
@@ -331,6 +335,8 @@ RSpec/LeakyConstantDeclaration:
Enabled: false
RSpec/LetBeforeExamples:
Enabled: false
+RSpec/MatchArray:
+ Enabled: false
RSpec/MissingExampleGroupArgument:
Enabled: false
RSpec/MultipleExpectations:
@@ -373,8 +379,6 @@ Style/AccessModifierDeclarations:
Enabled: false
Style/AccessorGrouping:
Enabled: false
-Style/AsciiComments:
- Enabled: false
Style/BisectedAttrAccessor:
Enabled: false
Style/CaseLikeIf:
@@ -485,35 +489,235 @@ Style/TrailingMethodEndStatement:
Enabled: false
Style/UnpackFirst:
Enabled: false
+Capybara/MatchStyle:
+ Enabled: false
+Capybara/NegationMatcher:
+ Enabled: false
+Capybara/SpecificActions:
+ Enabled: false
+Capybara/SpecificFinders:
+ Enabled: false
+Capybara/SpecificMatcher:
+ Enabled: false
+Gemspec/DeprecatedAttributeAssignment:
+ Enabled: false
+Gemspec/DevelopmentDependencies:
+ Enabled: false
+Gemspec/RequireMFA:
+ Enabled: false
+Layout/LineContinuationLeadingSpace:
+ Enabled: false
+Layout/LineContinuationSpacing:
+ Enabled: false
+Layout/LineEndStringConcatenationIndentation:
+ Enabled: false
+Layout/SpaceBeforeBrackets:
+ Enabled: false
+Lint/AmbiguousAssignment:
+ Enabled: false
+Lint/AmbiguousOperatorPrecedence:
+ Enabled: false
+Lint/AmbiguousRange:
+ Enabled: false
+Lint/ConstantOverwrittenInRescue:
+ Enabled: false
+Lint/DeprecatedConstants:
+ Enabled: false
Lint/DuplicateBranch:
Enabled: false
+Lint/DuplicateMagicComment:
+ Enabled: false
Lint/DuplicateRegexpCharacterClassElement:
Enabled: false
Lint/EmptyBlock:
Enabled: false
Lint/EmptyClass:
Enabled: false
+Lint/EmptyInPattern:
+ Enabled: false
+Lint/IncompatibleIoSelectWithFiberScheduler:
+ Enabled: false
+Lint/LambdaWithoutLiteralBlock:
+ Enabled: false
Lint/NoReturnInBeginEndBlocks:
Enabled: false
+Lint/NonAtomicFileOperation:
+ Enabled: false
+Lint/NumberedParameterAssignment:
+ Enabled: false
+Lint/OrAssignmentToConstant:
+ Enabled: false
+Lint/RedundantDirGlobSort:
+ Enabled: false
+Lint/RefinementImportMethods:
+ Enabled: false
+Lint/RequireRangeParentheses:
+ Enabled: false
+Lint/RequireRelativeSelfPath:
+ Enabled: false
+Lint/SymbolConversion:
+ Enabled: false
Lint/ToEnumArguments:
Enabled: false
+Lint/TripleQuotes:
+ Enabled: false
Lint/UnexpectedBlockArity:
Enabled: false
Lint/UnmodifiedReduceAccumulator:
Enabled: false
+Lint/UselessRescue:
+ Enabled: false
+Lint/UselessRuby2Keywords:
+ Enabled: false
+Metrics/CollectionLiteralLength:
+ Enabled: false
+Naming/BlockForwarding:
+ Enabled: false
Performance/CollectionLiteralInLoop:
Enabled: false
+Performance/ConcurrentMonotonicTime:
+ Enabled: false
+Performance/MapCompact:
+ Enabled: false
+Performance/RedundantEqualityComparisonBlock:
+ Enabled: false
+Performance/RedundantSplitRegexpArgument:
+ Enabled: false
+Performance/StringIdentifierArgument:
+ Enabled: false
+RSpec/BeEq:
+ Enabled: false
+RSpec/BeNil:
+ Enabled: false
+RSpec/ChangeByZero:
+ Enabled: false
+RSpec/ClassCheck:
+ Enabled: false
+RSpec/DuplicatedMetadata:
+ Enabled: false
+RSpec/ExcessiveDocstringSpacing:
+ Enabled: false
+RSpec/FactoryBot/ConsistentParenthesesStyle:
+ Enabled: false
+RSpec/FactoryBot/FactoryNameStyle:
+ Enabled: false
+RSpec/FactoryBot/SyntaxMethods:
+ Enabled: false
+RSpec/IdenticalEqualityAssertion:
+ Enabled: false
+RSpec/NoExpectationExample:
+ Enabled: false
+RSpec/PendingWithoutReason:
+ Enabled: false
+RSpec/Rails/AvoidSetupHook:
+ Enabled: false
+RSpec/Rails/HaveHttpStatus:
+ Enabled: false
+RSpec/Rails/InferredSpecType:
+ Enabled: false
+RSpec/Rails/MinitestAssertions:
+ Enabled: false
+RSpec/Rails/TravelAround:
+ Enabled: false
+RSpec/RedundantAround:
+ Enabled: false
+RSpec/SkipBlockInsideExample:
+ Enabled: false
+RSpec/SortMetadata:
+ Enabled: false
+RSpec/SubjectDeclaration:
+ Enabled: false
+RSpec/VerifiedDoubleReference:
+ Enabled: false
+Security/CompoundHash:
+ Enabled: false
+Security/IoMethods:
+ Enabled: false
Style/ArgumentsForwarding:
Enabled: false
+Style/ArrayIntersect:
+ Enabled: false
Style/CollectionCompact:
Enabled: false
+Style/ComparableClamp:
+ Enabled: false
+Style/ConcatArrayLiterals:
+ Enabled: false
+Style/DirEmpty:
+ Enabled: false
Style/DocumentDynamicEvalDefinition:
Enabled: false
+Style/EmptyHeredoc:
+ Enabled: false
+Style/EndlessMethod:
+ Enabled: false
+Style/EnvHome:
+ Enabled: false
+Style/FetchEnvVar:
+ Enabled: false
+Style/FileEmpty:
+ Enabled: false
+Style/FileRead:
+ Enabled: false
+Style/FileWrite:
+ Enabled: false
+Style/HashConversion:
+ Enabled: false
+Style/HashExcept:
+ Enabled: false
+Style/IfWithBooleanLiteralBranches:
+ Enabled: false
+Style/InPatternThen:
+ Enabled: false
+Style/MagicCommentFormat:
+ Enabled: false
+Style/MapCompactWithConditionalBlock:
+ Enabled: false
+Style/MapToHash:
+ Enabled: false
+Style/MapToSet:
+ Enabled: false
+Style/MinMaxComparison:
+ Enabled: false
+Style/MultilineInPatternThen:
+ Enabled: false
Style/NegatedIfElseCondition:
Enabled: false
+Style/NestedFileDirname:
+ Enabled: false
Style/NilLambda:
Enabled: false
+Style/NumberedParameters:
+ Enabled: false
+Style/NumberedParametersLimit:
+ Enabled: false
+Style/ObjectThen:
+ Enabled: false
+Style/OpenStructUse:
+ Enabled: false
+Style/OperatorMethodCall:
+ Enabled: false
+Style/QuotedSymbols:
+ Enabled: false
Style/RedundantArgument:
Enabled: false
+Style/RedundantConstantBase:
+ Enabled: false
+Style/RedundantDoubleSplatHashBraces:
+ Enabled: false
+Style/RedundantEach:
+ Enabled: false
+Style/RedundantHeredocDelimiterQuotes:
+ Enabled: false
+Style/RedundantInitialize:
+ Enabled: false
+Style/RedundantSelfAssignmentBranch:
+ Enabled: false
+Style/RedundantStringEscape:
+ Enabled: false
+Style/SelectByRegexp:
+ Enabled: false
+Style/StringChars:
+ Enabled: false
Style/SwapValues:
Enabled: false
diff --git a/Gemfile b/Gemfile
index 4ffa786..add1873 100644
--- a/Gemfile
+++ b/Gemfile
@@ -14,30 +14,31 @@ def location_for(place_or_version, fake_version = nil)
end
group :development do
- gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
- gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
- gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
- gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
- gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
- gem "voxpupuli-puppet-lint-plugins", '~> 3.1', require: false
- gem "facterdb", '~> 1.18', require: false
- gem "metadata-json-lint", '>= 2.0.2', '< 4.0.0', require: false
- gem "puppetlabs_spec_helper", '>= 3.0.0', '< 5.0.0', require: false
- gem "rspec-puppet-facts", '~> 2.0', require: false
- gem "codecov", '~> 0.2', require: false
- gem "dependency_checker", '~> 0.2', require: false
- gem "parallel_tests", '~> 3.4', require: false
- gem "pry", '~> 0.10', require: false
- gem "simplecov-console", '~> 0.5', require: false
- gem "puppet-debugger", '~> 1.0', require: false
- gem "rubocop", '= 1.6.1', require: false
- gem "rubocop-performance", '= 1.9.1', require: false
- gem "rubocop-rspec", '= 2.0.1', require: false
- gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
+ gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+ gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+ gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+ gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+ gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+ gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
+ gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
+ gem "facterdb", '~> 1.18', require: false
+ gem "metadata-json-lint", '~> 3.0', require: false
+ gem "puppetlabs_spec_helper", '~> 6.0', require: false
+ gem "rspec-puppet-facts", '~> 2.0', require: false
+ gem "codecov", '~> 0.2', require: false
+ gem "dependency_checker", '~> 1.0.0', require: false
+ gem "parallel_tests", '= 3.12.1', require: false
+ gem "pry", '~> 0.10', require: false
+ gem "simplecov-console", '~> 0.5', require: false
+ gem "puppet-debugger", '~> 1.0', require: false
+ gem "rubocop", '= 1.48.1', require: false
+ gem "rubocop-performance", '= 1.16.0', require: false
+ gem "rubocop-rspec", '= 2.19.0', require: false
+ gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
end
group :system_tests do
- gem "puppet_litmus", '< 1.0.0', require: false, platforms: [:ruby]
- gem "serverspec", '~> 2.41', require: false
+ gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
+ gem "serverspec", '~> 2.41', require: false
end
puppet_version = ENV['PUPPET_GEM_VERSION']
diff --git a/REFERENCE.md b/REFERENCE.md
index 4ea2f78..7d2e19d 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -10,10 +10,11 @@
### Defined types
-* [`mollyguard::checks::ceph`](#mollyguard--checks--ceph): use this to add ceph check to molly-guard
-* [`mollyguard::checks::drbd`](#mollyguard--checks--drbd): use this to add drbd check to molly-guard
-* [`mollyguard::checks::libvirt`](#mollyguard--checks--libvirt): use this to add check for running libbvirt domains to molly-guard
-* [`mollyguard::checks::repmgr_postgres`](#mollyguard--checks--repmgr_postgres): use this to add repmgr-postgres check to molly-guard
+* [`mollyguard::checks::ceph`](#mollyguardchecksceph): use this to add ceph check to molly-guard
+* [`mollyguard::checks::drbd`](#mollyguardchecksdrbd): use this to add drbd check to molly-guard
+* [`mollyguard::checks::libvirt`](#mollyguardcheckslibvirt): use this to add check for running libbvirt domains to molly-guard
+* [`mollyguard::checks::rabbitmq`](#mollyguardchecksrabbitmq): use this to add drbd check to molly-guard
+* [`mollyguard::checks::repmgr_postgres`](#mollyguardchecksrepmgr_postgres): use this to add repmgr-postgres check to molly-guard
## Classes
@@ -25,14 +26,14 @@ mollyguard main class
The following parameters are available in the `mollyguard` class:
-* [`package_ensure`](#-mollyguard--package_ensure)
-* [`packages`](#-mollyguard--packages)
-* [`checks`](#-mollyguard--checks)
-* [`check_destination`](#-mollyguard--check_destination)
-* [`purge_checks`](#-mollyguard--purge_checks)
-* [`ignore_sys_checks`](#-mollyguard--ignore_sys_checks)
+* [`package_ensure`](#package_ensure)
+* [`packages`](#packages)
+* [`checks`](#checks)
+* [`check_destination`](#check_destination)
+* [`purge_checks`](#purge_checks)
+* [`ignore_sys_checks`](#ignore_sys_checks)
-##### `package_ensure`
+##### `package_ensure`
Data type: `String`
@@ -40,7 +41,7 @@ what to ensure for packages, defaults to 'present'
Default value: `'present'`
-##### `packages`
+##### `packages`
Data type: `Array`
@@ -48,11 +49,12 @@ Array of packages to install, defaults to ['molly-guard']
Default value: `['molly-guard']`
-##### `checks`
+##### `checks`
Data type: `Hash`
-Hash of additional checks to install, defaults to {}
+Hash of additional checks to install, defaults to {}.
+This parameter is hiera hash merged by default.
Example (hiera):
mollyguard::checks:
@@ -62,7 +64,7 @@ Example (hiera):
Default value: `{}`
-##### `check_destination`
+##### `check_destination`
Data type: `String`
@@ -71,15 +73,15 @@ defaults to '/etc/molly-guard/run.d'
Default value: `'/etc/molly-guard/run.d'`
-##### `purge_checks`
+##### `purge_checks`
Data type: `Boolean`
if true (default), we purge checks not managed with puppet
-Default value: `true`
+Default value: ``true``
-##### `ignore_sys_checks`
+##### `ignore_sys_checks`
Data type: `Array`
@@ -91,7 +93,7 @@ Default value: `['10-print-message', '30-query-hostname']`
## Defined types
-### `mollyguard::checks::ceph`
+### `mollyguard::checks::ceph`
use this to add ceph check to molly-guard
@@ -99,20 +101,20 @@ use this to add ceph check to molly-guard
The following parameters are available in the `mollyguard::checks::ceph` defined type:
-* [`destination`](#-mollyguard--checks--ceph--destination)
-* [`check_name`](#-mollyguard--checks--ceph--check_name)
-* [`sort`](#-mollyguard--checks--ceph--sort)
-* [`owner`](#-mollyguard--checks--ceph--owner)
-* [`group`](#-mollyguard--checks--ceph--group)
-* [`mode`](#-mollyguard--checks--ceph--mode)
+* [`destination`](#destination)
+* [`check_name`](#check_name)
+* [`sort`](#sort)
+* [`owner`](#owner)
+* [`group`](#group)
+* [`mode`](#mode)
-##### `destination`
+##### `destination`
Data type: `String`
directory where to put the check (mandatory)
-##### `check_name`
+##### `check_name`
Data type: `String`
@@ -120,7 +122,7 @@ name of the check (defaults to $title)
Default value: `$title`
-##### `sort`
+##### `sort`
Data type: `String`
@@ -128,7 +130,7 @@ sort parameter (defaults to '20')
Default value: `'20'`
-##### `owner`
+##### `owner`
Data type: `String`
@@ -136,7 +138,7 @@ owner of the check (file), defaults to 'root'
Default value: `'root'`
-##### `group`
+##### `group`
Data type: `String`
@@ -144,7 +146,7 @@ group of the check (file), defaults to 'root'
Default value: `'root'`
-##### `mode`
+##### `mode`
Data type: `String`
@@ -152,7 +154,7 @@ mode of the check (file), defaults to '0755'
Default value: `'0755'`
-### `mollyguard::checks::drbd`
+### `mollyguard::checks::drbd`
use this to add drbd check to molly-guard
@@ -160,20 +162,20 @@ use this to add drbd check to molly-guard
The following parameters are available in the `mollyguard::checks::drbd` defined type:
-* [`destination`](#-mollyguard--checks--drbd--destination)
-* [`check_name`](#-mollyguard--checks--drbd--check_name)
-* [`sort`](#-mollyguard--checks--drbd--sort)
-* [`owner`](#-mollyguard--checks--drbd--owner)
-* [`group`](#-mollyguard--checks--drbd--group)
-* [`mode`](#-mollyguard--checks--drbd--mode)
+* [`destination`](#destination)
+* [`check_name`](#check_name)
+* [`sort`](#sort)
+* [`owner`](#owner)
+* [`group`](#group)
+* [`mode`](#mode)
-##### `destination`
+##### `destination`
Data type: `String`
directory where to put the check (mandatory)
-##### `check_name`
+##### `check_name`
Data type: `String`
@@ -181,7 +183,7 @@ name of the check (defaults to $title)
Default value: `$title`
-##### `sort`
+##### `sort`
Data type: `String`
@@ -189,7 +191,7 @@ sort parameter (defaults to '20')
Default value: `'20'`
-##### `owner`
+##### `owner`
Data type: `String`
@@ -197,7 +199,7 @@ owner of the check (file), defaults to 'root'
Default value: `'root'`
-##### `group`
+##### `group`
Data type: `String`
@@ -205,7 +207,7 @@ group of the check (file), defaults to 'root'
Default value: `'root'`
-##### `mode`
+##### `mode`
Data type: `String`
@@ -213,7 +215,7 @@ mode of the check (file), defaults to '0755'
Default value: `'0755'`
-### `mollyguard::checks::libvirt`
+### `mollyguard::checks::libvirt`
use this to add check for running libbvirt domains
to molly-guard
@@ -222,21 +224,21 @@ to molly-guard
The following parameters are available in the `mollyguard::checks::libvirt` defined type:
-* [`destination`](#-mollyguard--checks--libvirt--destination)
-* [`check_name`](#-mollyguard--checks--libvirt--check_name)
-* [`sort`](#-mollyguard--checks--libvirt--sort)
-* [`owner`](#-mollyguard--checks--libvirt--owner)
-* [`group`](#-mollyguard--checks--libvirt--group)
-* [`mode`](#-mollyguard--checks--libvirt--mode)
-* [`options`](#-mollyguard--checks--libvirt--options)
+* [`destination`](#destination)
+* [`check_name`](#check_name)
+* [`sort`](#sort)
+* [`owner`](#owner)
+* [`group`](#group)
+* [`mode`](#mode)
+* [`options`](#options)
-##### `destination`
+##### `destination`
Data type: `String`
directory where to put the check (mandatory)
-##### `check_name`
+##### `check_name`
Data type: `String`
@@ -244,7 +246,7 @@ name of the check (defaults to $title)
Default value: `$title`
-##### `sort`
+##### `sort`
Data type: `String`
@@ -252,7 +254,7 @@ sort parameter (defaults to '20')
Default value: `'20'`
-##### `owner`
+##### `owner`
Data type: `String`
@@ -260,7 +262,7 @@ owner of the check (file), defaults to 'root'
Default value: `'root'`
-##### `group`
+##### `group`
Data type: `String`
@@ -268,7 +270,7 @@ group of the check (file), defaults to 'root'
Default value: `'root'`
-##### `mode`
+##### `mode`
Data type: `String`
@@ -276,7 +278,7 @@ mode of the check (file), defaults to '0755'
Default value: `'0755'`
-##### `options`
+##### `options`
Data type: `String`
@@ -288,7 +290,68 @@ if you do not care about shutdown instances.
Default value: `'--all'`
-### `mollyguard::checks::repmgr_postgres`
+### `mollyguard::checks::rabbitmq`
+
+use this to add drbd check to molly-guard
+
+#### Parameters
+
+The following parameters are available in the `mollyguard::checks::rabbitmq` defined type:
+
+* [`destination`](#destination)
+* [`check_name`](#check_name)
+* [`sort`](#sort)
+* [`owner`](#owner)
+* [`group`](#group)
+* [`mode`](#mode)
+
+##### `destination`
+
+Data type: `String`
+
+directory where to put the check (mandatory)
+
+##### `check_name`
+
+Data type: `String`
+
+name of the check (defaults to $title)
+
+Default value: `$title`
+
+##### `sort`
+
+Data type: `String`
+
+sort parameter (defaults to '20')
+
+Default value: `'20'`
+
+##### `owner`
+
+Data type: `String`
+
+owner of the check (file), defaults to 'root'
+
+Default value: `'root'`
+
+##### `group`
+
+Data type: `String`
+
+group of the check (file), defaults to 'root'
+
+Default value: `'root'`
+
+##### `mode`
+
+Data type: `String`
+
+mode of the check (file), defaults to '0755'
+
+Default value: `'0755'`
+
+### `mollyguard::checks::repmgr_postgres`
use this to add repmgr-postgres check to molly-guard
@@ -296,20 +359,20 @@ use this to add repmgr-postgres check to molly-guard
The following parameters are available in the `mollyguard::checks::repmgr_postgres` defined type:
-* [`destination`](#-mollyguard--checks--repmgr_postgres--destination)
-* [`check_name`](#-mollyguard--checks--repmgr_postgres--check_name)
-* [`sort`](#-mollyguard--checks--repmgr_postgres--sort)
-* [`owner`](#-mollyguard--checks--repmgr_postgres--owner)
-* [`group`](#-mollyguard--checks--repmgr_postgres--group)
-* [`mode`](#-mollyguard--checks--repmgr_postgres--mode)
+* [`destination`](#destination)
+* [`check_name`](#check_name)
+* [`sort`](#sort)
+* [`owner`](#owner)
+* [`group`](#group)
+* [`mode`](#mode)
-##### `destination`
+##### `destination`
Data type: `String`
directory where to put the check (mandatory)
-##### `check_name`
+##### `check_name`
Data type: `String`
@@ -317,7 +380,7 @@ name of the check (defaults to $title)
Default value: `$title`
-##### `sort`
+##### `sort`
Data type: `String`
@@ -325,7 +388,7 @@ sort parameter (defaults to '20')
Default value: `'20'`
-##### `owner`
+##### `owner`
Data type: `String`
@@ -333,7 +396,7 @@ owner of the check (file), defaults to 'root'
Default value: `'root'`
-##### `group`
+##### `group`
Data type: `String`
@@ -341,7 +404,7 @@ group of the check (file), defaults to 'root'
Default value: `'root'`
-##### `mode`
+##### `mode`
Data type: `String`
diff --git a/Rakefile b/Rakefile
index 0f8754e..74415a9 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,12 +1,11 @@
# frozen_string_literal: true
require 'bundler'
-require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
+require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
-require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
-require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
-require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
+require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator'
+require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'
def changelog_user
return unless Rake.application.top_level_tasks.include? "changelog"
@@ -44,7 +43,7 @@ end
PuppetLint.configuration.send('disable_relative')
-if Bundler.rubygems.find_name('github_changelog_generator').any?
+if Gem.loaded_specs.key? 'github_changelog_generator'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil?
config.user = "#{changelog_user}"
diff --git a/data/common.yaml b/data/common.yaml
new file mode 100644
index 0000000..c3c1a69
--- /dev/null
+++ b/data/common.yaml
@@ -0,0 +1,7 @@
+---
+# common settings for puppet-mollyguard
+#
+
+lookup_options:
+ mollyguard::checks:
+ merge: 'hash'
diff --git a/hiera.yaml b/hiera.yaml
new file mode 100644
index 0000000..66a2f56
--- /dev/null
+++ b/hiera.yaml
@@ -0,0 +1,10 @@
+---
+version: 5
+
+defaults:
+ datadir: 'data'
+ data_hash: 'yaml_data'
+
+hierarchy:
+ - name: 'common'
+ path: 'common.yaml'
diff --git a/manifests/checks/rabbitmq.pp b/manifests/checks/rabbitmq.pp
new file mode 100644
index 0000000..7fee78b
--- /dev/null
+++ b/manifests/checks/rabbitmq.pp
@@ -0,0 +1,32 @@
+#
+# use this to add drbd check to molly-guard
+#
+# @param destination
+# directory where to put the check (mandatory)
+# @param check_name
+# name of the check (defaults to $title)
+# @param sort
+# sort parameter (defaults to '20')
+# @param owner
+# owner of the check (file), defaults to 'root'
+# @param group
+# group of the check (file), defaults to 'root'
+# @param mode
+# mode of the check (file), defaults to '0755'
+#
+define mollyguard::checks::rabbitmq (
+ String $destination,
+ String $check_name = $title,
+ String $sort = '20',
+ String $owner = 'root',
+ String $group = 'root',
+ String $mode = '0755',
+) {
+ file { "${destination}/${sort}-${check_name}":
+ ensure => 'file',
+ owner => $owner,
+ group => $group,
+ mode => $mode,
+ content => epp('mollyguard/checks/check-rabbitmq.sh.epp', {}),
+ }
+}
diff --git a/manifests/init.pp b/manifests/init.pp
index 8eac8b4..906f3fe 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -5,7 +5,8 @@
# @param packages
# Array of packages to install, defaults to ['molly-guard']
# @param checks
-# Hash of additional checks to install, defaults to {}
+# Hash of additional checks to install, defaults to {}.
+# This parameter is hiera hash merged by default.
#
# Example (hiera):
# mollyguard::checks:
diff --git a/metadata.json b/metadata.json
index 63bfdd6..bee5dfe 100644
--- a/metadata.json
+++ b/metadata.json
@@ -41,7 +41,7 @@
"molly-guard",
"reboot"
],
- "pdk-version": "2.6.1",
- "template-url": "pdk-default#2.7.1",
- "template-ref": "tags/2.7.1-0-g9a16c87"
+ "pdk-version": "3.0.0",
+ "template-url": "pdk-default#3.0.0",
+ "template-ref": "tags/3.0.0-0-g056e50d"
}
diff --git a/pdk.yaml b/pdk.yaml
new file mode 100644
index 0000000..4bef4bd
--- /dev/null
+++ b/pdk.yaml
@@ -0,0 +1,2 @@
+---
+ignore: []
diff --git a/spec/defines/checks_rabbitmq_spec.rb b/spec/defines/checks_rabbitmq_spec.rb
new file mode 100644
index 0000000..4cf3027
--- /dev/null
+++ b/spec/defines/checks_rabbitmq_spec.rb
@@ -0,0 +1,58 @@
+
+require 'spec_helper'
+
+describe 'mollyguard::checks::rabbitmq' do
+ let :default_params do
+ { destination: '/tmp/test',
+ check_name: 'rabbit-molly-test',
+ sort: '20',
+ owner: 'root',
+ group: 'root',
+ mode: '0755' }
+ end
+
+ shared_examples 'mollyguard::checks::rabbitmq define' do
+ context 'it compiles with all dependencies' do
+ it { is_expected.to compile.with_all_deps }
+ end
+
+ it {
+ is_expected.to contain_file(params[:destination] + '/' + params[:sort] + '-' + params[:check_name])
+ .with_ensure('file')
+ .with_owner(params[:owner])
+ .with_group(params[:group])
+ .with_mode(params[:mode])
+ }
+ end
+
+ on_supported_os.each do |os, os_facts|
+ context "on #{os}" do
+ let(:facts) { os_facts }
+
+ context 'whith defaults' do
+ let(:title) { 'test-check' }
+ let :params do
+ default_params
+ end
+
+ it_behaves_like 'mollyguard::checks::rabbitmq define'
+ end
+
+ context 'whith non-defaults' do
+ let(:title) { 'another-check' }
+ let :params do
+ default_params.merge(
+ destination: '/tmp/somewhereelse',
+ check_name: 'another-blah-check',
+ sort: '42',
+ owner: 'someone',
+ group: 'someone',
+ mode: '4242',
+ )
+ end
+
+ it_behaves_like 'mollyguard::checks::rabbitmq define'
+ end
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 07db734..6820ceb 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -25,8 +25,8 @@
next unless File.exist?(f) && File.readable?(f) && File.size?(f)
begin
- default_facts.merge!(YAML.safe_load(File.read(f), [], [], true))
- rescue => e
+ default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true))
+ rescue StandardError => e
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
end
end
diff --git a/templates/checks/check-rabbitmq.sh.epp b/templates/checks/check-rabbitmq.sh.epp
new file mode 100644
index 0000000..a5d1b7d
--- /dev/null
+++ b/templates/checks/check-rabbitmq.sh.epp
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Managed with puppet (module mollyguard)
+#
+# This script checks if the local node is
+# set into drain mode or not
+#
+
+set -e
+
+MAINT=`rabbitmqctl status --formatter json|jq .is_under_maintenance`
+
+if [ "$MAINT" = 'true' ]; then
+ echo 'rabbitmq is in maintenance mode => OK'
+ exit 0
+else
+ echo
+ echo 'rabbitmq is not in maintenance mode'
+ echo 'use "rabbitmq-upgrade drain" to set maintenance mode first'
+ echo
+ read -p "Do you want to continue with '$MOLLYGUARD_CMD'? (yN) " answer
+ if [ "$answer" = "y" ] ; then
+ exit 0
+ else
+ exit 1
+ fi
+fi