diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 048d2b55..6aaa603f 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -124,7 +124,7 @@ If you have Ruby 2.x or want a specific version of Puppet,
you must set an environment variable such as:
```sh
-export PUPPET_VERSION="~> 5.5.6"
+export PUPPET_GEM_VERSION="~> 6.1.0"
```
You can install all needed gems for spec tests into the modules directory by
@@ -232,19 +232,21 @@ simple tests against it after applying the module. You can run this
with:
```sh
-BEAKER_setfile=debian10-x64 bundle exec rake beaker
+BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker
```
-You can replace the string `debian10` with any common operating system.
+You can replace the string `debian11` with any common operating system.
The following strings are known to work:
-* ubuntu1604
-* ubuntu1804
* ubuntu2004
-* debian9
-* debian10
+* ubuntu2204
+* debian11
* centos7
* centos8
+* centos9
+* almalinux8
+* almalinux9
+* fedora36
For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests).
diff --git a/.github/SECURITY.md b/.github/SECURITY.md
deleted file mode 100644
index cacadf22..00000000
--- a/.github/SECURITY.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Vox Pupuli Security Policy
-
-Our vulnerabilities reporting process is at https://voxpupuli.org/security/
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d08d05e8..7216724f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -4,87 +4,20 @@
name: CI
-on: pull_request
+on:
+ pull_request: {}
+ push:
+ branches:
+ - main
+ - master
concurrency:
- group: ${{ github.head_ref }}
+ group: ${{ github.ref_name }}
cancel-in-progress: true
jobs:
- setup_matrix:
- name: 'Setup Test Matrix'
- runs-on: ubuntu-latest
- timeout-minutes: 40
- 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 }}
- env:
- BUNDLE_WITHOUT: development:system_tests:release
- steps:
- - uses: actions/checkout@v2
- - name: Setup ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: '3.0'
- bundler-cache: true
- - name: Run static validations
- run: bundle exec rake validate lint check
- - name: Run rake rubocop
- run: bundle exec rake rubocop
- - name: Setup Test Matrix
- id: get-outputs
- run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false
-
- unit:
- needs: setup_matrix
- runs-on: ubuntu-latest
- timeout-minutes: 40
- strategy:
- fail-fast: false
- matrix:
- include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}}
- env:
- BUNDLE_WITHOUT: development:system_tests:release
- PUPPET_VERSION: "~> ${{ matrix.puppet }}.0"
- name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }})
- steps:
- - uses: actions/checkout@v2
- - name: Setup ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: ${{ matrix.ruby }}
- bundler-cache: true
- - name: Run tests
- run: bundle exec rake parallel_spec
-
- acceptance:
- needs: setup_matrix
- runs-on: ubuntu-latest
- env:
- BUNDLE_WITHOUT: development:test:release
- strategy:
- fail-fast: false
- matrix:
- include: ${{fromJson(needs.setup_matrix.outputs.github_action_test_matrix)}}
- name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }}
- steps:
- - uses: actions/checkout@v2
- - name: Setup ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: '3.0'
- bundler-cache: true
- - name: Run tests
- run: bundle exec rake beaker
- env:
- BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }}
- BEAKER_setfile: ${{ matrix.setfile.value }}
-
- tests:
- needs:
- - unit
- - acceptance
- runs-on: ubuntu-latest
- name: Test suite
- steps:
- - run: echo Test suite completed
+ puppet:
+ name: Puppet
+ uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
+ with:
+ pidfile_workaround: 'false'
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 664ba694..55324aa6 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -9,26 +9,14 @@ on:
tags:
- '*'
-env:
- BUNDLE_WITHOUT: development:test:system_tests
-
jobs:
- deploy:
- name: 'deploy to forge'
- runs-on: ubuntu-latest
- if: github.repository_owner == 'voxpupuli'
- steps:
- - name: Checkout repository
- uses: actions/checkout@v2
- - name: Setup Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: '2.7'
- bundler-cache: true
- - name: Build and Deploy
- env:
- # Configure secrets here:
- # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
- BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}'
- BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}'
- run: bundle exec rake module:push
+ release:
+ name: Release
+ uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v2
+ with:
+ allowed_owner: 'voxpupuli'
+ secrets:
+ # Configure secrets here:
+ # https://docs.github.com/en/actions/security-guides/encrypted-secrets
+ username: ${{ secrets.PUPPET_FORGE_USERNAME }}
+ api_key: ${{ secrets.PUPPET_FORGE_API_KEY }}
diff --git a/.gitignore b/.gitignore
index 9b95224c..84fd904c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,23 +1,23 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
-pkg/
-Gemfile.lock
-Gemfile.local
-vendor/
-.vendor/
-spec/fixtures/manifests/
-spec/fixtures/modules/
-.vagrant/
-.bundle/
-.ruby-version
-coverage/
-log/
-.idea/
-.dependencies/
-.librarian/
-Puppetfile.lock
+/pkg/
+/Gemfile.lock
+/Gemfile.local
+/vendor/
+/.vendor/
+/spec/fixtures/manifests/
+/spec/fixtures/modules/
+/.vagrant/
+/.bundle/
+/.ruby-version
+/coverage/
+/log/
+/.idea/
+/.dependencies/
+/.librarian/
+/Puppetfile.lock
*.iml
.*.sw?
-.yardoc/
-Guardfile
+/.yardoc/
+/Guardfile
diff --git a/.msync.yml b/.msync.yml
index 43966c2f..f46ee025 100644
--- a/.msync.yml
+++ b/.msync.yml
@@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
-modulesync_config_version: '4.2.0'
+modulesync_config_version: '7.3.0'
diff --git a/.pmtignore b/.pmtignore
index 65f50514..10b98306 100644
--- a/.pmtignore
+++ b/.pmtignore
@@ -1,37 +1,38 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
-docs/
-pkg/
-Gemfile
-Gemfile.lock
-Gemfile.local
-vendor/
-.vendor/
-spec/
-Rakefile
-.vagrant/
-.bundle/
-.ruby-version
-coverage/
-log/
-.idea/
-.dependencies/
-.github/
-.librarian/
-Puppetfile.lock
+/docs/
+/pkg/
+/Gemfile
+/Gemfile.lock
+/Gemfile.local
+/vendor/
+/.vendor/
+/spec/
+/Rakefile
+/.vagrant/
+/.bundle/
+/.ruby-version
+/coverage/
+/log/
+/.idea/
+/.dependencies/
+/.github/
+/.librarian/
+/Puppetfile.lock
*.iml
-.editorconfig
-.fixtures.yml
-.gitignore
-.msync.yml
-.overcommit.yml
-.pmtignore
-.rspec
-.rspec_parallel
-.rubocop.yml
-.sync.yml
+/.editorconfig
+/.fixtures.yml
+/.gitignore
+/.msync.yml
+/.overcommit.yml
+/.pmtignore
+/.rspec
+/.rspec_parallel
+/.rubocop.yml
+/.sync.yml
.*.sw?
-.yardoc/
-.yardopts
-Dockerfile
+/.yardoc/
+/.yardopts
+/Dockerfile
+/HISTORY.md
diff --git a/.puppet-lint.rc b/.puppet-lint.rc
new file mode 100644
index 00000000..dd8272c7
--- /dev/null
+++ b/.puppet-lint.rc
@@ -0,0 +1,3 @@
+--fail-on-warnings
+--no-parameter_documentation-check
+--no-parameter_types-check
diff --git a/.rubocop.yml b/.rubocop.yml
index 53ac1898..fded90cf 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -2,5 +2,6 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
+inherit_from: .rubocop_todo.yml
inherit_gem:
voxpupuli-test: rubocop.yml
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
new file mode 100644
index 00000000..9a195e25
--- /dev/null
+++ b/.rubocop_todo.yml
@@ -0,0 +1,60 @@
+# This configuration was generated by
+# `rubocop --auto-gen-config`
+# on 2024-02-20 13:57:00 UTC using RuboCop version 1.50.2.
+# The point is for the user to remove these configuration records
+# one by one as the offenses are removed from the code base.
+# Note that changes in the inspected code, or installation of new
+# versions of RuboCop, may require this file to be generated again.
+
+# Offense count: 4
+# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
+Lint/DuplicateBranch:
+ Exclude:
+ - 'lib/puppet/provider/cs_primitive/pcs.rb'
+ - 'spec/spec_helper_acceptance.rb'
+ - 'spec/spec_helper_corosync.rb'
+
+# Offense count: 1
+# Configuration parameters: CheckForMethodsWithNoSideEffects.
+Lint/Void:
+ Exclude:
+ - 'lib/puppet/type/cs_colocation.rb'
+
+# Offense count: 5
+# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
+# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
+Naming/MethodParameterName:
+ Exclude:
+ - 'lib/puppet/provider/cs_colocation/pcs.rb'
+ - 'lib/puppet/provider/cs_primitive/crm.rb'
+ - 'lib/puppet/provider/cs_primitive/pcs.rb'
+ - 'lib/puppet/type/cs_primitive.rb'
+ - 'lib/puppet_x/voxpupuli/corosync/provider/cib_helper.rb'
+
+# Offense count: 1
+# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
+# SupportedStyles: snake_case, normalcase, non_integer
+# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
+Naming/VariableNumber:
+ Exclude:
+ - 'lib/puppet_x/voxpupuli/corosync/provider/pcs.rb'
+
+# Offense count: 1
+# Configuration parameters: AllowSubject.
+RSpec/MultipleMemoizedHelpers:
+ Max: 10
+
+# Offense count: 4
+RSpec/RepeatedExampleGroupBody:
+ Exclude:
+ - 'spec/acceptance/basic_spec.rb'
+ - 'spec/acceptance/corosync_class_spec.rb'
+
+# Offense count: 2
+# This cop supports safe autocorrection (--autocorrect).
+# Configuration parameters: AllowedMethods, AllowedPatterns.
+# AllowedMethods: ==, equal?, eql?
+Style/ClassEqualityComparison:
+ Exclude:
+ - 'lib/puppet/provider/cs_primitive/crm.rb'
+ - 'lib/puppet/provider/cs_primitive/pcs.rb'
diff --git a/Dockerfile b/Dockerfile
index e3cf307f..8dd82d63 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -8,7 +8,7 @@ WORKDIR /opt/puppet
# https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39
RUN mkdir -p /etc/sv
-ARG PUPPET_VERSION="~> 6.0"
+ARG PUPPET_GEM_VERSION="~> 6.0"
ARG PARALLEL_TEST_PROCESSORS=4
# Cache gems
diff --git a/Gemfile b/Gemfile
index a39114ce..a4a3b204 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,13 +1,13 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
-source ENV['GEM_SOURCE'] || "https://rubygems.org"
+source ENV['GEM_SOURCE'] || 'https://rubygems.org'
group :test do
- gem 'voxpupuli-test', '~> 2.5', :require => false
+ gem 'voxpupuli-test', '~> 7.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
- gem 'puppet_metadata', '~> 1.0', :require => false
+ gem 'puppet_metadata', '~> 3.5', :require => false
end
group :development do
@@ -16,19 +16,17 @@ group :development do
end
group :system_tests do
- gem 'voxpupuli-acceptance', '~> 1.0', :require => false
+ gem 'voxpupuli-acceptance', '~> 3.0', :require => false
end
group :release do
- gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5'
- gem 'voxpupuli-release', '>= 1.0.2', :require => false
- gem 'puppet-strings', '>= 2.2', :require => false
+ gem 'voxpupuli-release', '~> 3.0', :require => false
end
gem 'rake', :require => false
gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test]
-puppetversion = ENV['PUPPET_VERSION'] || '>= 6.0'
+puppetversion = ENV['PUPPET_GEM_VERSION'] || '~> 7.24'
gem 'puppet', puppetversion, :require => false, :groups => [:test]
# vim: syntax=ruby
diff --git a/REFERENCE.md b/REFERENCE.md
index 1260fdb2..42addf42 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -1,44 +1,45 @@
# Reference
+
## Table of Contents
-**Classes**
+### Classes
* [`corosync`](#corosync): Configures the Pacemaker+Corosync stack to provide high-availability.
-* [`corosync::params`](#corosyncparams): Configures sane defaults based on the operating system.
-* [`corosync::qdevice`](#corosyncqdevice): Performs basic initial configuration of the qdevice daemon on a node.
-* [`corosync::reprobe`](#corosyncreprobe): Triggers re-probe for changes any of the native cs_* types.
+* [`corosync::params`](#corosync--params): Configures sane defaults based on the operating system.
+* [`corosync::qdevice`](#corosync--qdevice): Performs basic initial configuration of the qdevice daemon on a node.
+* [`corosync::reprobe`](#corosync--reprobe): Triggers re-probe for changes any of the native cs_* types.
-**Defined types**
+### Defined types
-* [`corosync::service`](#corosyncservice): Declare services within /etc/corosync/service.d/ (Corosync 1.x)
+* [`corosync::service`](#corosync--service): Declare services within /etc/corosync/service.d/ (Corosync 1.x)
-**Resource types**
+### Resource types
* [`cs_clone`](#cs_clone): Type for manipulating corosync/pacemaker resource clone. More information on Corosync/Pacemaker colocation can be found here: * http://www.c
* [`cs_colocation`](#cs_colocation): Type for manipulating corosync/pacemaker colocation. Colocation is the grouping together of a set of primitives so that they travel together
-* [`cs_commit`](#cs_commit): Final commit statement which triggers the syncronous application of all primitive changes which reference this CIB. Do not generate more than
-* [`cs_group`](#cs_group): Type for manipulating Corosync/Pacemkaer group entries. Groups are a set or resources (primitives) that need to be grouped together. More in
+* [`cs_commit`](#cs_commit): Final commit statement which triggers the synchronous application of all primitive changes which reference this CIB. Do not generate more tha
+* [`cs_group`](#cs_group): Type for manipulating Corosync/Pacemaker group entries. Groups are a set or resources (primitives) that need to be grouped together. More in
* [`cs_location`](#cs_location): Type for manipulating corosync/pacemaker resource location. More information on Corosync/Pacemaker colocation can be found here: * http://ww
-* [`cs_order`](#cs_order): Type for manipulating Corosync/Pacemkaer ordering entries. Order entries are another type of constraint that can be put on sets of primitive
+* [`cs_order`](#cs_order): Type for manipulating Corosync/Pacemaker ordering entries. Order entries are another type of constraint that can be put on sets of primitive
* [`cs_primitive`](#cs_primitive): Type for manipulating Corosync/Pacemaker primitives. Primitives are probably the most important building block when creating highly availabl
-* [`cs_property`](#cs_property): Type for manipulating corosync/pacemaker configuration properties. Besides the configuration file that is managed by the module the contains
+* [`cs_property`](#cs_property): Type for manipulating corosync/pacemaker configuration properties. Besides the configuration file that is managed by the module the contains
* [`cs_rsc_defaults`](#cs_rsc_defaults): Type for manipulating corosync/pacemaker global defaults for resource options. The type is pretty simple interface for setting key/value pair
-* [`cs_shadow`](#cs_shadow): cs_shadow resources represent a Corosync shadow CIB. Any corosync resources defined with 'cib' set to the title of a cs_shadow resource will
+* [`cs_shadow`](#cs_shadow): cs_shadow resources represent a Corosync shadow CIB. Any corosync resources defined with 'cib' set to the title of a cs_shadow resource will
-**Data types**
+### Data types
-* [`Corosync::ArrayRing`](#corosyncarrayring):
-* [`Corosync::CryptoCipher`](#corosynccryptocipher): Defines the allowed cipher types for secure corosync communication
-* [`Corosync::CryptoHash`](#corosynccryptohash):
-* [`Corosync::IpStringIp`](#corosyncipstringip):
-* [`Corosync::QuorumAlgorithm`](#corosyncquorumalgorithm):
-* [`Corosync::Syslogpriority`](#corosyncsyslogpriority):
+* [`Corosync::ArrayRing`](#Corosync--ArrayRing)
+* [`Corosync::CryptoCipher`](#Corosync--CryptoCipher): Defines the allowed cipher types for secure corosync communication
+* [`Corosync::CryptoHash`](#Corosync--CryptoHash)
+* [`Corosync::IpStringIp`](#Corosync--IpStringIp)
+* [`Corosync::QuorumAlgorithm`](#Corosync--QuorumAlgorithm)
+* [`Corosync::Syslogpriority`](#Corosync--Syslogpriority)
## Classes
-### corosync
+### `corosync`
This class will set up corosync for use by the Puppet Enterprise console to
facilitate an active/standby configuration for high availability. It is
@@ -68,53 +69,125 @@ class { 'corosync':
#### Parameters
-The following parameters are available in the `corosync` class.
-
-##### `enable_secauth`
+The following parameters are available in the `corosync` class:
+
+* [`enable_secauth`](#-corosync--enable_secauth)
+* [`authkey_source`](#-corosync--authkey_source)
+* [`authkey`](#-corosync--authkey)
+* [`crypto_hash`](#-corosync--crypto_hash)
+* [`crypto_cipher`](#-corosync--crypto_cipher)
+* [`threads`](#-corosync--threads)
+* [`bind_address`](#-corosync--bind_address)
+* [`port`](#-corosync--port)
+* [`multicast_address`](#-corosync--multicast_address)
+* [`unicast_addresses`](#-corosync--unicast_addresses)
+* [`force_online`](#-corosync--force_online)
+* [`check_standby`](#-corosync--check_standby)
+* [`log_timestamp`](#-corosync--log_timestamp)
+* [`log_file`](#-corosync--log_file)
+* [`log_file_name`](#-corosync--log_file_name)
+* [`debug`](#-corosync--debug)
+* [`log_stderr`](#-corosync--log_stderr)
+* [`syslog_priority`](#-corosync--syslog_priority)
+* [`log_function_name`](#-corosync--log_function_name)
+* [`rrp_mode`](#-corosync--rrp_mode)
+* [`netmtu`](#-corosync--netmtu)
+* [`ttl`](#-corosync--ttl)
+* [`vsftype`](#-corosync--vsftype)
+* [`package_corosync`](#-corosync--package_corosync)
+* [`package_pacemaker`](#-corosync--package_pacemaker)
+* [`package_fence_agents`](#-corosync--package_fence_agents)
+* [`packageopts_corosync`](#-corosync--packageopts_corosync)
+* [`packageopts_crmsh`](#-corosync--packageopts_crmsh)
+* [`packageopts_pacemaker`](#-corosync--packageopts_pacemaker)
+* [`packageopts_pcs`](#-corosync--packageopts_pcs)
+* [`packageopts_fence_agents`](#-corosync--packageopts_fence_agents)
+* [`ensure_corosync`](#-corosync--ensure_corosync)
+* [`ensure_crmsh`](#-corosync--ensure_crmsh)
+* [`ensure_pacemaker`](#-corosync--ensure_pacemaker)
+* [`ensure_pcs`](#-corosync--ensure_pcs)
+* [`ensure_fence_agents`](#-corosync--ensure_fence_agents)
+* [`set_votequorum`](#-corosync--set_votequorum)
+* [`votequorum_expected_votes`](#-corosync--votequorum_expected_votes)
+* [`quorum_members`](#-corosync--quorum_members)
+* [`quorum_members_ids`](#-corosync--quorum_members_ids)
+* [`quorum_members_names`](#-corosync--quorum_members_names)
+* [`token`](#-corosync--token)
+* [`token_retransmits_before_loss_const`](#-corosync--token_retransmits_before_loss_const)
+* [`compatibility`](#-corosync--compatibility)
+* [`enable_corosync_service`](#-corosync--enable_corosync_service)
+* [`manage_corosync_service`](#-corosync--manage_corosync_service)
+* [`enable_pacemaker_service`](#-corosync--enable_pacemaker_service)
+* [`manage_pacemaker_service`](#-corosync--manage_pacemaker_service)
+* [`enable_pcsd_service`](#-corosync--enable_pcsd_service)
+* [`manage_pcsd_service`](#-corosync--manage_pcsd_service)
+* [`manage_pcsd_auth`](#-corosync--manage_pcsd_auth)
+* [`manage_pcsd_auth_node`](#-corosync--manage_pcsd_auth_node)
+* [`sensitive_hacluster_password`](#-corosync--sensitive_hacluster_password)
+* [`sensitive_hacluster_hash`](#-corosync--sensitive_hacluster_hash)
+* [`manage_quorum_device`](#-corosync--manage_quorum_device)
+* [`quorum_device_host`](#-corosync--quorum_device_host)
+* [`quorum_device_algorithm`](#-corosync--quorum_device_algorithm)
+* [`package_quorum_device`](#-corosync--package_quorum_device)
+* [`sensitive_quorum_device_password`](#-corosync--sensitive_quorum_device_password)
+* [`cluster_name`](#-corosync--cluster_name)
+* [`join`](#-corosync--join)
+* [`consensus`](#-corosync--consensus)
+* [`ip_version`](#-corosync--ip_version)
+* [`clear_node_high_bit`](#-corosync--clear_node_high_bit)
+* [`max_messages`](#-corosync--max_messages)
+* [`test_corosync_config`](#-corosync--test_corosync_config)
+* [`test_corosync_config_cmd`](#-corosync--test_corosync_config_cmd)
+* [`watchdog_device`](#-corosync--watchdog_device)
+* [`provider`](#-corosync--provider)
+* [`config_validate_cmd`](#-corosync--config_validate_cmd)
+* [`pcs_version`](#-corosync--pcs_version)
+
+##### `enable_secauth`
Data type: `Boolean`
Controls corosync's ability to authenticate and encrypt multicast messages.
-Default value: $corosync::params::enable_secauth
+Default value: `$corosync::params::enable_secauth`
-##### `authkey_source`
+##### `authkey_source`
Data type: `Enum['file', 'string']`
Allows to use either a file or a string as a authkey.
-Default value: $corosync::params::authkey_source
+Default value: `$corosync::params::authkey_source`
-##### `authkey`
+##### `authkey`
-Data type: `Variant[Stdlib::Absolutepath,Stdlib::Base64]`
+Data type: `Variant[Stdlib::Filesource,Stdlib::Base64]`
Specifies the path to the CA which is used to sign Corosync's certificate if
authkey_source is 'file' or a base64 encoded version of the actual authkey
if 'string' is used instead.
-Default value: $corosync::params::authkey
+Default value: `$corosync::params::authkey`
-##### `crypto_hash`
+##### `crypto_hash`
Data type: `Corosync::CryptoHash`
Hashing algorithm used by corosync for intra-cluster communication. Valid
values are none, md5, sha1, sha256, sha384, and sha512
-Default value: 'sha1'
+Default value: `'sha1'`
-##### `crypto_cipher`
+##### `crypto_cipher`
Data type: `Corosync::CryptoCipher`
Encryption cipher used by corosync for intra-cluster communication. Valid
values are none, aes256, aes192, aes128, and 3des
-Default value: 'aes256'
+Default value: `'aes256'`
-##### `threads`
+##### `threads`
Data type: `Optional[Integer]`
@@ -124,16 +197,16 @@ threads.
Default value: `undef`
-##### `bind_address`
+##### `bind_address`
Data type: `Corosync::IpStringIp`
The ip address we are going to bind the corosync daemon too.
Can be specified as an array to have multiple rings.
-Default value: $corosync::params::bind_address
+Default value: `$corosync::params::bind_address`
-##### `port`
+##### `port`
Data type: `Optional[Variant[Stdlib::Port, Array[Stdlib::Port]]]`
@@ -141,9 +214,9 @@ The UDP port that corosync will use to do its multicast communication. Be
aware that corosync used this defined port plus minus one.
Can be specified as an array to have multiple rings.
-Default value: $corosync::params::port
+Default value: `$corosync::params::port`
-##### `multicast_address`
+##### `multicast_address`
Data type: `Optional[Corosync::IpStringIp]`
@@ -154,56 +227,57 @@ Can be specified as an array to have multiple rings (multicast only).
Default value: `undef`
-##### `unicast_addresses`
+##### `unicast_addresses`
Data type: `Optional[Array]`
An array of IP addresses that make up the cluster's members. These are
-use if you are able to use multicast on your network and instead opt for
-the udpu transport. You need a relatively recent version of Corosync to
+used if you are not able to use multicast on your network and instead opt
+for the udpu transport. You need a relatively recent version of Corosync to
make this possible.
You can also have an array of arrays to have multiple rings. In that case,
each subarray matches a host IP addresses.
+As of Corosync 3 knet is the new default which also does not use multicast.
Default value: `undef`
-##### `force_online`
+##### `force_online`
Data type: `Boolean`
Boolean parameter specifying whether to force nodes that have been put
in standby back online.
-Default value: $corosync::params::force_online
+Default value: `$corosync::params::force_online`
-##### `check_standby`
+##### `check_standby`
Data type: `Boolean`
Boolean parameter specifying whether puppet should return an error log
message if a node is in standby. Useful for monitoring node state.
-Default value: $corosync::params::check_standby
+Default value: `$corosync::params::check_standby`
-##### `log_timestamp`
+##### `log_timestamp`
Data type: `Boolean`
Boolean parameter specifying whether a timestamp should be placed on all
log messages.
-Default value: $corosync::params::log_timestamp
+Default value: `$corosync::params::log_timestamp`
-##### `log_file`
+##### `log_file`
Data type: `Boolean`
Boolean parameter specifying whether Corosync should produce debug
output in a logfile.
-Default value: $corosync::params::log_file
+Default value: `$corosync::params::log_file`
-##### `log_file_name`
+##### `log_file_name`
Data type: `Optional[Stdlib::Absolutepath]`
@@ -212,43 +286,43 @@ above) is true.
Default value: `undef`
-##### `debug`
+##### `debug`
Data type: `Boolean`
Boolean parameter specifying whether Corosync should produce debug
output in its logs.
-Default value: $corosync::params::debug
+Default value: `$corosync::params::debug`
-##### `log_stderr`
+##### `log_stderr`
Data type: `Boolean`
Boolean parameter specifying whether Corosync should log errors to
stderr.
-Default value: $corosync::params::log_stderr
+Default value: `$corosync::params::log_stderr`
-##### `syslog_priority`
+##### `syslog_priority`
Data type: `Corosync::SyslogPriority`
String parameter specifying the minimal log level for Corosync syslog
messages. Allowed values: debug|info|notice|warning|err|emerg.
-Default value: $corosync::params::syslog_priority
+Default value: `$corosync::params::syslog_priority`
-##### `log_function_name`
+##### `log_function_name`
Data type: `Boolean`
Boolean parameter specifying whether Corosync should log called function
names to.
-Default value: $corosync::params::log_function_name
+Default value: `$corosync::params::log_function_name`
-##### `rrp_mode`
+##### `rrp_mode`
Data type: `Optional[Enum['none', 'active', 'passive']]`
@@ -256,7 +330,7 @@ Mode of redundant ring. May be none, active, or passive.
Default value: `undef`
-##### `netmtu`
+##### `netmtu`
Data type: `Optional[Integer]`
@@ -264,7 +338,7 @@ This specifies the network maximum transmit unit.
Default value: `undef`
-##### `ttl`
+##### `ttl`
Data type: `Optional[Integer[0,255]]`
@@ -272,7 +346,7 @@ Time To Live.
Default value: `undef`
-##### `vsftype`
+##### `vsftype`
Data type: `Optional[Enum['ykd', 'none']]`
@@ -280,43 +354,23 @@ Virtual synchrony filter type.
Default value: `undef`
-##### `package_corosync`
+##### `package_corosync`
Data type: `Boolean`
Define if package corosync should be managed.
-Default value: $corosync::params::package_corosync
-
-##### `package_crmsh`
-
-Data type: `Boolean`
-
-Define if package crmsh should be managed.
-Default (Debian): true
-Default: false
-
-Default value: $corosync::params::package_crmsh
+Default value: `$corosync::params::package_corosync`
-##### `package_pacemaker`
+##### `package_pacemaker`
Data type: `Boolean`
Define if package pacemaker should be managed.
-Default value: $corosync::params::package_pacemaker
-
-##### `package_pcs`
-
-Data type: `Boolean`
-
-Define if package pcs should be managed.
-Default (Red Hat based): true
-Default (otherwise): false
+Default value: `$corosync::params::package_pacemaker`
-Default value: $corosync::params::package_pcs
-
-##### `package_fence_agents`
+##### `package_fence_agents`
Data type: `Boolean`
@@ -324,99 +378,99 @@ Define if package fence-agents should be managed.
Default (Red Hat based): true
Default (otherwise): false
-Default value: $corosync::params::package_fence_agents
+Default value: `false`
-##### `packageopts_corosync`
+##### `packageopts_corosync`
Data type: `Optional[Array[String[1]]]`
Additional install-options for the corosync package resource.
Default: undef
-Default value: $corosync::params::package_install_options
+Default value: `$corosync::params::package_install_options`
-##### `packageopts_crmsh`
+##### `packageopts_crmsh`
Data type: `Optional[Array[String[1]]]`
Additional install-options for the crmsh package resource.
Default: undef
-Default value: $corosync::params::package_install_options
+Default value: `$corosync::params::package_install_options`
-##### `packageopts_pacemaker`
+##### `packageopts_pacemaker`
Data type: `Optional[Array[String[1]]]`
Additional install-options for the pacemaker package resource.
Default: undef
-Default value: $corosync::params::package_install_options
+Default value: `$corosync::params::package_install_options`
-##### `packageopts_pcs`
+##### `packageopts_pcs`
Data type: `Optional[Array[String[1]]]`
Additional install-options for the pcs package resource.
Default: undef
-Default value: $corosync::params::package_install_options
+Default value: `$corosync::params::package_install_options`
-##### `packageopts_fence_agents`
+##### `packageopts_fence_agents`
Data type: `Optional[Array[String[1]]]`
Additional install-options for the pcs package resource.
Default: undef
-Default value: $corosync::params::package_install_options
+Default value: `$corosync::params::package_install_options`
-##### `version_corosync`
+##### `ensure_corosync`
Data type: `String[1]`
Define what version of the corosync package should be installed.
Default: 'present'
-Default value: $corosync::params::version_corosync
+Default value: `$corosync::params::ensure_corosync`
-##### `version_crmsh`
+##### `ensure_crmsh`
Data type: `String[1]`
Define what version of the crmsh package should be installed.
Default: 'present'
-Default value: $corosync::params::version_crmsh
+Default value: `$corosync::params::ensure_crmsh`
-##### `version_pacemaker`
+##### `ensure_pacemaker`
Data type: `String[1]`
Define what version of the pacemaker package should be installed.
Default: 'present'
-Default value: $corosync::params::version_pacemaker
+Default value: `$corosync::params::ensure_pacemaker`
-##### `version_pcs`
+##### `ensure_pcs`
Data type: `String[1]`
Define what version of the pcs package should be installed.
Default: 'present'
-Default value: $corosync::params::version_pcs
+Default value: `$corosync::params::ensure_pcs`
-##### `version_fence_agents`
+##### `ensure_fence_agents`
Data type: `String[1]`
Define what version of the fence-agents-all package should be installed.
Default: 'present'
-Default value: $corosync::params::version_fence_agents
+Default value: `$corosync::params::ensure_fence_agents`
-##### `set_votequorum`
+##### `set_votequorum`
Data type: `Boolean`
@@ -425,9 +479,9 @@ Default (Red Hat based): true
Default (Ubuntu >= 14.04): true
Default (otherwise): false
-Default value: $corosync::params::set_votequorum
+Default value: `$corosync::params::set_votequorum`
-##### `votequorum_expected_votes`
+##### `votequorum_expected_votes`
Data type: `Optional[Integer]`
@@ -436,7 +490,7 @@ derived from the number of nodes.
Default value: `undef`
-##### `quorum_members`
+##### `quorum_members`
Data type: `Array`
@@ -445,9 +499,9 @@ is set to true.
You can also have an array of arrays to have multiple rings. In that case,
each subarray matches a member IP addresses.
-Default value: ['localhost']
+Default value: `['localhost']`
-##### `quorum_members_ids`
+##### `quorum_members_ids`
Data type: `Optional[Array]`
@@ -457,7 +511,7 @@ Should be used only with the quorum_members parameter.
Default value: `undef`
-##### `quorum_members_names`
+##### `quorum_members_names`
Data type: `Optional[Array]`
@@ -466,7 +520,7 @@ define IP addresses in quorum_members.
Default value: `undef`
-##### `token`
+##### `token`
Data type: `Optional[Integer]`
@@ -474,7 +528,7 @@ Time (in ms) to wait for a token
Default value: `undef`
-##### `token_retransmits_before_loss_const`
+##### `token_retransmits_before_loss_const`
Data type: `Optional[Integer]`
@@ -482,7 +536,7 @@ How many token retransmits before forming a new configuration.
Default value: `undef`
-##### `compatibility`
+##### `compatibility`
Data type: `Optional[String]`
@@ -491,32 +545,32 @@ backward compatibility. This sets that.
Default value: `undef`
-##### `enable_corosync_service`
+##### `enable_corosync_service`
Data type: `Boolean`
Whether the module should enable the corosync service.
-Default value: $corosync::params::enable_corosync_service
+Default value: `$corosync::params::enable_corosync_service`
-##### `manage_corosync_service`
+##### `manage_corosync_service`
Data type: `Boolean`
Whether the module should try to manage the corosync service. If set to
false, the service will need to be specified in the catalog elsewhere.
-Default value: $corosync::params::manage_corosync_service
+Default value: `$corosync::params::manage_corosync_service`
-##### `enable_pacemaker_service`
+##### `enable_pacemaker_service`
Data type: `Boolean`
Whether the module should enable the pacemaker service.
-Default value: $corosync::params::enable_pacemaker_service
+Default value: `$corosync::params::enable_pacemaker_service`
-##### `manage_pacemaker_service`
+##### `manage_pacemaker_service`
Data type: `Boolean`
@@ -525,17 +579,17 @@ Default (Red Hat based >= 7): true
Default (Ubuntu >= 14.04): true
Default (otherwise): false
-Default value: $corosync::params::manage_pacemaker_service
+Default value: `$corosync::params::manage_pacemaker_service`
-##### `enable_pcsd_service`
+##### `enable_pcsd_service`
Data type: `Boolean`
Whether the module should enable the pcsd service.
-Default value: $corosync::params::enable_pcsd_service
+Default value: `$corosync::params::enable_pcsd_service`
-##### `manage_pcsd_service`
+##### `manage_pcsd_service`
Data type: `Boolean`
@@ -545,7 +599,7 @@ interface.
Default value: `false`
-##### `manage_pcsd_auth`
+##### `manage_pcsd_auth`
Data type: `Boolean`
@@ -558,7 +612,7 @@ $sensitive_hacluster_password is mandatory if this parameter is set.
Default value: `false`
-##### `manage_pcsd_auth_node`
+##### `manage_pcsd_auth_node`
Data type: `Enum['first','last']`
@@ -567,9 +621,9 @@ work. Note that only one node 'should' do the work and nodes are chosen by
matching local facts to the contents of quorum_members. When
manage_pcsd_auth is disabled this parameter has no effect.
-Default value: 'first'
+Default value: `'first'`
-##### `sensitive_hacluster_password`
+##### `sensitive_hacluster_password`
Data type: `Optional[Sensitive[String]]`
@@ -580,7 +634,7 @@ to authorize all nodes.
Default value: `undef`
-##### `sensitive_hacluster_hash`
+##### `sensitive_hacluster_hash`
Data type: `Optional[Sensitive[String]]`
@@ -590,7 +644,7 @@ be used to set the password for the hacluster user on each node.
Default value: `undef`
-##### `manage_quorum_device`
+##### `manage_quorum_device`
Data type: `Boolean`
@@ -602,7 +656,7 @@ nodes have failed.
Default value: `false`
-##### `quorum_device_host`
+##### `quorum_device_host`
Data type: `Optional[Stdlib::Fqdn]`
@@ -611,9 +665,9 @@ mandatory when manage_quorum_device is true.
Default value: `undef`
-##### `quorum_device_algorithm`
+##### `quorum_device_algorithm`
-Data type: `Optional[Corosync::QuorumAlgorithm]`
+Data type: `Corosync::QuorumAlgorithm`
There are currently two algorithms the quorum device can utilize to
determine how its vote should be allocated; Fifty-fifty split and
@@ -621,18 +675,18 @@ last-man-standing. See the
[corosync-qdevice man page](https://www.systutorials.com/docs/linux/man/8-corosync-qdevice/)
for details.
-Default value: 'ffsplit'
+Default value: `'ffsplit'`
-##### `package_quorum_device`
+##### `package_quorum_device`
Data type: `Optional[String]`
The name of the package providing the quorum device functionality. This
parameter is mandatory if manage_quorum_device is true.
-Default value: $corosync::params::package_quorum_device
+Default value: `$corosync::params::package_quorum_device`
-##### `sensitive_quorum_device_password`
+##### `sensitive_quorum_device_password`
Data type: `Optional[Sensitive[String]]`
@@ -641,7 +695,7 @@ This parameter is mandatory if manage_quorum_device is true.
Default value: `undef`
-##### `cluster_name`
+##### `cluster_name`
Data type: `Optional[String[1]]`
@@ -650,7 +704,7 @@ generating of multicast address.
Default value: `undef`
-##### `join`
+##### `join`
Data type: `Optional[Integer]`
@@ -659,7 +713,7 @@ in the membership protocol.
Default value: `undef`
-##### `consensus`
+##### `consensus`
Data type: `Optional[Integer]`
@@ -671,7 +725,7 @@ consensus value.
Default value: `undef`
-##### `ip_version`
+##### `ip_version`
Data type: `Optional[String[1]]`
@@ -686,7 +740,7 @@ Default (if unspecified) is ipv6-4 for knet and udpu transports and ipv4 for udp
Default value: `undef`
-##### `clear_node_high_bit`
+##### `clear_node_high_bit`
Data type: `Optional[Enum['yes', 'no']]`
@@ -701,7 +755,7 @@ only a subset of the cluster (for example during a rolling upgrade).
Default value: `undef`
-##### `max_messages`
+##### `max_messages`
Data type: `Optional[Integer]`
@@ -711,20 +765,57 @@ to 256000 / netmtu to prevent overflow of the kernel transmit buffers.
Default value: `undef`
-##### `test_corosync_config`
+##### `test_corosync_config`
Data type: `Boolean`
Whether we should test new configuration files with `corosync -t`.
(requires corosync 2.3.4)
-Default value: $corosync::params::test_corosync_config
+Default value: `$corosync::params::test_corosync_config`
+
+##### `test_corosync_config_cmd`
+
+Override the standard config_validate_cmd which only works for corosync 2.x.
+
+##### `watchdog_device`
+
+Data type: `Optional[Variant[Stdlib::Absolutepath, Enum['off']]]`
+
+Watchdog device to use, for example '/dev/watchdog' or 'off'.
+Its presence (or lack thereof) shifted with corosync versions.
+
+Default value: `undef`
+
+##### `provider`
+
+Data type: `Enum['pcs', 'crm']`
+
+What command line utility provides corosync configuration capabilities.
+
+Default value: `'pcs'`
+
+##### `config_validate_cmd`
+
+Data type: `String[1]`
+
-### corosync::params
+
+Default value: `'/usr/bin/env COROSYNC_MAIN_CONFIG_FILE=% /usr/sbin/corosync -t'`
+
+##### `pcs_version`
+
+Data type: `String`
+
+
+
+Default value: `''`
+
+### `corosync::params`
Configures sane defaults based on the operating system.
-### corosync::qdevice
+### `corosync::qdevice`
This class performs the configuration of the qdevice daemon on a target node.
Note that this requires corosync 2.x and must never be deployed on a node
@@ -733,7 +824,7 @@ correct firewall ports for both pcs, and the actual quorum device as shown in
the included example.
* **See also**
-https://www.systutorials.com/docs/linux/man/8-corosync-qnetd/
+ * https://www.systutorials.com/docs/linux/man/8-corosync-qnetd/
#### Examples
@@ -773,35 +864,47 @@ firewalld_service { 'high-availability':
#### Parameters
-The following parameters are available in the `corosync::qdevice` class.
+The following parameters are available in the `corosync::qdevice` class:
-##### `sensitive_hacluster_hash`
+* [`sensitive_hacluster_hash`](#-corosync--qdevice--sensitive_hacluster_hash)
+* [`package_pcs`](#-corosync--qdevice--package_pcs)
+* [`package_corosync_qnetd`](#-corosync--qdevice--package_corosync_qnetd)
+* [`provider`](#-corosync--qdevice--provider)
-Data type: `Sensitive[String]`
+##### `sensitive_hacluster_hash`
+
+Data type: `Optional[Sensitive[String]]`
-The password hash for the hacluster user on this quorum device node. This
-is currently a mandatory parameter because pcsd must be used to perform the
+The password hash for the hacluster user on this quorum device node. If
+omitted, you must create the hacluster user and haclient group yourself.
+This user is required because pcsd must be used to perform the
quorum node configuration.
Default value: `undef`
-##### `package_pcs`
+##### `package_pcs`
Data type: `String[1]`
Name of the PCS package on this system.
-Default value: 'pcs'
+Default value: `'pcs'`
-##### `package_corosync_qnetd`
+##### `package_corosync_qnetd`
Data type: `String[1]`
Name of the corosync qnetd package for this system.
-Default value: 'corosync-qnetd'
+Default value: `'corosync-qnetd'`
-### corosync::reprobe
+##### `provider`
+
+Data type: `String`
+
+What command line utility provides corosync configuration capabilities.
+
+### `corosync::reprobe`
Include this class to reprobe the corosync cluster when there are changes in
any of the native cs_* types. Useful for multi-node provisioning when the
@@ -820,7 +923,7 @@ include corosync::reprobe
## Defined types
-### corosync::service
+### `corosync::service`
Models a Corosync service. Corosync services are plugins that provide
functionality for monitoring cluster resources. One of the most common
@@ -847,9 +950,12 @@ corosync::service { 'pacemaker':
#### Parameters
-The following parameters are available in the `corosync::service` defined type.
+The following parameters are available in the `corosync::service` defined type:
+
+* [`name`](#-corosync--service--name)
+* [`version`](#-corosync--service--version)
-##### `name`
+##### `name`
Data type: `String`
@@ -857,7 +963,7 @@ The namevar in this type is the title you give it when you define a resource
instance. It is used for a handful of purposes; defining the name of the
config file and the name defined inside the file itself.
-##### `version`
+##### `version`
Data type: `String[1]`
@@ -865,7 +971,7 @@ Version of the protocol used by this service. This is currently unused.
## Resource types
-### cs_clone
+### `cs_clone`
Type for manipulating corosync/pacemaker resource clone.
More information on Corosync/Pacemaker colocation can be found here:
@@ -876,101 +982,110 @@ More information on Corosync/Pacemaker colocation can be found here:
The following properties are available in the `cs_clone` type.
-##### `ensure`
-
-Valid values: present, absent
-
-The basic property that the resource should be in.
-
-Default value: present
-
-##### `primitive`
-
-The corosync resource primitive to be cloned.
-
-##### `group`
-
-The corosync resource group to be cloned.
-
##### `clone_max`
-Valid values: %r{\d+}, absent
+Valid values: `%r{\d+}`, `absent`
How many copies of the resource to start.
Defaults to the number of nodes in the cluster.
-Default value: absent
+Default value: `absent`
##### `clone_node_max`
-Valid values: %r{\d+}, absent
+Valid values: `%r{\d+}`, `absent`
How many copies of the resource can be started on a single node.
Defaults to 1.
-Default value: absent
+Default value: `absent`
-##### `notify_clones`
+##### `ensure`
-Valid values: `true`, `false`, absent
+Valid values: `present`, `absent`
-When stopping or starting a copy of the clone, tell all the other copies beforehand
-and when the action was successful.
-Allowed values: true, false
+The basic property that the resource should be in.
-Default value: absent
+Default value: `present`
##### `globally_unique`
-Valid values: `true`, `false`, absent
+Valid values: `true`, `false`, `absent`
Does each copy of the clone perform a different function?
Allowed values: true, false
-Default value: absent
+Default value: `absent`
-##### `ordered`
-
-Valid values: `true`, `false`, absent
-
-Should the copies be started in series (instead of in parallel). Allowed values: true, false
+##### `group`
-Default value: absent
+The corosync resource group to be cloned.
##### `interleave`
-Valid values: `true`, `false`, absent
+Valid values: `true`, `false`, `absent`
Changes the behavior of ordering constraints (between clones/masters) so that instances can start/stop
as soon as their peer instance has (rather than waiting for every instance of the other clone has).
Allowed values: true, false
-Default value: absent
+Default value: `absent`
-#### Parameters
+##### `notify_clones`
-The following parameters are available in the `cs_clone` type.
+Valid values: `true`, `false`, `absent`
-##### `name`
+When stopping or starting a copy of the clone, tell all the other copies beforehand
+and when the action was successful.
+Allowed values: true, false
-namevar
+Default value: `absent`
-Identifier of the clone entry. This value needs to be unique
-across the entire Corosync/Pacemaker configuration since it doesn't have
-the concept of name spaces per type.
+##### `ordered`
+
+Valid values: `true`, `false`, `absent`
+
+Should the copies be started in series (instead of in parallel). Allowed values: true, false
+
+Default value: `absent`
+
+##### `primitive`
+
+The corosync resource primitive to be cloned.
+
+#### Parameters
+
+The following parameters are available in the `cs_clone` type.
-##### `cib`
+* [`cib`](#-cs_clone--cib)
+* [`name`](#-cs_clone--name)
+* [`provider`](#-cs_clone--provider)
+
+##### `cib`
Corosync applies its configuration immediately. Using a CIB allows
you to group multiple primitives and relationships to be applied at
once. This can be necessary to insert complex configurations into
Corosync correctly.
-This paramater sets the CIB this colocation should be created in. A
+This parameter sets the CIB this colocation should be created in. A
cs_shadow resource with a title of the same name as this value should
also be added to your manifest.
-### cs_colocation
+##### `name`
+
+namevar
+
+Identifier of the clone entry. This value needs to be unique
+across the entire Corosync/Pacemaker configuration since it doesn't have
+the concept of name spaces per type.
+
+##### `provider`
+
+The specific backend to use for this `cs_clone` resource. You will seldom need to specify this --- Puppet will usually
+discover the appropriate provider for your platform.
+
+### `cs_colocation`
Type for manipulating corosync/pacemaker colocation. Colocation
is the grouping together of a set of primitives so that they travel
@@ -988,11 +1103,11 @@ The following properties are available in the `cs_colocation` type.
##### `ensure`
-Valid values: present, absent
+Valid values: `present`, `absent`
The basic property that the resource should be in.
-Default value: present
+Default value: `present`
##### `primitives`
@@ -1021,21 +1136,17 @@ primitives get priority when forcing the move of other primitives.
This value can be an integer but is often defined as the string
INFINITY.
-Default value: INFINITY
+Default value: `INFINITY`
#### Parameters
The following parameters are available in the `cs_colocation` type.
-##### `name`
+* [`cib`](#-cs_colocation--cib)
+* [`name`](#-cs_colocation--name)
+* [`provider`](#-cs_colocation--provider)
-namevar
-
-Identifier of the colocation entry. This value needs to be unique
-across the entire Corosync/Pacemaker configuration since it doesn't have
-the concept of name spaces per type.
-
-##### `cib`
+##### `cib`
Corosync applies its configuration immediately. Using a CIB allows
you to group multiple primitives and relationships to be applied at
@@ -1046,9 +1157,22 @@ This paramater sets the CIB this colocation should be created in. A
cs_shadow resource with a title of the same name as this value should
also be added to your manifest.
-### cs_commit
+##### `name`
+
+namevar
+
+Identifier of the colocation entry. This value needs to be unique
+across the entire Corosync/Pacemaker configuration since it doesn't have
+the concept of name spaces per type.
+
+##### `provider`
-Final commit statement which triggers the syncronous application of
+The specific backend to use for this `cs_colocation` resource. You will seldom need to specify this --- Puppet will
+usually discover the appropriate provider for your platform.
+
+### `cs_commit`
+
+Final commit statement which triggers the synchronous application of
all primitive changes which reference this CIB. Do not generate more
than one cs_commit referencing the same CIB for a given cluster!
@@ -1056,20 +1180,29 @@ than one cs_commit referencing the same CIB for a given cluster!
The following parameters are available in the `cs_commit` type.
-##### `cib`
+* [`cib`](#-cs_commit--cib)
+* [`name`](#-cs_commit--name)
+* [`provider`](#-cs_commit--provider)
+
+##### `cib`
Name of the CIB to commit. This value defaults to the name of
the cs_commit resource.
-##### `name`
+##### `name`
namevar
Name of the CIB to commit. See the cib parameter for more detail.
-### cs_group
+##### `provider`
+
+The specific backend to use for this `cs_commit` resource. You will seldom need to specify this --- Puppet will usually
+discover the appropriate provider for your platform.
+
+### `cs_group`
-Type for manipulating Corosync/Pacemkaer group entries.
+Type for manipulating Corosync/Pacemaker group entries.
Groups are a set or resources (primitives) that need to be
grouped together.
@@ -1083,11 +1216,11 @@ The following properties are available in the `cs_group` type.
##### `ensure`
-Valid values: present, absent
+Valid values: `present`, `absent`
The basic property that the resource should be in.
-Default value: present
+Default value: `present`
##### `primitives`
@@ -1098,26 +1231,35 @@ order that you wish them to start.
The following parameters are available in the `cs_group` type.
-##### `name`
-
-namevar
-
-Name identifier of this group entry. This value needs to be unique
-across the entire Corosync/Pacemaker configuration since it doesn't have
-the concept of name spaces per type.
+* [`cib`](#-cs_group--cib)
+* [`name`](#-cs_group--name)
+* [`provider`](#-cs_group--provider)
-##### `cib`
+##### `cib`
Corosync applies its configuration immediately. Using a CIB allows
you to group multiple primitives and relationships to be applied at
once. This can be necessary to insert complex configurations into
Corosync correctly.
-This paramater sets the CIB this order should be created in. A
+This parameter sets the CIB this order should be created in. A
cs_shadow resource with a title of the same name as this value should
also be added to your manifest.
-### cs_location
+##### `name`
+
+namevar
+
+Name identifier of this group entry. This value needs to be unique
+across the entire Corosync/Pacemaker configuration since it doesn't have
+the concept of name spaces per type.
+
+##### `provider`
+
+The specific backend to use for this `cs_group` resource. You will seldom need to specify this --- Puppet will usually
+discover the appropriate provider for your platform.
+
+### `cs_location`
Type for manipulating corosync/pacemaker resource location.
More information on Corosync/Pacemaker colocation can be found here:
@@ -1130,36 +1272,26 @@ The following properties are available in the `cs_location` type.
##### `ensure`
-Valid values: present, absent
+Valid values: `present`, `absent`
The basic property that the resource should be in.
-Default value: present
-
-##### `primitive`
-
-The corosync resource primitive to have a location applied.
+Default value: `present`
##### `node_name`
The corosync node_name where the resource should be located.
+##### `primitive`
+
+The corosync resource primitive to have a location applied.
+
##### `resource_discovery`
Whether Pacemaker should perform resource discovery on this
node for the specified resource. It matches the resource-discovery
location property in pacemaker
-##### `score`
-
-The priority of this location. Primitives can be a part of
-multiple location groups and so there is a way to control which
-primitives get priority when forcing the move of other primitives.
-This value can be an integer but is often defined as the string
-INFINITY.
-
-Default value: INFINITY
-
##### `rules`
The rules of this location. This is an array of hashes where
@@ -1190,19 +1322,25 @@ Example:
],
}
-#### Parameters
+##### `score`
-The following parameters are available in the `cs_location` type.
+The priority of this location. Primitives can be a part of
+multiple location groups and so there is a way to control which
+primitives get priority when forcing the move of other primitives.
+This value can be an integer but is often defined as the string
+INFINITY.
-##### `name`
+Default value: `INFINITY`
-namevar
+#### Parameters
-Identifier of the location entry. This value needs to be unique
-across the entire Corosync/Pacemaker configuration since it doesn't have
-the concept of name spaces per type.
+The following parameters are available in the `cs_location` type.
+
+* [`cib`](#-cs_location--cib)
+* [`name`](#-cs_location--name)
+* [`provider`](#-cs_location--provider)
-##### `cib`
+##### `cib`
Corosync applies its configuration immediately. Using a CIB allows
you to group multiple primitives and relationships to be applied at
@@ -1213,9 +1351,22 @@ This paramater sets the CIB this colocation should be created in. A
cs_shadow resource with a title of the same name as this value should
also be added to your manifest.
-### cs_order
+##### `name`
+
+namevar
+
+Identifier of the location entry. This value needs to be unique
+across the entire Corosync/Pacemaker configuration since it doesn't have
+the concept of name spaces per type.
+
+##### `provider`
-Type for manipulating Corosync/Pacemkaer ordering entries. Order
+The specific backend to use for this `cs_location` resource. You will seldom need to specify this --- Puppet will
+usually discover the appropriate provider for your platform.
+
+### `cs_order`
+
+Type for manipulating Corosync/Pacemaker ordering entries. Order
entries are another type of constraint that can be put on sets of
primitives but unlike colocation, order does matter. These designate
the order at which you need specific primitives to come into a desired
@@ -1231,33 +1382,18 @@ The following properties are available in the `cs_order` type.
##### `ensure`
-Valid values: present, absent
+Valid values: `present`, `absent`
The basic property that the resource should be in.
-Default value: present
+Default value: `present`
##### `first`
First Corosync primitive. Just like colocation, our primitives for
-ording come in pairs but this time order matters so we need to define
+ordering come in pairs but this time order matters so we need to define
which primitive starts the desired state change chain.
-##### `second`
-
-Second Corosync primitive. Our second primitive will move to the
-desired state after the first primitive.
-
-##### `score`
-
-The priority of the this ordered grouping. Primitives can be a part
-of multiple order groups and so there is a way to control which
-primitives get priority when forcing the order of state changes on
-other primitives. This value can be an integer but is often defined
-as the string INFINITY.
-
-Default value: INFINITY
-
##### `kind`
How to enforce the constraint.
@@ -1274,39 +1410,63 @@ the resources. First and then can start in either order, but one must
complete starting before the other can be started. A typical use case is
when resource start-up puts a high load on the host.
-Default value: Mandatory
+Default value: `Mandatory`
+
+##### `score`
+
+The priority of the this ordered grouping. Primitives can be a part
+of multiple order groups and so there is a way to control which
+primitives get priority when forcing the order of state changes on
+other primitives. This value can be an integer but is often defined
+as the string INFINITY.
+When using pcs as provider this value is not used.
+It is generally preferred to use the `kind` parameter.
+
+##### `second`
+
+Second Corosync primitive. Our second primitive will move to the
+desired state after the first primitive.
##### `symmetrical`
Boolean specifying if the resources should stop in reverse order.
Default value: true.
-Default value: true
+Default value: `true`
#### Parameters
The following parameters are available in the `cs_order` type.
-##### `name`
-
-namevar
-
-Name identifier of this ordering entry. This value needs to be unique
-across the entire Corosync/Pacemaker configuration since it doesn't have
-the concept of name spaces per type.
+* [`cib`](#-cs_order--cib)
+* [`name`](#-cs_order--name)
+* [`provider`](#-cs_order--provider)
-##### `cib`
+##### `cib`
Corosync applies its configuration immediately. Using a CIB allows
you to group multiple primitives and relationships to be applied at
once. This can be necessary to insert complex configurations into
Corosync correctly.
-This paramater sets the CIB this order should be created in. A
+This parameter sets the CIB this order should be created in. A
cs_shadow resource with a title of the same name as this value should
also be added to your manifest.
-### cs_primitive
+##### `name`
+
+namevar
+
+Name identifier of this ordering entry. This value needs to be unique
+across the entire Corosync/Pacemaker configuration since it doesn't have
+the concept of name spaces per type.
+
+##### `provider`
+
+The specific backend to use for this `cs_order` resource. You will seldom need to specify this --- Puppet will usually
+discover the appropriate provider for your platform.
+
+### `cs_primitive`
Type for manipulating Corosync/Pacemaker primitives. Primitives
are probably the most important building block when creating highly
@@ -1314,7 +1474,7 @@ available clusters using Corosync and Pacemaker. Each primitive defines
an application, ip address, or similar to monitor and maintain. These
managed primitives are maintained using what is called a resource agent.
These resource agents have a concept of class, type, and subsystem that
-provides the functionality. Regretibly these pieces of vocabulary
+provides the functionality. Regrettably these pieces of vocabulary
clash with those used in Puppet so to overcome the name clashing the
property and parameter names have been qualified a bit for clarity.
@@ -1329,22 +1489,21 @@ The following properties are available in the `cs_primitive` type.
##### `ensure`
-Valid values: present, absent
+Valid values: `present`, `absent`
The basic property that the resource should be in.
-Default value: present
+Default value: `present`
-##### `parameters`
+##### `metadata`
-A hash of params for the primitive. Parameters in a primitive are
-used by the underlying resource agent, each class using them slightly
-differently. In ocf scripts they are exported and pulled into the
-script as variables to be used. Since the list of these parameters
-are completely arbitrary and validity not enforced we simply defer
-defining a model and just accept a hash.
+A hash of metadata for the primitive. A primitive can have a set of
+metadata that doesn't affect the underlying Corosync type/provider but
+affect that concept of a resource. This metadata is similar to Puppet's
+resources resource and some meta-parameters, they change resource
+behavior but have no affect of the data that is synced or manipulated.
-Default value: Hash.new
+Default value: `Hash.new`
##### `operations`
@@ -1356,42 +1515,56 @@ and just accept a hash. There maybe room to model this one but it
would require a review of all resource agents to see if each operation
is valid.
-Default value: Hash.new
+Default value: `Hash.new`
+
+##### `parameters`
+
+A hash of params for the primitive. Parameters in a primitive are
+used by the underlying resource agent, each class using them slightly
+differently. In ocf scripts they are exported and pulled into the
+script as variables to be used. Since the list of these parameters
+are completely arbitrary and validity not enforced we simply defer
+defining a model and just accept a hash.
+
+Default value: `Hash.new`
##### `utilization`
A hash of utilization attributes for the primitive. If nodes are
also configured with available resources, and Pacemaker's placement
-stratgey is set appropriately, then Pacemaker can place primitives on
+strategy is set appropriately, then Pacemaker can place primitives on
nodes only where resources are available.
See the Pacemaker documentation:
http://clusterlabs.org/doc/en-US/Pacemaker/1.1/html/Pacemaker_Explained/ch11.html
-Default value: Hash.new
+Default value: `Hash.new`
-##### `metadata`
-
-A hash of metadata for the primitive. A primitive can have a set of
-metadata that doesn't affect the underlying Corosync type/provider but
-affect that concept of a resource. This metadata is similar to Puppet's
-resources resource and some meta-parameters, they change resource
-behavior but have no affect of the data that is synced or manipulated.
-
-Default value: Hash.new
+#### Parameters
-##### `ms_metadata`
+The following parameters are available in the `cs_primitive` type.
-A hash of metadata for the master/slave primitive state.
+* [`cib`](#-cs_primitive--cib)
+* [`name`](#-cs_primitive--name)
+* [`primitive_class`](#-cs_primitive--primitive_class)
+* [`primitive_type`](#-cs_primitive--primitive_type)
+* [`provided_by`](#-cs_primitive--provided_by)
+* [`provider`](#-cs_primitive--provider)
+* [`unmanaged_metadata`](#-cs_primitive--unmanaged_metadata)
-Default value: Hash.new
+##### `cib`
-#### Parameters
+Corosync applies its configuration immediately. Using a CIB allows
+you to group multiple primitives and relationships to be applied at
+once. This can be necessary to insert complex configurations into
+Corosync correctly.
-The following parameters are available in the `cs_primitive` type.
+This parameter sets the CIB this primitive should be created in. A
+cs_shadow resource with a title of the same name as this value should
+also be added to your manifest.
-##### `name`
+##### `name`
namevar
@@ -1399,24 +1572,24 @@ Name identifier of primitive. This value needs to be unique
across the entire Corosync/Pacemaker configuration since it doesn't have
the concept of name spaces per type.
-##### `primitive_class`
+##### `primitive_class`
Corosync class of the primitive. Examples of classes are lsb or ocf.
-Lsb funtions a lot like the init provider in Puppet for services, an init
+Lsb functions a lot like the init provider in Puppet for services, an init
script is ran periodically on each host to identify status, or to start
and stop a particular application. Ocf of the other hand is a script with
-meta-data and stucture that is specific to Corosync and Pacemaker.
+meta-data and structure that is specific to Corosync and Pacemaker.
-##### `primitive_type`
+##### `primitive_type`
Corosync primitive type. Type generally matches to the specific
'thing' your managing, i.e. ip address or vhost. Though, they can be
-completely arbitarily named and manage any number of underlying
+completely arbitrarily named and manage any number of underlying
applications or resources.
-##### `provided_by`
+##### `provided_by`
-Corosync primitive provider. All resource agents used in a primitve
+Corosync primitive provider. All resource agents used in a primitive
have something that provides them to the system, be it the Pacemaker or
redhat plugins...they're not always obvious though so currently you're
left to understand Corosync enough to figure it out. Usually, if it isn't
@@ -1427,25 +1600,19 @@ from the command line has Corosync installed:
* `crm configure ra providers `
-##### `cib`
+##### `provider`
-Corosync applies its configuration immediately. Using a CIB allows
-you to group multiple primitives and relationships to be applied at
-once. This can be necessary to insert complex configurations into
-Corosync correctly.
-
-This paramater sets the CIB this primitive should be created in. A
-cs_shadow resource with a title of the same name as this value should
-also be added to your manifest.
+The specific backend to use for this `cs_primitive` resource. You will seldom need to specify this --- Puppet will
+usually discover the appropriate provider for your platform.
-##### `unmanaged_metadata`
+##### `unmanaged_metadata`
Metadata options that should not be managed by Puppet.
Examples: ['target-role', 'is-managed']
-Default value: Array.new
+Default value: `Array.new`
-### cs_property
+### `cs_property`
Type for manipulating corosync/pacemaker configuration properties.
Besides the configuration file that is managed by the module the contains
@@ -1470,11 +1637,11 @@ The following properties are available in the `cs_property` type.
##### `ensure`
-Valid values: present, absent
+Valid values: `present`, `absent`
The basic property that the resource should be in.
-Default value: present
+Default value: `present`
##### `value`
@@ -1486,27 +1653,37 @@ cluster properties can range the gambit.
The following parameters are available in the `cs_property` type.
-##### `name`
-
-namevar
-
-Name identifier of this property. Simply the name of the cluster
-property. Happily most of these are unique.
+* [`cib`](#-cs_property--cib)
+* [`name`](#-cs_property--name)
+* [`provider`](#-cs_property--provider)
+* [`replace`](#-cs_property--replace)
-##### `cib`
+##### `cib`
Corosync applies its configuration immediately. Using a CIB allows
you to group multiple primitives and relationships to be applied at
once. This can be necessary to insert complex configurations into
Corosync correctly.
-This paramater sets the CIB this parameter should be created in. A
+This parameter sets the CIB this parameter should be created in. A
cs_shadow resource with a title of the same name as this value should
also be added to your manifest.
-##### `replace`
+##### `name`
+
+namevar
+
+Name identifier of this property. Simply the name of the cluster
+property. Happily most of these are unique.
+
+##### `provider`
+
+The specific backend to use for this `cs_property` resource. You will seldom need to specify this --- Puppet will
+usually discover the appropriate provider for your platform.
-Valid values: `true`, `false`, yes, no
+##### `replace`
+
+Valid values: `true`, `false`, `yes`, `no`
Whether to replace a property that already exists on the cluster
whose value doesn't match what the `value` attribute specifies. Setting
@@ -1515,7 +1692,7 @@ overwriting future changes. Defaults to `true`.
Default value: `true`
-### cs_rsc_defaults
+### `cs_rsc_defaults`
Type for manipulating corosync/pacemaker global defaults for
resource options. The type is pretty simple interface for setting
@@ -1533,11 +1710,11 @@ The following properties are available in the `cs_rsc_defaults` type.
##### `ensure`
-Valid values: present, absent
+Valid values: `present`, `absent`
The basic property that the resource should be in.
-Default value: present
+Default value: `present`
##### `value`
@@ -1549,25 +1726,34 @@ resource options can range the gambit.
The following parameters are available in the `cs_rsc_defaults` type.
-##### `name`
-
-namevar
+* [`cib`](#-cs_rsc_defaults--cib)
+* [`name`](#-cs_rsc_defaults--name)
+* [`provider`](#-cs_rsc_defaults--provider)
-Name identifier of this property. Simply the name of the resource
-option. Happily most of these are unique.
-
-##### `cib`
+##### `cib`
Corosync applies its configuration immediately. Using a CIB allows
you to group multiple primitives and relationships to be applied at
once. This can be necessary to insert complex configurations into
Corosync correctly.
-This paramater sets the CIB this rsc_defaults should be created in. A
+This parameter sets the CIB this rsc_defaults should be created in. A
cs_shadow resource with a title of the same name as this value should
also be added to your manifest.
-### cs_shadow
+##### `name`
+
+namevar
+
+Name identifier of this property. Simply the name of the resource
+option. Happily most of these are unique.
+
+##### `provider`
+
+The specific backend to use for this `cs_rsc_defaults` resource. You will seldom need to specify this --- Puppet will
+usually discover the appropriate provider for your platform.
+
+### `cs_shadow`
cs_shadow resources represent a Corosync shadow CIB. Any corosync
resources defined with 'cib' set to the title of a cs_shadow resource
@@ -1582,64 +1768,81 @@ The following properties are available in the `cs_shadow` type.
Implementation detail. DO NOT SET DIRECTLY.
-Default value: latest
+Default value: `latest`
#### Parameters
The following parameters are available in the `cs_shadow` type.
-##### `cib`
-
-namevar
-
-Name of the CIB to begin tracking changes against.
+* [`autocommit`](#-cs_shadow--autocommit)
+* [`cib`](#-cs_shadow--cib)
+* [`provider`](#-cs_shadow--provider)
-##### `autocommit`
+##### `autocommit`
-Valid values: `true`, `false`, yes, no
+Valid values: `true`, `false`, `yes`, `no`
Whether to generate a cs_commit or not. Can be used to create shadow
CIB without committing them.
Default value: `true`
+##### `cib`
+
+namevar
+
+Name of the CIB to begin tracking changes against.
+
+##### `provider`
+
+The specific backend to use for this `cs_shadow` resource. You will seldom need to specify this --- Puppet will usually
+discover the appropriate provider for your platform.
+
## Data types
-### Corosync::ArrayRing
+### `Corosync::ArrayRing`
The Corosync::ArrayRing data type.
-Alias of `Variant[Array[Stdlib::IP::Address], Array[
+Alias of
+
+```puppet
+Variant[Array[Stdlib::IP::Address], Array[
Array[Stdlib::IP::Address]
- ]]`
+ ]]
+```
-### Corosync::CryptoCipher
+### `Corosync::CryptoCipher`
Defines the allowed cipher types for secure corosync communication
Alias of `Enum['aes256', 'aes192', 'aes128', '3des']`
-### Corosync::CryptoHash
+### `Corosync::CryptoHash`
The Corosync::CryptoHash data type.
Alias of `Enum['md5', 'sha1', 'sha256', 'sha384', 'sha512']`
-### Corosync::IpStringIp
+### `Corosync::IpStringIp`
The Corosync::IpStringIp data type.
-Alias of `Variant[Stdlib::IP::Address, Array[
+Alias of
+
+```puppet
+Variant[Stdlib::IP::Address, Array[
Stdlib::IP::Address
- ]]`
+ ]]
+```
-### Corosync::QuorumAlgorithm
+### `Corosync::QuorumAlgorithm`
The Corosync::QuorumAlgorithm data type.
Alias of `Enum['ffsplit', 'lms']`
-### Corosync::Syslogpriority
+### `Corosync::Syslogpriority`
The Corosync::Syslogpriority data type.
diff --git a/Rakefile b/Rakefile
index 80b799d6..1a9b0607 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,7 +1,7 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
-# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper),
+# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper),
# otherwise attempt to load it directly.
begin
require 'voxpupuli/test/rake'
@@ -24,6 +24,10 @@ end
begin
require 'voxpupuli/release/rake_tasks'
rescue LoadError
+ # voxpupuli-release not present
+else
+ GCGConfig.user = 'voxpupuli'
+ GCGConfig.project = 'puppet-corosync'
end
desc "Run main 'test' task and report merged results to coveralls"
@@ -37,36 +41,4 @@ task test_with_coveralls: [:test] do
end
end
-desc 'Generate REFERENCE.md'
-task :reference, [:debug, :backtrace] do |t, args|
- patterns = ''
- Rake::Task['strings:generate:reference'].invoke(patterns, args[:debug], args[:backtrace])
-end
-
-begin
- require 'github_changelog_generator/task'
- require 'puppet_blacksmith'
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
- metadata = Blacksmith::Modulefile.new
- config.future_release = "v#{metadata.version}" if metadata.version =~ /^\d+\.\d+.\d+$/
- config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module."
- config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog}
- config.user = 'voxpupuli'
- config.project = metadata.metadata['name']
- end
-
- # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
- require 'rbconfig'
- if RbConfig::CONFIG['host_os'] =~ /linux/
- task :changelog do
- puts 'Fixing line endings...'
- changelog_file = File.join(__dir__, 'CHANGELOG.md')
- changelog_txt = File.read(changelog_file)
- new_contents = changelog_txt.gsub(%r{\r\n}, "\n")
- File.open(changelog_file, "w") {|file| file.puts new_contents }
- end
- end
-
-rescue LoadError
-end
# vim: syntax=ruby
diff --git a/data/os/Debian.yaml b/data/os/Debian.yaml
new file mode 100644
index 00000000..092666ef
--- /dev/null
+++ b/data/os/Debian.yaml
@@ -0,0 +1,3 @@
+---
+corosync::provider: 'pcs'
+corosync::pcs_version: '0.10.0'
diff --git a/data/os/Debian/9.yaml b/data/os/Debian/9.yaml
deleted file mode 100644
index 2cdfebbf..00000000
--- a/data/os/Debian/9.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-corosync::provider: 'crm'
-corosync::pcs_version: ~
diff --git a/lib/puppet/provider/cs_clone/crm.rb b/lib/puppet/provider/cs_clone/crm.rb
index 253f6a05..3d775be3 100644
--- a/lib/puppet/provider/cs_clone/crm.rb
+++ b/lib/puppet/provider/cs_clone/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: false
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
@@ -30,24 +33,20 @@ def self.instances
items = nvpairs_to_hash(e.elements['meta_attributes'])
clone_instance = {
- name: e.attributes['id'],
- ensure: :present,
- clone_max: items['clone-max'],
- clone_node_max: items['clone-node-max'],
- notify_clones: items['notify'],
- globally_unique: items['globally-unique'],
- ordered: items['ordered'],
- interleave: items['interleave'],
+ name: e.attributes['id'],
+ ensure: :present,
+ clone_max: items['clone-max'],
+ clone_node_max: items['clone-node-max'],
+ notify_clones: items['notify'],
+ globally_unique: items['globally-unique'],
+ ordered: items['ordered'],
+ interleave: items['interleave'],
existing_resource: :true
}
- if e.elements['primitive']
- clone_instance[:primitive] = e.elements['primitive'].attributes['id']
- end
+ clone_instance[:primitive] = e.elements['primitive'].attributes['id'] if e.elements['primitive']
- if e.elements['group']
- clone_instance[:group] = e.elements['group'].attributes['id']
- end
+ clone_instance[:group] = e.elements['group'].attributes['id'] if e.elements['group']
instances << new(clone_instance)
end
instances
@@ -57,16 +56,16 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
- primitive: @resource[:primitive],
- clone_max: @resource[:clone_max],
- clone_node_max: @resource[:clone_node_max],
- notify_clones: @resource[:notify_clones],
- globally_unique: @resource[:globally_unique],
- ordered: @resource[:ordered],
- interleave: @resource[:interleave],
- cib: @resource[:cib],
+ name: @resource[:name],
+ ensure: :present,
+ primitive: @resource[:primitive],
+ clone_max: @resource[:clone_max],
+ clone_node_max: @resource[:clone_node_max],
+ notify_clones: @resource[:notify_clones],
+ globally_unique: @resource[:globally_unique],
+ ordered: @resource[:ordered],
+ interleave: @resource[:interleave],
+ cib: @resource[:cib],
existing_resource: :false
}
end
diff --git a/lib/puppet/provider/cs_clone/pcs.rb b/lib/puppet/provider/cs_clone/pcs.rb
index d1a94b75..5dee868f 100644
--- a/lib/puppet/provider/cs_clone/pcs.rb
+++ b/lib/puppet/provider/cs_clone/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
@@ -15,7 +18,7 @@
mk_resource_methods
- defaultfor operatingsystem: [:fedora, :centos, :redhat]
+ defaultfor operatingsystem: %i[fedora centos redhat]
def change_clone_id(type, primitive, id, cib)
xpath = "/cib/configuration/resources/clone[descendant::#{type}[@id='#{primitive}']]"
@@ -42,14 +45,14 @@ def self.instances
items = nvpairs_to_hash(e.elements['meta_attributes'])
clone_instance = {
- name: e.attributes['id'],
- ensure: :present,
- clone_max: items['clone-max'],
- clone_node_max: items['clone-node-max'],
- notify_clones: items['notify'],
- globally_unique: items['globally-unique'],
- ordered: items['ordered'],
- interleave: items['interleave']
+ name: e.attributes['id'],
+ ensure: :present,
+ clone_max: items['clone-max'],
+ clone_node_max: items['clone-node-max'],
+ notify_clones: items['notify'],
+ globally_unique: items['globally-unique'],
+ ordered: items['ordered'],
+ interleave: items['interleave']
}
if e.elements['primitive']
@@ -73,16 +76,16 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
- primitive: @resource[:primitive],
- group: @resource[:group],
- clone_max: @resource[:clone_max],
- clone_node_max: @resource[:clone_node_max],
- notify_clones: @resource[:notify_clones],
- globally_unique: @resource[:globally_unique],
- ordered: @resource[:ordered],
- interleave: @resource[:interleave]
+ name: @resource[:name],
+ ensure: :present,
+ primitive: @resource[:primitive],
+ group: @resource[:group],
+ clone_max: @resource[:clone_max],
+ clone_node_max: @resource[:clone_node_max],
+ notify_clones: @resource[:notify_clones],
+ globally_unique: @resource[:globally_unique],
+ ordered: @resource[:ordered],
+ interleave: @resource[:interleave]
}
end
diff --git a/lib/puppet/provider/cs_colocation/crm.rb b/lib/puppet/provider/cs_colocation/crm.rb
index d347e0b4..ecd8f5b1 100644
--- a/lib/puppet/provider/cs_colocation/crm.rb
+++ b/lib/puppet/provider/cs_colocation/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: false
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
@@ -39,7 +42,7 @@ def self.instances
items['rsc']
end
- with_rsc = if items ['with-rsc-role']
+ with_rsc = if items['with-rsc-role']
"#{items['with-rsc']}:#{items['with-rsc-role']}"
else
items['with-rsc']
@@ -58,7 +61,7 @@ def self.instances
rsetitems = rset.attributes
# If the resource set has a role, it will apply to all referenced resources.
- rsetrole = (rsetitems['role'] if rsetitems['role'])
+ rsetrole = (rsetitems['role'])
# Add all referenced resources to the primitives array.
rset.each_element('resource_ref') do |rref|
@@ -77,11 +80,11 @@ def self.instances
end
colocation_instance = {
- name: items['id'],
- ensure: :present,
+ name: items['id'],
+ ensure: :present,
primitives: primitives,
- score: items['score'],
- provider: name
+ score: items['score'],
+ provider: name
}
instances << new(colocation_instance)
end
@@ -92,11 +95,11 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
+ name: @resource[:name],
+ ensure: :present,
primitives: @resource[:primitives],
- score: @resource[:score],
- cib: @resource[:cib]
+ score: @resource[:score],
+ cib: @resource[:cib]
}
end
diff --git a/lib/puppet/provider/cs_colocation/pcs.rb b/lib/puppet/provider/cs_colocation/pcs.rb
index 34fff76f..725c4012 100644
--- a/lib/puppet/provider/cs_colocation/pcs.rb
+++ b/lib/puppet/provider/cs_colocation/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
@@ -13,7 +16,7 @@
of current primitive colocations on the system; add, delete, or adjust various
aspects.'
- defaultfor operatingsystem: [:fedora, :centos, :redhat]
+ defaultfor operatingsystem: %i[fedora centos redhat]
commands pcs: 'pcs'
@@ -25,63 +28,59 @@ def self.instances
cmd = [command(:pcs), 'cluster', 'cib']
raw, = run_command_in_cib(cmd)
doc = REXML::Document.new(raw)
- resource_set_options = ['sequential', 'require-all', 'action', 'role']
+ resource_set_options = %w[sequential require-all action role]
constraints = doc.root.elements['configuration'].elements['constraints']
- unless constraints.nil?
- constraints.each_element('rsc_colocation') do |e|
- items = e.attributes
-
- if e.has_elements?
- resource_sets = []
- e.each_element('resource_set') do |rs|
- resource_set = {}
- options = {}
- resource_set_options.each do |o|
- options[o] = rs.attributes[o] if rs.attributes[o]
- end
- # rubocop:disable Style/ZeroLengthPredicate
- resource_set['options'] = options if options.keys.size > 0
- # rubocop:enable Style/ZeroLengthPredicate
- resource_set['primitives'] = []
- rs.each_element('resource_ref') do |rr|
- resource_set['primitives'] << rr.attributes['id']
- end
- resource_sets << resource_set
+ constraints&.each_element('rsc_colocation') do |e|
+ items = e.attributes
+
+ if e.has_elements?
+ resource_sets = []
+ e.each_element('resource_set') do |rs|
+ resource_set = {}
+ options = {}
+ resource_set_options.each do |o|
+ options[o] = rs.attributes[o] if rs.attributes[o]
+ end
+ resource_set['options'] = options if options.keys.size.positive?
+ resource_set['primitives'] = []
+ rs.each_element('resource_ref') do |rr|
+ resource_set['primitives'] << rr.attributes['id']
end
- colocation_instance = {
- name: items['id'],
- ensure: :present,
- primitives: resource_sets,
- score: items['score'],
- provider: name,
- new: false
- }
- else
- rsc = if items['rsc-role'] && items['rsc-role'] != 'Started'
- "#{items['rsc']}:#{items['rsc-role']}"
- else
- items['rsc']
- end
-
- with_rsc = if items ['with-rsc-role'] && items['with-rsc-role'] != 'Started'
- "#{items['with-rsc']}:#{items['with-rsc-role']}"
- else
- items['with-rsc']
- end
-
- colocation_instance = {
- name: items['id'],
- ensure: :present,
- # Put primitives in chronological order, first 'with-rsc', then 'rsc'.
- primitives: [with_rsc, rsc],
- score: items['score'],
- provider: name,
- new: false
- }
+ resource_sets << resource_set
end
- instances << new(colocation_instance)
+ colocation_instance = {
+ name: items['id'],
+ ensure: :present,
+ primitives: resource_sets,
+ score: items['score'],
+ provider: name,
+ new: false
+ }
+ else
+ rsc = if items['rsc-role'] && items['rsc-role'] != 'Started'
+ "#{items['rsc']}:#{items['rsc-role']}"
+ else
+ items['rsc']
+ end
+
+ with_rsc = if items['with-rsc-role'] && items['with-rsc-role'] != 'Started'
+ "#{items['with-rsc']}:#{items['with-rsc-role']}"
+ else
+ items['with-rsc']
+ end
+
+ colocation_instance = {
+ name: items['id'],
+ ensure: :present,
+ # Put primitives in chronological order, first 'with-rsc', then 'rsc'.
+ primitives: [with_rsc, rsc],
+ score: items['score'],
+ provider: name,
+ new: false
+ }
end
+ instances << new(colocation_instance)
end
instances
end
@@ -90,11 +89,11 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
+ name: @resource[:name],
+ ensure: :present,
primitives: @resource[:primitives],
- score: @resource[:score],
- new: true
+ score: @resource[:score],
+ new: true
}
end
@@ -160,9 +159,7 @@ def flush
if first_item.is_a?(Array)
cmd << 'set'
cmd << format_resource_set(first_item)
- until @property_hash[:primitives].empty?
- cmd += format_resource_set(@property_hash[:primitives].shift)
- end
+ cmd += format_resource_set(@property_hash[:primitives].shift) until @property_hash[:primitives].empty?
cmd << 'setoptions'
cmd << "id=#{@property_hash[:name]}"
cmd << "score=#{@property_hash[:score]}"
diff --git a/lib/puppet/provider/cs_commit/crm.rb b/lib/puppet/provider/cs_commit/crm.rb
index da423248..8fe2504a 100644
--- a/lib/puppet/provider/cs_commit/crm.rb
+++ b/lib/puppet/provider/cs_commit/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
diff --git a/lib/puppet/provider/cs_commit/pcs.rb b/lib/puppet/provider/cs_commit/pcs.rb
index 03a7251c..979e098c 100644
--- a/lib/puppet/provider/cs_commit/pcs.rb
+++ b/lib/puppet/provider/cs_commit/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
@@ -22,8 +25,8 @@ def self.instances
end
def commit
- cib_path = File.join(Puppet[:vardir], 'shadow.' + @resource[:name])
- self.class.run_command_in_cib([command(:pcs), 'cluster', 'cib-push', cib_path, 'diff-against=' + cib_path + '.ori'])
+ cib_path = File.join(Puppet[:vardir], "shadow.#{@resource[:name]}")
+ self.class.run_command_in_cib([command(:pcs), 'cluster', 'cib-push', cib_path, "diff-against=#{cib_path}.ori"])
# We run the next command in the CIB directly by purpose:
# We commit the shadow CIB with the admin_epoch it was created.
self.class.run_command_in_cib([command(:cibadmin), '--modify', '--xml-text', ''])
diff --git a/lib/puppet/provider/cs_group/crm.rb b/lib/puppet/provider/cs_group/crm.rb
index 6d8eede2..fa115700 100644
--- a/lib/puppet/provider/cs_group/crm.rb
+++ b/lib/puppet/provider/cs_group/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
@@ -32,10 +35,10 @@ def self.instances
end
group_instance = {
- name: e.attributes['id'],
- ensure: :present,
+ name: e.attributes['id'],
+ ensure: :present,
primitives: primitives,
- provider: name
+ provider: name
}
instances << new(group_instance)
end
@@ -46,8 +49,8 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
+ name: @resource[:name],
+ ensure: :present,
primitives: Array(@resource[:primitives])
}
@property_hash[:cib] = @resource[:cib] unless @resource[:cib].nil?
diff --git a/lib/puppet/provider/cs_group/pcs.rb b/lib/puppet/provider/cs_group/pcs.rb
index ef67c4a6..8e3a7702 100644
--- a/lib/puppet/provider/cs_group/pcs.rb
+++ b/lib/puppet/provider/cs_group/pcs.rb
@@ -1,16 +1,19 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
Puppet::Type.type(:cs_group).provide(:pcs, parent: PuppetX::Voxpupuli::Corosync::Provider::Pcs) do
desc 'Provider to add, delete, manipulate primitive groups.'
- defaultfor operatingsystem: [:fedora, :centos, :redhat]
+ defaultfor operatingsystem: %i[fedora centos redhat]
# Path to the pcs binary for interacting with the cluster configuration.
commands pcs: '/usr/sbin/pcs'
@@ -34,11 +37,11 @@ def self.instances
end
group_instance = {
- name: e.attributes['id'],
- ensure: :present,
+ name: e.attributes['id'],
+ ensure: :present,
primitives: primitives,
- provider: name,
- new: false
+ provider: name,
+ new: false
}
instances << new(group_instance)
end
@@ -49,10 +52,10 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
+ name: @resource[:name],
+ ensure: :present,
primitives: Array(@resource[:primitives]),
- new: true
+ new: true
}
@property_hash[:cib] = @resource[:cib] unless @resource[:cib].nil?
end
diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb
index 3ac34966..e87bd061 100644
--- a/lib/puppet/provider/cs_location/crm.rb
+++ b/lib/puppet/provider/cs_location/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
@@ -29,11 +32,7 @@
pacemakerd_version_string = pacemakerd('--version')
if pacemakerd_version_string
pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first
- if pacemakerd_version
- if Puppet::Util::Package.versioncmp(pacemakerd_version, '1.1.13') >= 0
- has_feature :discovery
- end
- end
+ has_feature :discovery if pacemakerd_version && (Puppet::Util::Package.versioncmp(pacemakerd_version, '1.1.13') >= 0)
end
rescue Puppet::MissingCommand
# on fresh systems pacemaker is not yet installed when pacemakerd command is executed, so we do just nothing, when the executable is missing
@@ -57,14 +56,14 @@ def self.instances
id, items = node2hash(e, ['expression']).first
location_instance = {
- name: id,
- ensure: :present,
- primitive: items['rsc'],
- node_name: items['node'],
- score: items['score'] || 'INFINITY',
- rules: items['rule'],
+ name: id,
+ ensure: :present,
+ primitive: items['rsc'],
+ node_name: items['node'],
+ score: items['score'] || 'INFINITY',
+ rules: items['rule'],
resource_discovery: items['resource-discovery'],
- provider: name
+ provider: name
}
instances << new(location_instance)
end
@@ -75,12 +74,12 @@ def self.instances
# care of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
- primitive: @resource[:primitive],
- node_name: @resource[:node_name],
- score: @resource[:score],
- rules: @resource[:rules],
+ name: @resource[:name],
+ ensure: :present,
+ primitive: @resource[:primitive],
+ node_name: @resource[:node_name],
+ score: @resource[:score],
+ rules: @resource[:rules],
resource_discovery: @resource[:resource_discovery]
}
end
@@ -101,28 +100,22 @@ def flush
updated = "location #{@property_hash[:name]} #{@property_hash[:primitive]}"
- if feature?(:discovery)
- updated << " resource-discovery=#{@property_hash[:resource_discovery]}" unless @property_hash[:resource_discovery].nil?
- end
+ updated << " resource-discovery=#{@property_hash[:resource_discovery]}" if feature?(:discovery) && !@property_hash[:resource_discovery].nil?
- unless @property_hash[:node_name].nil?
- updated << " #{@property_hash[:score]}: #{@property_hash[:node_name]}"
- end
+ updated << " #{@property_hash[:score]}: #{@property_hash[:node_name]}" unless @property_hash[:node_name].nil?
- unless @property_hash[:rules].nil?
- @property_hash[:rules].each do |rule_item|
- name = rule_item.keys.first
- rule = rule_item[name]
+ @property_hash[:rules]&.each do |rule_item|
+ name = rule_item.keys.first
+ rule = rule_item[name]
- score = rule['score-attribute'] || rule['score']
+ score = rule['score-attribute'] || rule['score']
- boolean_op = rule['boolean-op'] || 'and'
- expression = self.class.rule_expression(name, rule['expression'], boolean_op)
+ boolean_op = rule['boolean-op'] || 'and'
+ expression = self.class.rule_expression(name, rule['expression'], boolean_op)
- updated << " rule $id=\"#{name}\""
- updated << " $role=\"#{rule['role']}\"" unless rule['role'].nil?
- updated << " #{score}: #{expression.join(' ')}"
- end
+ updated << " rule $id=\"#{name}\""
+ updated << " $role=\"#{rule['role']}\"" unless rule['role'].nil?
+ updated << " #{score}: #{expression.join(' ')}"
end
debug("Loading update: #{updated}")
diff --git a/lib/puppet/provider/cs_location/pcs.rb b/lib/puppet/provider/cs_location/pcs.rb
index 05db0380..00650558 100644
--- a/lib/puppet/provider/cs_location/pcs.rb
+++ b/lib/puppet/provider/cs_location/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
@@ -13,7 +16,7 @@
of current primitive locations on the system; add, delete, or adjust various
aspects.'
- defaultfor operatingsystem: [:fedora, :centos, :redhat]
+ defaultfor operatingsystem: %i[fedora centos redhat]
has_feature :discovery
commands pcs: 'pcs'
@@ -30,26 +33,24 @@ def self.instances
doc = REXML::Document.new(raw)
constraints = doc.root.elements['configuration'].elements['constraints']
- unless constraints.nil?
- constraints.each_element('rsc_location') do |e|
- # The node2hash method maps resource locations from XML into hashes.
- # The expression key is handled differently because the result must
- # not contain the id of the XML node. The crm command can not set the
- # expression id so Puppet would try to update the rule at every run.
- id, items = node2hash(e, ['expression']).first
-
- location_instance = {
- name: id,
- ensure: :present,
- primitive: items['rsc'],
- node_name: items['node'],
- score: items['score'] || 'INFINITY',
- rules: items['rule'],
- resource_discovery: items['resource-discovery'],
- provider: name
- }
- instances << new(location_instance)
- end
+ constraints&.each_element('rsc_location') do |e|
+ # The node2hash method maps resource locations from XML into hashes.
+ # The expression key is handled differently because the result must
+ # not contain the id of the XML node. The crm command can not set the
+ # expression id so Puppet would try to update the rule at every run.
+ id, items = node2hash(e, ['expression']).first
+
+ location_instance = {
+ name: id,
+ ensure: :present,
+ primitive: items['rsc'],
+ node_name: items['node'],
+ score: items['score'] || 'INFINITY',
+ rules: items['rule'],
+ resource_discovery: items['resource-discovery'],
+ provider: name
+ }
+ instances << new(location_instance)
end
instances
end
@@ -58,12 +59,12 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
- primitive: @resource[:primitive],
- node_name: @resource[:node_name],
- score: @resource[:score],
- rules: @resource[:rules],
+ name: @resource[:name],
+ ensure: :present,
+ primitive: @resource[:primitive],
+ node_name: @resource[:node_name],
+ score: @resource[:score],
+ rules: @resource[:rules],
resource_discovery: @resource[:resource_discovery]
}
end
diff --git a/lib/puppet/provider/cs_order/crm.rb b/lib/puppet/provider/cs_order/crm.rb
index f2679117..62f1278d 100644
--- a/lib/puppet/provider/cs_order/crm.rb
+++ b/lib/puppet/provider/cs_order/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
@@ -42,11 +45,7 @@ def self.instances
items['then']
end
- kind = if items['kind']
- items['kind']
- else
- 'Mandatory'
- end
+ kind = items['kind'] || 'Mandatory'
symmetrical = if items['symmetrical']
(items['symmetrical'] == 'true')
@@ -56,14 +55,14 @@ def self.instances
end
order_instance = {
- name: items['id'],
- ensure: :present,
- first: first,
- second: second,
- score: items['score'],
- kind: kind,
+ name: items['id'],
+ ensure: :present,
+ first: first,
+ second: second,
+ score: items['score'],
+ kind: kind,
symmetrical: symmetrical,
- provider: name
+ provider: name
}
instances << new(order_instance)
end
@@ -74,14 +73,14 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
- first: @resource[:first],
- second: @resource[:second],
- score: @resource[:score],
+ name: @resource[:name],
+ ensure: :present,
+ first: @resource[:first],
+ second: @resource[:second],
+ score: @resource[:score],
symmetrical: @resource[:symmetrical],
- kind: @resource[:kind],
- cib: @resource[:cib]
+ kind: @resource[:kind],
+ cib: @resource[:cib]
}
end
diff --git a/lib/puppet/provider/cs_order/pcs.rb b/lib/puppet/provider/cs_order/pcs.rb
index c26225a2..a527910a 100644
--- a/lib/puppet/provider/cs_order/pcs.rb
+++ b/lib/puppet/provider/cs_order/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
@@ -13,7 +16,7 @@
of current primitive start orders on the system; add, delete, or adjust various
aspects.'
- defaultfor operatingsystem: [:fedora, :centos, :redhat]
+ defaultfor operatingsystem: %i[fedora centos redhat]
has_feature :kindness
@@ -32,46 +35,40 @@ def self.instances
doc = REXML::Document.new(raw)
constraints = doc.root.elements['configuration'].elements['constraints']
- unless constraints.nil?
- constraints.each_element('rsc_order') do |e|
- items = e.attributes
-
- first = if items['first-action']
- "#{items['first']}:#{items['first-action']}"
- else
- items['first']
- end
-
- second = if items['then-action']
- "#{items['then']}:#{items['then-action']}"
- else
- items['then']
- end
- kind = if items['kind']
- items['kind']
+ constraints&.each_element('rsc_order') do |e|
+ items = e.attributes
+
+ first = if items['first-action']
+ "#{items['first']}:#{items['first-action']}"
+ else
+ items['first']
+ end
+
+ second = if items['then-action']
+ "#{items['then']}:#{items['then-action']}"
else
- 'Mandatory'
+ items['then']
end
-
- symmetrical = if items['symmetrical']
- (items['symmetrical'] == 'true')
- else
- # Default: symmetrical is true unless explicitly defined.
- true
- end
-
- order_instance = {
- name: items['id'],
- ensure: :present,
- first: first,
- second: second,
- kind: kind,
- symmetrical: symmetrical,
- provider: name,
- new: false
- }
- instances << new(order_instance)
- end
+ kind = items['kind'] || 'Mandatory'
+
+ symmetrical = if items['symmetrical']
+ (items['symmetrical'] == 'true')
+ else
+ # Default: symmetrical is true unless explicitly defined.
+ true
+ end
+
+ order_instance = {
+ name: items['id'],
+ ensure: :present,
+ first: first,
+ second: second,
+ kind: kind,
+ symmetrical: symmetrical,
+ provider: name,
+ new: false
+ }
+ instances << new(order_instance)
end
instances
end
@@ -80,13 +77,13 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
- first: @resource[:first],
- second: @resource[:second],
- kind: @resource[:kind],
+ name: @resource[:name],
+ ensure: :present,
+ first: @resource[:first],
+ second: @resource[:second],
+ kind: @resource[:kind],
symmetrical: @resource[:symmetrical],
- new: true
+ new: true
}
end
diff --git a/lib/puppet/provider/cs_primitive/crm.rb b/lib/puppet/provider/cs_primitive/crm.rb
index 911cb32c..d8c966a7 100644
--- a/lib/puppet/provider/cs_primitive/crm.rb
+++ b/lib/puppet/provider/cs_primitive/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: false
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
@@ -23,37 +26,33 @@
# for creating a new provider instance.
def self.element_to_hash(e)
hash = {
- primitive_class: e.attributes['class'],
- primitive_type: e.attributes['type'],
- provided_by: e.attributes['provider'],
- name: e.attributes['id'].to_sym,
- ensure: :present,
- provider: name,
- parameters: nvpairs_to_hash(e.elements['instance_attributes']),
- operations: [],
- utilization: nvpairs_to_hash(e.elements['utilization']),
- metadata: nvpairs_to_hash(e.elements['meta_attributes']),
+ primitive_class: e.attributes['class'],
+ primitive_type: e.attributes['type'],
+ provided_by: e.attributes['provider'],
+ name: e.attributes['id'].to_sym,
+ ensure: :present,
+ provider: name,
+ parameters: nvpairs_to_hash(e.elements['instance_attributes']),
+ operations: [],
+ utilization: nvpairs_to_hash(e.elements['utilization']),
+ metadata: nvpairs_to_hash(e.elements['meta_attributes']),
existing_metadata: nvpairs_to_hash(e.elements['meta_attributes']),
- ms_metadata: {},
+ ms_metadata: {},
}
operations = e.elements['operations']
- unless operations.nil?
- operations.each_element do |o|
- valids = o.attributes.reject { |k, _v| k == 'id' }
- name = valids['name'].to_s
- operation = {}
- operation[name] = {}
- valids.each do |k, v|
- operation[name][k] = v.to_s if k != 'name'
- end
- unless o.elements['instance_attributes'].nil?
- o.elements['instance_attributes'].each_element do |i|
- operation[name][i.attributes['name']] = i.attributes['value']
- end
- end
- hash[:operations] << operation
+ operations&.each_element do |o|
+ valids = o.attributes.reject { |k, _v| k == 'id' }
+ name = valids['name'].to_s
+ operation = {}
+ operation[name] = {}
+ valids.each do |k, v|
+ operation[name][k] = v.to_s if k != 'name'
+ end
+ o.elements['instance_attributes']&.each_element do |i|
+ operation[name][i.attributes['name']] = i.attributes['value']
end
+ hash[:operations] << operation
end
hash
@@ -78,11 +77,11 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
+ name: @resource[:name],
+ ensure: :present,
primitive_class: @resource[:primitive_class],
- provided_by: @resource[:provided_by],
- primitive_type: @resource[:primitive_type],
+ provided_by: @resource[:provided_by],
+ primitive_type: @resource[:primitive_type],
}
@property_hash[:parameters] = @resource[:parameters] unless @resource[:parameters].nil?
@property_hash[:operations] = @resource[:operations] unless @resource[:operations].nil?
@@ -162,9 +161,7 @@ def flush
end
if @resource && @resource.class.name == :cs_primitive && @resource[:unmanaged_metadata]
@resource[:unmanaged_metadata].each do |parameter_name|
- if @property_hash[:existing_metadata] && @property_hash[:existing_metadata][parameter_name]
- @property_hash[:metadata][parameter_name] = @property_hash[:existing_metadata]['target-role']
- end
+ @property_hash[:metadata][parameter_name] = @property_hash[:existing_metadata]['target-role'] if @property_hash[:existing_metadata] && @property_hash[:existing_metadata][parameter_name]
end
end
unless @property_hash[:parameters].empty?
diff --git a/lib/puppet/provider/cs_primitive/pcs.rb b/lib/puppet/provider/cs_primitive/pcs.rb
index cd40d552..7e27a1d5 100644
--- a/lib/puppet/provider/cs_primitive/pcs.rb
+++ b/lib/puppet/provider/cs_primitive/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: false
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
@@ -20,48 +23,44 @@
mk_resource_methods
- defaultfor operatingsystem: [:fedora, :centos, :redhat]
+ defaultfor operatingsystem: %i[fedora centos redhat]
# given an XML element (a from cibadmin), produce a hash suitible
# for creating a new provider instance.
def self.element_to_hash(e)
hash = {
- primitive_class: e.attributes['class'],
- primitive_type: e.attributes['type'],
- provided_by: e.attributes['provider'],
- name: e.attributes['id'].to_sym,
- ensure: :present,
- provider: name,
- parameters: nvpairs_to_hash(e.elements['instance_attributes']),
- operations: [],
- utilization: nvpairs_to_hash(e.elements['utilization']),
- metadata: nvpairs_to_hash(e.elements['meta_attributes']),
- existing_resource: :true,
+ primitive_class: e.attributes['class'],
+ primitive_type: e.attributes['type'],
+ provided_by: e.attributes['provider'],
+ name: e.attributes['id'].to_sym,
+ ensure: :present,
+ provider: name,
+ parameters: nvpairs_to_hash(e.elements['instance_attributes']),
+ operations: [],
+ utilization: nvpairs_to_hash(e.elements['utilization']),
+ metadata: nvpairs_to_hash(e.elements['meta_attributes']),
+ existing_resource: :true,
existing_primitive_class: e.attributes['class'],
- existing_primitive_type: e.attributes['type'],
- existing_provided_by: e.attributes['provider'],
- existing_metadata: nvpairs_to_hash(e.elements['meta_attributes']),
- existing_operations: []
+ existing_primitive_type: e.attributes['type'],
+ existing_provided_by: e.attributes['provider'],
+ existing_metadata: nvpairs_to_hash(e.elements['meta_attributes']),
+ existing_operations: []
}
operations = e.elements['operations']
- unless operations.nil?
- operations.each_element do |o|
- valids = o.attributes.reject { |k, _v| k == 'id' }
- name = valids['name'].to_s
- operation = {}
- operation[name] = {}
- valids.each do |k, v|
- operation[name][k] = v.to_s if k != 'name'
- end
- unless o.elements['instance_attributes'].nil?
- o.elements['instance_attributes'].each_element do |i|
- operation[name][i.attributes['name']] = i.attributes['value']
- end
- end
- hash[:operations] << operation
- hash[:existing_operations] << operation
+ operations&.each_element do |o|
+ valids = o.attributes.reject { |k, _v| k == 'id' }
+ name = valids['name'].to_s
+ operation = {}
+ operation[name] = {}
+ valids.each do |k, v|
+ operation[name][k] = v.to_s if k != 'name'
+ end
+ o.elements['instance_attributes']&.each_element do |i|
+ operation[name][i.attributes['name']] = i.attributes['value']
end
+ hash[:operations] << operation
+ hash[:existing_operations] << operation
end
hash
@@ -98,11 +97,11 @@ def self._determine_primitive_subcommand(primitive_class)
# updates or create a resource, so we flag the resources with that parameter
def create
@property_hash = {
- name: @resource[:name],
- ensure: :present,
- primitive_class: @resource[:primitive_class],
- provided_by: @resource[:provided_by],
- primitive_type: @resource[:primitive_type],
+ name: @resource[:name],
+ ensure: :present,
+ primitive_class: @resource[:primitive_class],
+ provided_by: @resource[:provided_by],
+ primitive_type: @resource[:primitive_type],
existing_resource: :false
}
@property_hash[:parameters] = @resource[:parameters] unless @resource[:parameters].nil?
@@ -183,9 +182,7 @@ def _flush_resource(operations, parameters, utilization, metadatas)
# provider or type has changed. Since stonith resources have a special
# command they do not include a provider or class in their type name
resource_type = "#{@property_hash[:primitive_class]}:"
- if @property_hash[:provided_by]
- resource_type << "#{@property_hash[:provided_by]}:"
- end
+ resource_type << "#{@property_hash[:provided_by]}:" if @property_hash[:provided_by]
resource_type << (@property_hash[:primitive_type]).to_s
# We destroy the resource if it's type, class or provider has changed
@@ -272,7 +269,7 @@ def flush
if @resource && @resource.class.name == :cs_primitive && @resource[:unmanaged_metadata]
@resource[:unmanaged_metadata].each do |parameter_name|
@property_hash[:metadata].delete(parameter_name)
- @property_hash[:existing_metadata].delete(parameter_name) if @property_hash[:existing_metadata]
+ @property_hash[:existing_metadata]&.delete(parameter_name)
end
end
@@ -291,11 +288,7 @@ def flush
# Establish whether this is a regular resource or a special stonith resource
# The destinction exists only because pcs uses a different subcommand to
# interact with stonith resources
- is_stonith = if (@property_hash[:primitive_class]).to_s == 'stonith'
- true
- else
- false
- end
+ is_stonith = (@property_hash[:primitive_class]).to_s == 'stonith'
# Call the appropriate helper function to generate the PCS commands
if is_stonith
diff --git a/lib/puppet/provider/cs_property/crm.rb b/lib/puppet/provider/cs_property/crm.rb
index d94a48a2..4e9a0cac 100644
--- a/lib/puppet/provider/cs_property/crm.rb
+++ b/lib/puppet/provider/cs_property/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
@@ -26,19 +29,17 @@ def self.instances
doc = REXML::Document.new(raw)
cluster_property_set = doc.root.elements["configuration/crm_config/cluster_property_set[@id='cib-bootstrap-options']"]
- unless cluster_property_set.nil?
- cluster_property_set.each_element do |e|
- items = e.attributes
- property = { name: items['name'], value: items['value'] }
+ cluster_property_set&.each_element do |e|
+ items = e.attributes
+ property = { name: items['name'], value: items['value'] }
- property_instance = {
- name: property[:name],
- ensure: :present,
- value: property[:value],
- provider: name
- }
- instances << new(property_instance)
- end
+ property_instance = {
+ name: property[:name],
+ ensure: :present,
+ value: property[:value],
+ provider: name
+ }
+ instances << new(property_instance)
end
instances
end
@@ -47,9 +48,9 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
+ name: @resource[:name],
ensure: :present,
- value: @resource[:value]
+ value: @resource[:value]
}
end
diff --git a/lib/puppet/provider/cs_property/pcs.rb b/lib/puppet/provider/cs_property/pcs.rb
index fefb11cf..3132c2aa 100644
--- a/lib/puppet/provider/cs_property/pcs.rb
+++ b/lib/puppet/provider/cs_property/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
@@ -12,7 +15,7 @@
abstract corosync/pacemaker vs. keepalived. This provider will check the state
of Corosync cluster configuration properties.'
- defaultfor operatingsystem: [:fedora, :centos, :redhat]
+ defaultfor operatingsystem: %i[fedora centos redhat]
# Path to the pcs binary for interacting with the cluster configuration.
commands pcs: 'pcs'
@@ -27,19 +30,17 @@ def self.instances
doc = REXML::Document.new(raw)
cluster_property_set = doc.root.elements["configuration/crm_config/cluster_property_set[@id='cib-bootstrap-options']"]
- unless cluster_property_set.nil?
- cluster_property_set.each_element do |e|
- items = e.attributes
- property = { name: items['name'], value: items['value'] }
-
- property_instance = {
- name: property[:name],
- ensure: :present,
- value: property[:value],
- provider: name
- }
- instances << new(property_instance)
- end
+ cluster_property_set&.each_element do |e|
+ items = e.attributes
+ property = { name: items['name'], value: items['value'] }
+
+ property_instance = {
+ name: property[:name],
+ ensure: :present,
+ value: property[:value],
+ provider: name
+ }
+ instances << new(property_instance)
end
instances
end
@@ -48,9 +49,9 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
+ name: @resource[:name],
ensure: :present,
- value: @resource[:value]
+ value: @resource[:value]
}
end
diff --git a/lib/puppet/provider/cs_rsc_defaults/crm.rb b/lib/puppet/provider/cs_rsc_defaults/crm.rb
index 65326f33..493e3f72 100644
--- a/lib/puppet/provider/cs_rsc_defaults/crm.rb
+++ b/lib/puppet/provider/cs_rsc_defaults/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
@@ -30,9 +33,9 @@ def self.instances
rsc_defaults = { name: items['name'], value: items['value'] }
rsc_defaults_instance = {
- name: rsc_defaults[:name],
- ensure: :present,
- value: rsc_defaults[:value],
+ name: rsc_defaults[:name],
+ ensure: :present,
+ value: rsc_defaults[:value],
provider: name
}
instances << new(rsc_defaults_instance)
@@ -44,9 +47,9 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
+ name: @resource[:name],
ensure: :present,
- value: @resource[:value]
+ value: @resource[:value]
}
end
diff --git a/lib/puppet/provider/cs_rsc_defaults/pcs.rb b/lib/puppet/provider/cs_rsc_defaults/pcs.rb
index 1b04cb90..a730c3b4 100644
--- a/lib/puppet/provider/cs_rsc_defaults/pcs.rb
+++ b/lib/puppet/provider/cs_rsc_defaults/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
@@ -12,7 +15,7 @@
abstract corosync/pacemaker vs. keepalived. This provider will check the state
of Corosync global defaults for resource options.'
- defaultfor operatingsystem: [:fedora, :centos, :redhat]
+ defaultfor operatingsystem: %i[fedora centos redhat]
# Path to the pcs binary for interacting with the cluster configuration.
commands pcs: 'pcs'
@@ -31,9 +34,9 @@ def self.instances
rsc_defaults = { name: items['name'], value: items['value'] }
rsc_defaults_instance = {
- name: rsc_defaults[:name],
- ensure: :present,
- value: rsc_defaults[:value],
+ name: rsc_defaults[:name],
+ ensure: :present,
+ value: rsc_defaults[:value],
provider: name
}
instances << new(rsc_defaults_instance)
@@ -45,16 +48,16 @@ def self.instances
# of actually doing the work.
def create
@property_hash = {
- name: @resource[:name],
+ name: @resource[:name],
ensure: :present,
- value: @resource[:value]
+ value: @resource[:value]
}
end
# Unlike create we actually immediately delete the item.
def destroy
debug('Removing resource default')
- cmd = [command(:pcs), 'resource', 'defaults', (@property_hash[:name]).to_s + '=']
+ cmd = [command(:pcs), 'resource', 'defaults', "#{@property_hash[:name]}="]
self.class.run_command_in_cib(cmd, @resource[:cib])
@property_hash.clear
end
@@ -79,6 +82,7 @@ def value=(should)
# as stdin for the pcs command.
def flush
return if @property_hash.empty?
+
# clear this on properties, in case it's set from a previous
# run of a different corosync type
cmd = [command(:pcs), 'resource', 'defaults', "#{@property_hash[:name]}=#{@property_hash[:value]}"]
diff --git a/lib/puppet/provider/cs_shadow/crm.rb b/lib/puppet/provider/cs_shadow/crm.rb
index c568c29d..158e56b3 100644
--- a/lib/puppet/provider/cs_shadow/crm.rb
+++ b/lib/puppet/provider/cs_shadow/crm.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/crmsh'
end
diff --git a/lib/puppet/provider/cs_shadow/pcs.rb b/lib/puppet/provider/cs_shadow/pcs.rb
index 024ab210..d89d9ea1 100644
--- a/lib/puppet/provider/cs_shadow/pcs.rb
+++ b/lib/puppet/provider/cs_shadow/pcs.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider/pcs'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/pcs'
end
diff --git a/lib/puppet/type/cs_clone.rb b/lib/puppet/type/cs_clone.rb
index a8ff4125..5cc551e4 100644
--- a/lib/puppet/type/cs_clone.rb
+++ b/lib/puppet/type/cs_clone.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
Puppet::Type.newtype(:cs_clone) do
@doc = "Type for manipulating corosync/pacemaker resource clone.
More information on Corosync/Pacemaker colocation can be found here:
@@ -108,14 +110,15 @@
def unmunge_cs_primitive(name)
name = name.split(':')[0]
- name = name[3..-1] if name.start_with? 'ms_'
+ name = name[3..] if name.start_with? 'ms_'
name
end
validate do
return if self[:ensure] == :absent
- mandatory_single_properties = [:primitive, :group]
+
+ mandatory_single_properties = %i[primitive group]
has_should = mandatory_single_properties.select { |prop| should(prop) }
raise Puppet::Error, "You cannot specify #{has_should.join(' and ')} on this type (only one)" if has_should.length > 1
raise Puppet::Error, "You must specify #{mandatory_single_properties.join(' or ')}" if has_should.length != 1
diff --git a/lib/puppet/type/cs_colocation.rb b/lib/puppet/type/cs_colocation.rb
index f644c6ad..54467600 100644
--- a/lib/puppet/type/cs_colocation.rb
+++ b/lib/puppet/type/cs_colocation.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
Puppet::Type.newtype(:cs_colocation) do
@doc = "Type for manipulating corosync/pacemaker colocation. Colocation
is the grouping together of a set of primitives so that they travel
@@ -43,6 +45,7 @@ def should=(value)
super
raise Puppet::Error, 'Puppet::Type::Cs_Colocation: The primitives property must be an array.' unless value.is_a? Array
raise Puppet::Error, 'Puppet::Type::Cs_Colocation: The primitives property must be an array of at least one element.' if value.empty?
+
@should
end
end
@@ -83,9 +86,7 @@ def extract_primitives
unless @parameters[:primitives].should.nil?
if @parameters[:primitives].should.first.is_a?(Hash)
@parameters[:primitives].should.each do |colocation_set|
- if colocation_set.key?('primitives')
- result << colocation_set['primitives']
- end
+ result << colocation_set['primitives'] if colocation_set.key?('primitives')
end
end
if @parameters[:primitives].should.first.is_a?(String)
@@ -97,7 +98,7 @@ def extract_primitives
result.flatten
end
- [:cs_clone, :cs_primitive].each do |resource_type|
+ %i[cs_clone cs_primitive].each do |resource_type|
autorequire(resource_type) do
extract_primitives
end
@@ -105,7 +106,7 @@ def extract_primitives
def unmunge_cs_primitive(name)
name = name.split(':')[0]
- name = name[3..-1] if name.start_with? 'ms_'
+ name = name[3..] if name.start_with? 'ms_'
name
end
diff --git a/lib/puppet/type/cs_commit.rb b/lib/puppet/type/cs_commit.rb
index b6accd30..ef1f120a 100644
--- a/lib/puppet/type/cs_commit.rb
+++ b/lib/puppet/type/cs_commit.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
Puppet::Type.newtype(:cs_commit) do
@doc = 'Final commit statement which triggers the synchronous application of
all primitive changes which reference this CIB. Do not generate more
@@ -35,7 +37,7 @@ def refresh
autos
end
- if Puppet::Util::Package.versioncmp(Puppet::PUPPETVERSION, '4.0') < 0
+ if Puppet::Util::Package.versioncmp(Puppet::PUPPETVERSION, '4.0').negative?
autorequire(:cs_primitive) do
resources_with_cib :cs_primitive
end
diff --git a/lib/puppet/type/cs_group.rb b/lib/puppet/type/cs_group.rb
index ccf168aa..a0b86d72 100644
--- a/lib/puppet/type/cs_group.rb
+++ b/lib/puppet/type/cs_group.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
Puppet::Type.newtype(:cs_group) do
@doc = "Type for manipulating Corosync/Pacemaker group entries.
Groups are a set or resources (primitives) that need to be
@@ -54,10 +56,8 @@ def insync?(is)
autorequire(:cs_primitive) do
autos = []
- if should(:primitives)
- should(:primitives).each do |val|
- autos << unmunge_cs_primitive(val)
- end
+ should(:primitives)&.each do |val|
+ autos << unmunge_cs_primitive(val)
end
autos
@@ -65,7 +65,7 @@ def insync?(is)
def unmunge_cs_primitive(name)
name = name.split(':')[0]
- name = name[3..-1] if name.start_with? 'ms_'
+ name = name[3..] if name.start_with? 'ms_'
name
end
diff --git a/lib/puppet/type/cs_location.rb b/lib/puppet/type/cs_location.rb
index 13415dfe..c9b42aeb 100644
--- a/lib/puppet/type/cs_location.rb
+++ b/lib/puppet/type/cs_location.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
Puppet::Type.newtype(:cs_location) do
@doc = "Type for manipulating corosync/pacemaker resource location.
More information on Corosync/Pacemaker colocation can be found here:
@@ -95,7 +97,7 @@ def insync?(is)
%w[corosync pacemaker]
end
- [:cs_primitive, :cs_clone, :cs_group].each do |type|
+ %i[cs_primitive cs_clone cs_group].each do |type|
autorequire(type) do
autos = []
autos << unmunge_cs_primitive(should(:primitive)) if should(:primitive)
@@ -106,14 +108,12 @@ def insync?(is)
def unmunge_cs_primitive(name)
name = name.split(':')[0]
- name = name[3..-1] if name.start_with? 'ms_'
+ name = name[3..] if name.start_with? 'ms_'
name
end
validate do
- if [self[:node_name], self[:rules]].compact.length > 1
- raise Puppet::Error, 'Location constraints dictate that node_name and rules cannot co-exist for this type.'
- end
+ raise Puppet::Error, 'Location constraints dictate that node_name and rules cannot co-exist for this type.' if [self[:node_name], self[:rules]].compact.length > 1
end
end
diff --git a/lib/puppet/type/cs_order.rb b/lib/puppet/type/cs_order.rb
index 1a08bb8f..60655d74 100644
--- a/lib/puppet/type/cs_order.rb
+++ b/lib/puppet/type/cs_order.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'puppet/property/boolean'
Puppet::Type.newtype(:cs_order) do
@@ -92,7 +94,7 @@
%w[corosync pacemaker]
end
- [:cs_clone, :cs_group, :cs_primitive].each do |resource_type|
+ %i[cs_clone cs_group cs_primitive].each do |resource_type|
autorequire(resource_type) do
autos = []
autos << unmunge_cs_resourcename(should(:first))
@@ -109,8 +111,9 @@
def unmunge_cs_resourcename(name)
return if name.nil?
+
name = name.split(':')[0]
- name = name[3..-1] if name.start_with? 'ms_'
+ name = name[3..] if name.start_with? 'ms_'
name
end
diff --git a/lib/puppet/type/cs_primitive.rb b/lib/puppet/type/cs_primitive.rb
index a94522e6..5400bcc7 100644
--- a/lib/puppet/type/cs_primitive.rb
+++ b/lib/puppet/type/cs_primitive.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: false
+
require 'puppet/parameter/boolean'
Puppet::Type.newtype(:cs_primitive) do
@@ -75,6 +77,7 @@
munge do |value|
return [value] if value.is_a?(String) || value.is_a?(Symbol)
+
value
end
@@ -220,9 +223,7 @@ def insync?(is)
super(is.reject { |k| @resource[:unmanaged_metadata].include?(k) })
end
- # rubocop:disable Style/PredicateName
def is_to_s(is)
- # rubocop:enable Style/PredicateName
super(is.reject { |k| @resource[:unmanaged_metadata].include?(k) })
end
diff --git a/lib/puppet/type/cs_property.rb b/lib/puppet/type/cs_property.rb
index 4a9682c3..d898ef63 100644
--- a/lib/puppet/type/cs_property.rb
+++ b/lib/puppet/type/cs_property.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'puppet/parameter/boolean'
Puppet::Type.newtype(:cs_property) do
diff --git a/lib/puppet/type/cs_rsc_defaults.rb b/lib/puppet/type/cs_rsc_defaults.rb
index 2f661723..9c2b57fb 100644
--- a/lib/puppet/type/cs_rsc_defaults.rb
+++ b/lib/puppet/type/cs_rsc_defaults.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
Puppet::Type.newtype(:cs_rsc_defaults) do
@doc = "Type for manipulating corosync/pacemaker global defaults for
resource options. The type is pretty simple interface for setting
diff --git a/lib/puppet/type/cs_shadow.rb b/lib/puppet/type/cs_shadow.rb
index 7cddbfbd..292333ad 100644
--- a/lib/puppet/type/cs_shadow.rb
+++ b/lib/puppet/type/cs_shadow.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
Puppet::Type.newtype(:cs_shadow) do
@doc = "cs_shadow resources represent a Corosync shadow CIB. Any corosync
resources defined with 'cib' set to the title of a cs_shadow resource
@@ -39,6 +41,7 @@ def change_to_s(currentvalue, _newvalue)
def generate
return [] if self[:autocommit] != true
+
options = { name: @title }
[Puppet::Type.type(:cs_commit).new(options)]
end
diff --git a/lib/puppet_x/voxpupuli/corosync/provider.rb b/lib/puppet_x/voxpupuli/corosync/provider.rb
index af9d4dcd..3eeda94d 100644
--- a/lib/puppet_x/voxpupuli/corosync/provider.rb
+++ b/lib/puppet_x/voxpupuli/corosync/provider.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module PuppetX
module Voxpupuli
module Corosync
diff --git a/lib/puppet_x/voxpupuli/corosync/provider/cib_helper.rb b/lib/puppet_x/voxpupuli/corosync/provider/cib_helper.rb
index 6bc01a08..96f46e4c 100644
--- a/lib/puppet_x/voxpupuli/corosync/provider/cib_helper.rb
+++ b/lib/puppet_x/voxpupuli/corosync/provider/cib_helper.rb
@@ -1,9 +1,12 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider'
rescue LoadError
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider'
end
@@ -69,21 +72,15 @@ def self.rule_expression(rulename, expressions, boolean_op = 'and')
rule_parameters = []
count = 0
- if boolean_op != 'and' && boolean_op != 'or'
- raise Puppet::Error, "boolean-op must be 'and' or 'or' in rule #{rulename}"
- end
+ raise Puppet::Error, "boolean-op must be 'and' or 'or' in rule #{rulename}" if boolean_op != 'and' && boolean_op != 'or'
expressions.each do |expr|
- rule_parameters << boolean_op if count > 0
+ rule_parameters << boolean_op if count.positive?
count += 1
- if expr['attribute'].nil?
- raise Puppet::Error, "attribute must be defined for expression #{count} in rule #{rulename}"
- end
+ raise Puppet::Error, "attribute must be defined for expression #{count} in rule #{rulename}" if expr['attribute'].nil?
- if expr['operation'].nil?
- raise Puppet::Error, "operation must be defined for expression #{count} in rule #{rulename}"
- end
+ raise Puppet::Error, "operation must be defined for expression #{count} in rule #{rulename}" if expr['operation'].nil?
attribute = expr['attribute']
operation = expr['operation']
@@ -94,9 +91,7 @@ def self.rule_expression(rulename, expressions, boolean_op = 'and')
rule_parameters << attribute
when 'lt', 'gt', 'lte', 'gte', 'eq', 'ne'
- if expr['value'].nil?
- raise Puppet::Error, "value must be defined for expression #{count} in rule #{rulename}"
- end
+ raise Puppet::Error, "value must be defined for expression #{count} in rule #{rulename}" if expr['value'].nil?
rule_parameters << attribute
rule_parameters << operation
@@ -114,6 +109,7 @@ def self.rule_expression(rulename, expressions, boolean_op = 'and')
def self._get_epoch(cmd, cib = nil)
raw, status = run_command_in_cib(cmd, cib, false)
return :absent if status.nonzero?
+
doc = REXML::Document.new(raw)
current_epoch = REXML::XPath.first(doc, '/cib').attributes['epoch']
current_admin_epoch = REXML::XPath.first(doc, '/cib').attributes['admin_epoch']
diff --git a/lib/puppet_x/voxpupuli/corosync/provider/crmsh.rb b/lib/puppet_x/voxpupuli/corosync/provider/crmsh.rb
index f07ecba3..c6d0f51d 100644
--- a/lib/puppet_x/voxpupuli/corosync/provider/crmsh.rb
+++ b/lib/puppet_x/voxpupuli/corosync/provider/crmsh.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider'
require 'puppet_x/voxpupuli/corosync/provider/cib_helper'
@@ -5,6 +7,7 @@
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider'
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/cib_helper'
end
@@ -24,6 +27,7 @@ class PuppetX::Voxpupuli::Corosync::Provider::Crmsh < PuppetX::Voxpupuli::Corosy
# rubocop:enable Style/ClassVars
def self.ready?(shadow_cib)
return true if @@crmready
+
cmd = [command(:crm_attribute), '--type', 'crm_config', '--query', '--name', 'dc-version']
raw, status = run_command_in_cib(cmd, nil, false)
if status.zero?
@@ -45,10 +49,10 @@ def self.ready?(shadow_cib)
# rubocop:enable Style/ClassVars
debug("Corosync is ready, CIB epoch is #{cib_epoch}.")
- return true
+ true
else
debug("Corosync not ready, retrying: #{raw}")
- return false
+ false
end
end
diff --git a/lib/puppet_x/voxpupuli/corosync/provider/pcs.rb b/lib/puppet_x/voxpupuli/corosync/provider/pcs.rb
index 3cb4e97b..12ace186 100644
--- a/lib/puppet_x/voxpupuli/corosync/provider/pcs.rb
+++ b/lib/puppet_x/voxpupuli/corosync/provider/pcs.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
begin
require 'puppet_x/voxpupuli/corosync/provider'
require 'puppet_x/voxpupuli/corosync/provider/cib_helper'
@@ -5,6 +7,7 @@
require 'pathname' # WORKAROUND #14073, #7788 and SERVER-973
corosync = Puppet::Module.find('corosync')
raise(LoadError, "Unable to find corosync module in modulepath #{Puppet[:basemodulepath] || Puppet[:modulepath]}") unless corosync
+
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider'
require File.join corosync.path, 'lib/puppet_x/voxpupuli/corosync/provider/cib_helper'
end
@@ -23,6 +26,7 @@ class PuppetX::Voxpupuli::Corosync::Provider::Pcs < PuppetX::Voxpupuli::Corosync
# rubocop:enable Style/ClassVars
def self.ready?(shadow_cib)
return true if @@pcsready
+
cmd = [command(:pcs), 'property', 'show', 'dc-version']
raw, status = run_command_in_cib(cmd, nil, false)
if status.zero?
@@ -45,10 +49,10 @@ def self.ready?(shadow_cib)
debug("Corosync is ready, CIB epoch is #{cib_epoch}. Sleeping 5 seconds for safety.")
sleep 5
- return true
+ true
else
debug("Corosync not ready, retrying: #{raw}")
- return false
+ false
end
end
@@ -78,7 +82,7 @@ def self.run_command_in_cib(cmd, cib = nil, failonfail = true)
unless cib.nil?
if cmd.first == command(:pcs)
- cib_path = File.join(Puppet[:vardir], 'shadow.' + cib)
+ cib_path = File.join(Puppet[:vardir], "shadow.#{cib}")
cmd.push('-f', cib_path)
else
custom_environment[:custom_environment] = { 'CIB_shadow_dir' => Puppet[:vardir], 'CIB_shadow' => cib }
@@ -89,9 +93,9 @@ def self.run_command_in_cib(cmd, cib = nil, failonfail = true)
end
def self.sync_shadow_cib(cib, failondeletefail = false)
- cib_path = File.join(Puppet[:vardir], 'shadow.' + cib)
+ cib_path = File.join(Puppet[:vardir], "shadow.#{cib}")
run_command_in_cib([command(:pcs), 'cluster', 'cib', cib_path], nil, failondeletefail)
- FileUtils.cp cib_path, cib_path + '.ori'
+ FileUtils.cp cib_path, "#{cib_path}.ori"
end
def exists?
diff --git a/manifests/init.pp b/manifests/init.pp
index 1b4fe15f..2250abae 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -402,7 +402,7 @@
Boolean $test_corosync_config = $corosync::params::test_corosync_config,
Optional[Variant[Stdlib::Absolutepath, Enum['off']]] $watchdog_device = undef,
Enum['pcs', 'crm'] $provider = 'pcs',
- String $pcs_version = '',
+ String $pcs_version = '', # lint:ignore:params_empty_string_assignment
) inherits corosync::params {
if $set_votequorum and (empty($quorum_members) and empty($multicast_address) and !$cluster_name) {
fail('set_votequorum is true, so you must set either quorum_members, or one of multicast_address or cluster_name.')
diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb
index 2b00cfde..38a44e08 100644
--- a/spec/acceptance/basic_spec.rb
+++ b/spec/acceptance/basic_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
# These tests are designed to ensure that the module, when ran with defaults,
@@ -22,7 +24,7 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
diff --git a/spec/acceptance/corosync_class_spec.rb b/spec/acceptance/corosync_class_spec.rb
index af26682c..daa4bed9 100644
--- a/spec/acceptance/corosync_class_spec.rb
+++ b/spec/acceptance/corosync_class_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
# These tests are designed to ensure that the module, when ran with defaults,
@@ -22,7 +24,7 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
it 'with only cluster_name' do
pp = <<-EOS
file { '/tmp/ca.pem':
diff --git a/spec/acceptance/cs_clone_spec.rb b/spec/acceptance/cs_clone_spec.rb
index 618590f7..add7f18c 100755
--- a/spec/acceptance/cs_clone_spec.rb
+++ b/spec/acceptance/cs_clone_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
describe 'corosync' do
@@ -20,7 +22,11 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
+ after :all do
+ cleanup_cs_resources
+ end
+
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
@@ -75,7 +81,7 @@ class { 'corosync':
ensure => present,
#{type} => '#{property_value}',
}
- EOS
+ EOS
apply_manifest(pp, catch_failures: true, debug: false, trace: true)
apply_manifest(pp, catch_changes: true, debug: false, trace: true)
command = "cibadmin --query | grep duncan_vip_clone_#{type}"
@@ -93,7 +99,7 @@ class { 'corosync':
cs_clone { 'duncan_vip_clone_#{type}':
ensure => absent,
}
- EOS
+ EOS
apply_manifest(pp, catch_failures: true, debug: false, trace: true)
apply_manifest(pp, catch_changes: true, debug: false, trace: true)
command = "cibadmin --query | grep duncan_vip_clone_#{type}"
@@ -123,7 +129,7 @@ def fetch_value_command(name)
ordered => false,
interleave => false,
}
- EOS
+ EOS
apply_manifest(pp, catch_failures: true, debug: false, trace: true)
apply_manifest(pp, catch_changes: true, debug: false, trace: true)
@@ -184,7 +190,7 @@ def fetch_value_command(name)
ordered => true,
interleave => true,
}
- EOS
+ EOS
apply_manifest(pp, catch_failures: true, debug: false, trace: true)
apply_manifest(pp, catch_changes: true, debug: false, trace: true)
@@ -237,7 +243,7 @@ def fetch_value_command(name)
clone_max => 43,
interleave => true,
}
- EOS
+ EOS
apply_manifest(pp, catch_failures: true, debug: false, trace: true)
apply_manifest(pp, catch_changes: true, debug: false, trace: true)
@@ -311,8 +317,4 @@ def fetch_value_command(name)
apply_manifest(pp, catch_changes: true, debug: false, trace: true)
end
end
-
- after :all do
- cleanup_cs_resources
- end
end
diff --git a/spec/acceptance/cs_colocation_spec.rb b/spec/acceptance/cs_colocation_spec.rb
index e6b428ea..75127839 100644
--- a/spec/acceptance/cs_colocation_spec.rb
+++ b/spec/acceptance/cs_colocation_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
describe 'corosync' do
@@ -20,7 +22,11 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
+ after :all do
+ cleanup_cs_resources
+ end
+
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
@@ -105,8 +111,4 @@ class { 'corosync':
expect(r.stdout).to match(%r{colocation.*\srsc="nginx_service"})
end
end
-
- after :all do
- cleanup_cs_resources
- end
end
diff --git a/spec/acceptance/cs_commit_spec.rb b/spec/acceptance/cs_commit_spec.rb
index 827f6cff..dff1f2b9 100644
--- a/spec/acceptance/cs_commit_spec.rb
+++ b/spec/acceptance/cs_commit_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
describe 'corosync' do
@@ -22,7 +24,11 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
+ after :all do
+ cleanup_cs_resources
+ end
+
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
@@ -183,8 +189,4 @@ class { 'corosync':
expect(r.stdout).to match(%r{colocation.*\srsc="apache2_service"})
end
end
-
- after :all do
- cleanup_cs_resources
- end
end
diff --git a/spec/acceptance/cs_group_spec.rb b/spec/acceptance/cs_group_spec.rb
index 585a5cca..ec356d30 100755
--- a/spec/acceptance/cs_group_spec.rb
+++ b/spec/acceptance/cs_group_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
describe 'corosync' do
@@ -20,7 +22,11 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
+ after :all do
+ cleanup_cs_resources
+ end
+
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
@@ -110,8 +116,4 @@ class { 'corosync':
it 'DEBUG' do
shell('cibadmin --query')
end
-
- after :all do
- cleanup_cs_resources
- end
end
diff --git a/spec/acceptance/cs_location_spec.rb b/spec/acceptance/cs_location_spec.rb
index d476b5a0..34d4bbb7 100755
--- a/spec/acceptance/cs_location_spec.rb
+++ b/spec/acceptance/cs_location_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
describe 'corosync' do
@@ -20,7 +22,11 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
+ after :all do
+ cleanup_cs_resources
+ end
+
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
@@ -236,8 +242,4 @@ class { 'corosync':
end
end
end
-
- after :all do
- cleanup_cs_resources
- end
end
diff --git a/spec/acceptance/cs_order_spec.rb b/spec/acceptance/cs_order_spec.rb
index 89837f60..a97e1802 100644
--- a/spec/acceptance/cs_order_spec.rb
+++ b/spec/acceptance/cs_order_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
describe 'corosync' do
@@ -20,7 +22,11 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
+ after :all do
+ cleanup_cs_resources
+ end
+
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
@@ -166,8 +172,4 @@ class { 'corosync':
end
end
end
-
- after :all do
- cleanup_cs_resources
- end
end
diff --git a/spec/acceptance/cs_primitive_spec.rb b/spec/acceptance/cs_primitive_spec.rb
index 6d735de8..7ffdb6f1 100644
--- a/spec/acceptance/cs_primitive_spec.rb
+++ b/spec/acceptance/cs_primitive_spec.rb
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
-require 'pry'
describe 'corosync' do
cert = '-----BEGIN CERTIFICATE-----
@@ -21,7 +22,11 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
+ after :all do
+ cleanup_cs_resources
+ end
+
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
@@ -332,8 +337,4 @@ class { 'corosync':
end
end
end
-
- after :all do
- cleanup_cs_resources
- end
end
diff --git a/spec/acceptance/cs_rsc_defaults_spec.rb b/spec/acceptance/cs_rsc_defaults_spec.rb
index 3fa942dc..581efe06 100644
--- a/spec/acceptance/cs_rsc_defaults_spec.rb
+++ b/spec/acceptance/cs_rsc_defaults_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
describe 'corosync' do
@@ -21,7 +23,7 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
it 'creates a rsc_defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
diff --git a/spec/acceptance/cs_shadow_spec.rb b/spec/acceptance/cs_shadow_spec.rb
index 5c7312f5..05cbc1a7 100644
--- a/spec/acceptance/cs_shadow_spec.rb
+++ b/spec/acceptance/cs_shadow_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper_acceptance'
describe 'corosync' do
@@ -22,7 +24,11 @@
japvs+0tdy9iwHj3z1ZME2Ntm/5TzG537e7Hb2zogatM9aBTUAWlZ1tpoaXuTH52
J76GtqoIOh+CTeY/BMwBotdQdgeR0zvjE9FuLWkhTmRtVFhbVIzJbFlFuYq5d3LH
NWyN0RsTXFaqowV1/HSyvfD7LoF/CrmN5gOAM3Ierv/Ti9uqGVhdGBd/kw=='
- File.open('/tmp/ca.pem', 'w') { |f| f.write(cert) }
+ File.write('/tmp/ca.pem', cert)
+ after :all do
+ cleanup_cs_resources
+ end
+
it 'with defaults' do
pp = <<-EOS
file { '/tmp/ca.pem':
@@ -189,7 +195,7 @@ class { 'corosync':
primitive => 'apache3_vip',
cib => 'puppet',
}
- EOS
+ EOS
apply_manifest(pp, catch_failures: true, debug: false, trace: true)
apply_manifest(pp, expect_changes: true, debug: false, trace: true)
command = if fact('default_provider') == 'pcs'
@@ -201,8 +207,4 @@ class { 'corosync':
expect(r.stdout).to match(%r{ true) }
@@ -1042,6 +1047,7 @@
require: 'Exec[authorize_qdevice]'
)
end
+
it 'contains the quorum configuration' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r!quorum {
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 50265422..ad70e4c9 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
@@ -7,19 +9,20 @@
# puppetlabs_spec_helper will set up coverage if the env variable is set.
# We want to do this if lib exists and it hasn't been explicitly set.
-ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__))
+ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__))
require 'voxpupuli/test/spec_helper'
+add_mocked_facts!
+
if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
- if facts
- facts.each do |name, value|
- add_custom_fact name.to_sym, value
- end
+ facts&.each do |name, value|
+ add_custom_fact name.to_sym, value
end
end
require 'spec_helper_corosync'
require 'spec_helper_methods'
+Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f }
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index bbf7f9bb..0ee5e434 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'voxpupuli/acceptance/spec_helper_acceptance'
configure_beaker do |host|
@@ -15,16 +17,12 @@
default_provider = 'pcs'
pcs_version = '0.10.0'
when 'Ubuntu'
- if fact_on(host, 'os.release.major').to_i > 18
- default_provider = 'pcs'
- pcs_version = '0.10.0'
- elsif fact_on(host, 'os.release.major').to_i > 16
- default_provider = 'pcs'
- pcs_version = '0.9.0'
- else
- default_provider = 'crm'
- pcs_version = ''
- end
+ default_provider = 'pcs'
+ pcs_version = if fact_on(host, 'os.release.major').to_i > 18
+ '0.10.0'
+ else
+ '0.9.0'
+ end
end
when 'Suse'
default_provider = 'crm'
@@ -64,7 +62,7 @@ def cleanup_cs_resources
resources { 'cs_location' :
purge => true,
}
- EOS
+ EOS
apply_manifest(pp, catch_failures: true, debug: false, trace: true)
apply_manifest(pp, catch_changes: true, debug: false, trace: true)
@@ -73,7 +71,7 @@ def cleanup_cs_resources
resources { 'cs_primitive' :
purge => true,
}
- EOS
+ EOS
apply_manifest(pp, catch_failures: true, debug: false, trace: true)
apply_manifest(pp, catch_changes: true, debug: false, trace: true)
diff --git a/spec/spec_helper_corosync.rb b/spec/spec_helper_corosync.rb
index 2bb231e2..a726ae86 100644
--- a/spec/spec_helper_corosync.rb
+++ b/spec/spec_helper_corosync.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
# This file contains helpers that are specific to this module
def corosync_stack(facts)
@@ -15,16 +17,12 @@ def corosync_stack(facts)
corosync_stack = 'pcs'
pcs_version = '0.10.0'
when 'Ubuntu'
- if facts[:os]['release']['major'].to_i > 18
- corosync_stack = 'pcs'
- pcs_version = '0.10.0'
- elsif facts[:os]['release']['major'].to_i > 16
- corosync_stack = 'pcs'
- pcs_version = '0.9.0'
- else
- corosync_stack = 'crm'
- pcs_version = ''
- end
+ corosync_stack = 'pcs'
+ pcs_version = if facts[:os]['release']['major'].to_i > 18
+ '0.10.0'
+ else
+ '0.9.0'
+ end
end
when 'Suse'
corosync_stack = 'crm'
diff --git a/spec/spec_helper_methods.rb b/spec/spec_helper_methods.rb
index 0b621af5..1e3408ec 100644
--- a/spec/spec_helper_methods.rb
+++ b/spec/spec_helper_methods.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
RSpec.configure do |c|
c.alias_it_should_behave_like_to :it_configures, 'configures'
c.expect_with :rspec do |r|
diff --git a/spec/unit/puppet/provider/cs_clone_crm_spec.rb b/spec/unit/puppet/provider/cs_clone_crm_spec.rb
index f206337c..4b3b03d4 100644
--- a/spec/unit/puppet/provider/cs_clone_crm_spec.rb
+++ b/spec/unit/puppet/provider/cs_clone_crm_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_clone).provider(:crm) do
@@ -40,7 +42,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
@@ -102,7 +104,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
@@ -123,16 +125,12 @@
def expect_update(pattern)
if Puppet::Util::Package.versioncmp(Puppet::PUPPETVERSION, '3.4') == -1
Puppet::Util::SUIDManager.expects(:run_and_capture).with do |*args|
- if args.slice(0..2) == %w[configure load update]
- expect(File.read(args[3])).to match(pattern)
- end
+ expect(File.read(args[3])).to match(pattern) if args.slice(0..2) == %w[configure load update]
true
end.at_least_once.returns(['', 0])
else
Puppet::Util::Execution.expects(:execute).with do |*args|
- if args.slice(0..2) == %w[configure load update]
- expect(File.read(args[3])).to match(pattern)
- end
+ expect(File.read(args[3])).to match(pattern) if args.slice(0..2) == %w[configure load update]
true
end.at_least_once.returns(
Puppet::Util::Execution::ProcessOutput.new('', 0)
@@ -142,10 +140,10 @@ def expect_update(pattern)
let :resource do
Puppet::Type.type(:cs_clone).new(
- name: 'p_keystone-clone',
- provider: :crm,
+ name: 'p_keystone-clone',
+ provider: :crm,
primitive: 'p_keystone',
- ensure: :present
+ ensure: :present
)
end
diff --git a/spec/unit/puppet/provider/cs_clone_pcs_spec.rb b/spec/unit/puppet/provider/cs_clone_pcs_spec.rb
index 42fc162b..ca96419b 100644
--- a/spec/unit/puppet/provider/cs_clone_pcs_spec.rb
+++ b/spec/unit/puppet/provider/cs_clone_pcs_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
require 'spec_helper_corosync'
@@ -40,7 +42,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
@@ -99,7 +101,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
@@ -119,10 +121,10 @@
context 'when flushing' do
let :resource do
Puppet::Type.type(:cs_clone).new(
- name: 'p_keystone-clone',
+ name: 'p_keystone-clone',
primitive: 'p_keystone',
- provider: :pcs,
- ensure: :present
+ provider: :pcs,
+ ensure: :present
)
end
@@ -180,19 +182,19 @@
context 'when changing clone id' do
def clone_xml(name)
- <<-EOS
-
-
-
-
-
-
-
-
-
-
-
-
+ <<~EOS
+
+
+
+
+
+
+
+
+
+
+
+
EOS
end
diff --git a/spec/unit/puppet/provider/cs_colocation_crm_spec.rb b/spec/unit/puppet/provider/cs_colocation_crm_spec.rb
index 9631a4d7..102edf02 100644
--- a/spec/unit/puppet/provider/cs_colocation_crm_spec.rb
+++ b/spec/unit/puppet/provider/cs_colocation_crm_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_colocation).provider(:crm) do
@@ -38,8 +40,8 @@
instances.first
end
- it "should be a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ it "is a kind of #{described_class.name}" do
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
@@ -64,16 +66,12 @@
def expect_update(pattern)
if Puppet::Util::Package.versioncmp(Puppet::PUPPETVERSION, '3.4') == -1
Puppet::Util::SUIDManager.expects(:run_and_capture).with do |*args|
- if args.slice(0..2) == %w[configure load update]
- expect(File.read(args[3])).to match(pattern)
- end
+ expect(File.read(args[3])).to match(pattern) if args.slice(0..2) == %w[configure load update]
true
end.at_least_once.returns(['', 0])
else
Puppet::Util::Execution.expects(:execute).with do |*args|
- if args.slice(0..2) == %w[configure load update]
- expect(File.read(args[3])).to match(pattern)
- end
+ expect(File.read(args[3])).to match(pattern) if args.slice(0..2) == %w[configure load update]
true
end.at_least_once.returns(
Puppet::Util::Execution::ProcessOutput.new('', 0)
@@ -84,10 +82,10 @@ def expect_update(pattern)
context 'with 2 primitives' do
let :resource do
Puppet::Type.type(:cs_colocation).new(
- name: 'first_with_second',
- provider: :crm,
+ name: 'first_with_second',
+ provider: :crm,
primitives: %w[first second],
- ensure: :present
+ ensure: :present
)
end
@@ -130,10 +128,10 @@ def expect_update(pattern)
context 'with 3 or more primitives' do
let :resource do
Puppet::Type.type(:cs_colocation).new(
- name: 'first_with_second_with_third',
- provider: :crm,
+ name: 'first_with_second_with_third',
+ provider: :crm,
primitives: %w[first second third],
- ensure: :present
+ ensure: :present
)
end
diff --git a/spec/unit/puppet/provider/cs_group_crm_spec.rb b/spec/unit/puppet/provider/cs_group_crm_spec.rb
index 9ce7786d..4f310dbf 100644
--- a/spec/unit/puppet/provider/cs_group_crm_spec.rb
+++ b/spec/unit/puppet/provider/cs_group_crm_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_group).provider(:crm) do
@@ -65,8 +67,8 @@
instances.first
end
- it "should be a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ it "is a kind of #{described_class.name}" do
+ expect(instance).to be_a(described_class)
end
it 'is named by the group id attribute' do
diff --git a/spec/unit/puppet/provider/cs_group_pcs_spec.rb b/spec/unit/puppet/provider/cs_group_pcs_spec.rb
index 72c7ca54..e752aaa2 100644
--- a/spec/unit/puppet/provider/cs_group_pcs_spec.rb
+++ b/spec/unit/puppet/provider/cs_group_pcs_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_group).provider(:pcs) do
@@ -60,8 +62,8 @@
instances.first
end
- it "should be a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ it "is a kind of #{described_class.name}" do
+ expect(instance).to be_a(described_class)
end
it 'is named by the group id attribute' do
diff --git a/spec/unit/puppet/provider/cs_location_pcs_spec.rb b/spec/unit/puppet/provider/cs_location_pcs_spec.rb
index 1657fe73..3e2c6ef7 100644
--- a/spec/unit/puppet/provider/cs_location_pcs_spec.rb
+++ b/spec/unit/puppet/provider/cs_location_pcs_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_location).provider(:pcs) do
@@ -35,8 +37,8 @@
instances.first
end
- it "should be a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ it "is a kind of #{described_class.name}" do
+ expect(instance).to be_a(described_class)
end
end
diff --git a/spec/unit/puppet/provider/cs_order_crm_spec.rb b/spec/unit/puppet/provider/cs_order_crm_spec.rb
index 28e2e4a3..71bc541b 100644
--- a/spec/unit/puppet/provider/cs_order_crm_spec.rb
+++ b/spec/unit/puppet/provider/cs_order_crm_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_order).provider(:crm) do
@@ -36,14 +38,15 @@
instances.first
end
- it "should be a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ it "is a kind of #{described_class.name}" do
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
expect(instance.name).to eq('nul-messagebus_before_nul-interface-2')
end
end
+
describe 'first instance' do
let :instance do
instances.first
@@ -62,7 +65,7 @@
end
it 'has symmetrical set to true' do
- expect(instance.symmetrical).to eq(true)
+ expect(instance.symmetrical).to be(true)
end
end
@@ -84,7 +87,7 @@
end
it 'has symmetrical set to false' do
- expect(instance.symmetrical).to eq(false)
+ expect(instance.symmetrical).to be(false)
end
end
end
diff --git a/spec/unit/puppet/provider/cs_order_pcs_spec.rb b/spec/unit/puppet/provider/cs_order_pcs_spec.rb
index c7e456d7..347c6793 100644
--- a/spec/unit/puppet/provider/cs_order_pcs_spec.rb
+++ b/spec/unit/puppet/provider/cs_order_pcs_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_order).provider(:pcs) do
@@ -29,14 +31,15 @@
instances.first
end
- it "should be a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ it "is a kind of #{described_class.name}" do
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
expect(instance.name).to eq('nul-messagebus_before_nul-interface-2')
end
end
+
describe 'first instance' do
let :instance do
instances.first
@@ -55,7 +58,7 @@
end
it 'has symmetrical set to true' do
- expect(instance.symmetrical).to eq(true)
+ expect(instance.symmetrical).to be(true)
end
end
@@ -77,7 +80,7 @@
end
it 'has symmetrical set to false' do
- expect(instance.symmetrical).to eq(false)
+ expect(instance.symmetrical).to be(false)
end
end
end
diff --git a/spec/unit/puppet/provider/cs_primitive_crm_spec.rb b/spec/unit/puppet/provider/cs_primitive_crm_spec.rb
index a4316303..2f3e08bc 100644
--- a/spec/unit/puppet/provider/cs_primitive_crm_spec.rb
+++ b/spec/unit/puppet/provider/cs_primitive_crm_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_primitive).provider(:crm) do
@@ -54,7 +56,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
@@ -82,10 +84,7 @@
end
it 'has an operations property corresponding to ' do
- expect(instance.operations).to match_array([{ 'monitor' => { 'interval' => '15', 'timeout' => '10', 'on-fail' => 'standby', 'OCF_CHECK_LEVEL' => '10' } },
- { 'monitor' => { 'interval' => '5', 'timeout' => '10', 'on-fail' => 'standby', 'role' => 'Master' } },
- { 'start' => { 'interval' => '0', 'timeout' => '60' } },
- { 'stop' => { 'interval' => '0', 'timeout' => '40' } }])
+ expect(instance.operations).to contain_exactly({ 'monitor' => { 'interval' => '15', 'timeout' => '10', 'on-fail' => 'standby', 'OCF_CHECK_LEVEL' => '10' } }, { 'monitor' => { 'interval' => '5', 'timeout' => '10', 'on-fail' => 'standby', 'role' => 'Master' } }, { 'start' => { 'interval' => '0', 'timeout' => '60' } }, { 'stop' => { 'interval' => '0', 'timeout' => '40' } })
end
it 'has a utilization property corresponding to ' do
@@ -119,16 +118,12 @@
def expect_update(pattern)
if Puppet::Util::Package.versioncmp(Puppet::PUPPETVERSION, '3.4') == -1
Puppet::Util::SUIDManager.expects(:run_and_capture).with do |*args|
- if args.slice(0..2) == %w[configure load update]
- expect(File.read(args[3])).to match(pattern)
- end
+ expect(File.read(args[3])).to match(pattern) if args.slice(0..2) == %w[configure load update]
true
end.at_least_once.returns(['', 0])
else
Puppet::Util::Execution.expects(:execute).with do |*args|
- if args.slice(0..2) == %w[configure load update]
- expect(File.read(args[3])).to match(pattern)
- end
+ expect(File.read(args[3])).to match(pattern) if args.slice(0..2) == %w[configure load update]
true
end.at_least_once.returns(
Puppet::Util::Execution::ProcessOutput.new('', 0)
diff --git a/spec/unit/puppet/provider/cs_primitive_pcs_spec.rb b/spec/unit/puppet/provider/cs_primitive_pcs_spec.rb
index 2c2960b7..09e76eb6 100644
--- a/spec/unit/puppet/provider/cs_primitive_pcs_spec.rb
+++ b/spec/unit/puppet/provider/cs_primitive_pcs_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
require 'spec_helper_corosync'
@@ -44,7 +46,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's id attribute" do
@@ -76,47 +78,47 @@
context 'when flushing' do
let :instances do
- cib = <<-EOS
-
-
-
-
-
-
-
-
-
-
-
-
-h
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ cib = <<~EOS
+
+
+
+
+
+
+
+
+
+
+
+
+ h
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
EOS
pcs_load_cib(cib)
diff --git a/spec/unit/puppet/provider/cs_property_crm_spec.rb b/spec/unit/puppet/provider/cs_property_crm_spec.rb
index 6e6ddc07..8b8324e8 100644
--- a/spec/unit/puppet/provider/cs_property_crm_spec.rb
+++ b/spec/unit/puppet/provider/cs_property_crm_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_property).provider(:crm) do
@@ -40,7 +42,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's name attribute" do
diff --git a/spec/unit/puppet/provider/cs_property_pcs_spec.rb b/spec/unit/puppet/provider/cs_property_pcs_spec.rb
index 4355999e..524e073d 100644
--- a/spec/unit/puppet/provider/cs_property_pcs_spec.rb
+++ b/spec/unit/puppet/provider/cs_property_pcs_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_property).provider(:pcs) do
@@ -35,7 +37,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's name attribute" do
diff --git a/spec/unit/puppet/provider/cs_rsc_defaults_crm_spec.rb b/spec/unit/puppet/provider/cs_rsc_defaults_crm_spec.rb
index 016faf7b..0c70287f 100644
--- a/spec/unit/puppet/provider/cs_rsc_defaults_crm_spec.rb
+++ b/spec/unit/puppet/provider/cs_rsc_defaults_crm_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_rsc_defaults).provider(:crm) do
@@ -37,7 +39,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's name attribute" do
diff --git a/spec/unit/puppet/provider/cs_rsc_defaults_pcs_spec.rb b/spec/unit/puppet/provider/cs_rsc_defaults_pcs_spec.rb
index cf41c400..ff27334b 100644
--- a/spec/unit/puppet/provider/cs_rsc_defaults_pcs_spec.rb
+++ b/spec/unit/puppet/provider/cs_rsc_defaults_pcs_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_rsc_defaults).provider(:pcs) do
@@ -32,7 +34,7 @@
end
it "is a kind of #{described_class.name}" do
- expect(instance).to be_a_kind_of(described_class)
+ expect(instance).to be_a(described_class)
end
it "is named by the 's name attribute" do
diff --git a/spec/unit/puppet/type/cs_clone_spec.rb b/spec/unit/puppet/type/cs_clone_spec.rb
index e98425f4..47a83409 100644
--- a/spec/unit/puppet/type/cs_clone_spec.rb
+++ b/spec/unit/puppet/type/cs_clone_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_clone) do
@@ -17,41 +19,41 @@
expect(subject.new(name: 'mock_clone', primitive: 'mock_primitive')).not_to be_nil
end
- [:name, :cib].each do |param|
- it "should have a #{param} parameter" do
+ %i[name cib].each do |param|
+ it "has a #{param} parameter" do
expect(subject).to be_validparameter(param)
end
- it "should have documentation for its #{param} parameter" do
+ it "has documentation for its #{param} parameter" do
expect(subject.paramclass(param).doc).to be_instance_of(String)
end
end
- [:primitive, :clone_max, :clone_node_max, :notify_clones, :globally_unique,
- :ordered, :interleave].each do |property|
- it "should have a #{property} property" do
+ %i[primitive clone_max clone_node_max notify_clones globally_unique
+ ordered interleave].each do |property|
+ it "has a #{property} property" do
expect(subject).to be_validproperty(property)
end
- it "should have documentation for its #{property} property" do
+ it "has documentation for its #{property} property" do
expect(subject.propertybyname(property).doc).to be_instance_of(String)
end
end
end
describe 'when validating attributes' do
- [:notify_clones, :globally_unique, :ordered, :interleave].each do |attribute|
- it "should validate that the #{attribute} attribute can be true/false" do
+ %i[notify_clones globally_unique ordered interleave].each do |attribute|
+ it "validates that the #{attribute} attribute can be true/false" do
[true, false].each do |value|
expect(subject.new(
- name: 'mock_clone',
+ name: 'mock_clone',
primitive: 'mock_primitive',
attribute => value
)[attribute]).to eq(value.to_s.to_sym)
end
end
- it "should validate that the #{attribute} attribute cannot be other values" do
+ it "validates that the #{attribute} attribute cannot be other values" do
['fail', 42].each do |value|
expect { subject.new(name: 'mock_clone', attribute => value) }. \
to raise_error Puppet::Error, %r{(true|false)}
@@ -80,6 +82,7 @@
it 'has apache primitive as source of autorequire' do
expect(autorequire_relationship.source).to eq apache_primitive
end
+
it 'has apache clone as target of autorequire' do
expect(autorequire_relationship.target).to eq apache_clone
end
@@ -119,6 +122,7 @@
it 'has apache group as source of autorequire' do
expect(autorequire_relationship.source).to eq apache_group
end
+
it 'has apache clone as target of autorequire' do
expect(autorequire_relationship.target).to eq apache_clone
end
diff --git a/spec/unit/puppet/type/cs_group_spec.rb b/spec/unit/puppet/type/cs_group_spec.rb
index 01faf37a..9895b6ef 100644
--- a/spec/unit/puppet/type/cs_group_spec.rb
+++ b/spec/unit/puppet/type/cs_group_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_group) do
@@ -17,22 +19,22 @@
expect(subject.new(name: 'mock_group')).not_to be_nil
end
- [:name, :cib].each do |param|
- it "should have a #{param} parameter" do
+ %i[name cib].each do |param|
+ it "has a #{param} parameter" do
expect(subject).to be_validparameter(param)
end
- it "should have documentation for its #{param} parameter" do
+ it "has documentation for its #{param} parameter" do
expect(subject.paramclass(param).doc).to be_instance_of(String)
end
end
[:primitives].each do |property|
- it "should have a #{property} property" do
+ it "has a #{property} property" do
expect(subject).to be_validproperty(property)
end
- it "should have documentation for its #{property} property" do
+ it "has documentation for its #{property} property" do
expect(subject.propertybyname(property).doc).to be_instance_of(String)
end
end
@@ -58,6 +60,7 @@
it 'has apache primitive as source of autorequire' do
expect(autorequire_relationship.source).to eq apache_primitive
end
+
it 'has apache group as target of autorequire' do
expect(autorequire_relationship.target).to eq apache_group
end
diff --git a/spec/unit/puppet/type/cs_location_spec.rb b/spec/unit/puppet/type/cs_location_spec.rb
index a4fb988e..dcc86046 100644
--- a/spec/unit/puppet/type/cs_location_spec.rb
+++ b/spec/unit/puppet/type/cs_location_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_location) do
@@ -17,22 +19,22 @@
expect(subject.new(name: 'mock_location')).not_to be_nil
end
- [:name, :cib].each do |param|
- it "should have a #{param} parameter" do
+ %i[name cib].each do |param|
+ it "has a #{param} parameter" do
expect(subject).to be_validparameter(param)
end
- it "should have documentation for its #{param} parameter" do
+ it "has documentation for its #{param} parameter" do
expect(subject.paramclass(param).doc).to be_instance_of(String)
end
end
- [:primitive, :node_name, :resource_discovery, :score, :rules].each do |property|
- it "should have a #{property} property" do
+ %i[primitive node_name resource_discovery score rules].each do |property|
+ it "has a #{property} property" do
expect(subject).to be_validproperty(property)
end
- it "should have documentation for its #{property} property" do
+ it "has documentation for its #{property} property" do
expect(subject.propertybyname(property).doc).to be_instance_of(String)
end
end
@@ -58,6 +60,7 @@
it 'has apache primitive as source of autorequire' do
expect(autorequire_relationship.source).to eq apache_primitive
end
+
it 'has apache location as target of autorequire' do
expect(autorequire_relationship.target).to eq apache_location
end
@@ -123,6 +126,7 @@
it 'has apache clone as source of autorequire' do
expect(autorequire_relationship.source).to eq apache_clone
end
+
it 'has apache location as target of autorequire' do
expect(autorequire_relationship.target).to eq apache_location
end
@@ -147,6 +151,7 @@
it 'has apache group as source of autorequire' do
expect(autorequire_relationship.source).to eq apache_group
end
+
it 'has apache location as target of autorequire' do
expect(autorequire_relationship.target).to eq apache_location
end
diff --git a/spec/unit/puppet/type/cs_primitive_spec.rb b/spec/unit/puppet/type/cs_primitive_spec.rb
index 4ce95343..242db812 100644
--- a/spec/unit/puppet/type/cs_primitive_spec.rb
+++ b/spec/unit/puppet/type/cs_primitive_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_primitive) do
@@ -17,37 +19,37 @@
expect(subject.new(name: 'mock_primitive')).not_to be_nil
end
- [:name, :primitive_class, :primitive_type, :provided_by, :cib].each do |param|
- it "should have a #{param} parameter" do
+ %i[name primitive_class primitive_type provided_by cib].each do |param|
+ it "has a #{param} parameter" do
expect(subject).to be_validparameter(param)
end
- it "should have documentation for its #{param} parameter" do
+ it "has documentation for its #{param} parameter" do
expect(subject.paramclass(param).doc).to be_instance_of(String)
end
end
- [:parameters, :operations, :metadata].each do |property|
- it "should have a #{property} property" do
+ %i[parameters operations metadata].each do |property|
+ it "has a #{property} property" do
expect(subject).to be_validproperty(property)
end
- it "should have documentation for its #{property} property" do
+ it "has documentation for its #{property} property" do
expect(subject.propertybyname(property).doc).to be_instance_of(String)
end
end
end
describe 'when validating attributes' do
- [:parameters, :operations, :metadata].each do |attribute|
- it "should validate that the #{attribute} attribute defaults to a hash" do
+ %i[parameters operations metadata].each do |attribute|
+ it "validates that the #{attribute} attribute defaults to a hash" do
expect(subject.new(name: 'mock_primitive')[:parameters]).to eq({})
end
- it "should validate that the #{attribute} attribute must be a hash" do
+ it "validates that the #{attribute} attribute must be a hash" do
expect do
subject.new(
- name: 'mock_primitive',
+ name: 'mock_primitive',
parameters: 'fail'
)
end.to raise_error Puppet::Error, %r{hash}
@@ -66,6 +68,7 @@
{ 'stop' => { 'interval' => '10' } }
])
end
+
it 'converts hashes into array' do
Puppet.expects(:deprecation_warning).never
expect(subject.new(
@@ -76,6 +79,7 @@
{ 'stop' => { 'interval' => '10' } }
])
end
+
it 'converts hashes into array with correct roles' do
Puppet.expects(:deprecation_warning).once
expect(subject.new(
@@ -86,6 +90,7 @@
{ 'stop' => { 'interval' => '10', 'role' => 'Master' } }
])
end
+
it 'converts sub-arrays into array' do
Puppet.expects(:deprecation_warning).once
expect(subject.new(
@@ -97,6 +102,7 @@
{ 'stop' => { 'interval' => '10' } }
])
end
+
it 'converts sub-arrays into array with correct roles' do # That case probably never happens in practice
Puppet.expects(:deprecation_warning).twice
expect(subject.new(
diff --git a/spec/unit/puppet/type/cs_property_spec.rb b/spec/unit/puppet/type/cs_property_spec.rb
index 49b84dde..6a4d359c 100644
--- a/spec/unit/puppet/type/cs_property_spec.rb
+++ b/spec/unit/puppet/type/cs_property_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Puppet::Type.type(:cs_property) do
@@ -13,21 +15,21 @@
end
[:replace].each do |param|
- it "should have a #{param} parameter" do
+ it "has a #{param} parameter" do
expect(subject).to be_validparameter(param)
end
- it "should have documentation for its #{param} parameter" do
+ it "has documentation for its #{param} parameter" do
expect(subject.paramclass(param).doc).to be_instance_of(String)
end
end
[:value].each do |property|
- it "should have a #{property} property" do
+ it "has a #{property} property" do
expect(subject).to be_validproperty(property)
end
- it "should have documentation for its #{property} property" do
+ it "has documentation for its #{property} property" do
expect(subject.propertybyname(property).doc).to be_instance_of(String)
end
end