diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ecb10a8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# editorconfig.org + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +tab_width = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..6aaa603 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,254 @@ +# Contribution guidelines + +## Table of contents + +* [Contributing](#contributing) +* [Writing proper commits - short version](#writing-proper-commits-short-version) +* [Writing proper commits - long version](#writing-proper-commits-long-version) +* [Dependencies](#dependencies) + * [Note for OS X users](#note-for-os-x-users) +* [The test matrix](#the-test-matrix) +* [Syntax and style](#syntax-and-style) +* [Running the unit tests](#running-the-unit-tests) +* [Unit tests in docker](#unit-tests-in-docker) +* [Integration tests](#integration-tests) + +This module has grown over time based on a range of contributions from +people using it. If you follow these contributing guidelines your patch +will likely make it into a release a little more quickly. + +## Contributing + +Please note that this project is released with a Contributor Code of Conduct. +By participating in this project you agree to abide by its terms. +[Contributor Code of Conduct](https://voxpupuli.org/coc/). + +* Fork the repo. +* Create a separate branch for your change. +* We only take pull requests with passing tests, and documentation. [GitHub Actions](https://docs.github.com/en/actions) run the tests for us. You can also execute them locally. This is explained [in a later section](#the-test-matrix). +* Checkout [our docs](https://voxpupuli.org/docs/reviewing_pr/) we use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html). They provide some guidance for new code that might help you before you submit a pull request. +* Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, please add a test. +* Squash your commits down into logical components. Make sure to rebase against our current master. +* Push the branch to your fork and submit a pull request. + +Please be prepared to repeat some of these steps as our contributors review your code. + +Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions! + +## Writing proper commits - short version + +* Make commits of logical units. +* Check for unnecessary whitespace with "git diff --check" before committing. +* Commit using Unix line endings (check the settings around "crlf" in git-config(1)). +* Do not check in commented out code or unneeded files. +* The first line of the commit message should be a short description (50 characters is the soft limit, excluding ticket number(s)), and should skip the full stop. +* Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". +* The body should provide a meaningful commit message, which: + *uses the imperative, present tense: `change`, not `changed` or `changes`. + * includes motivation for the change, and contrasts its implementation with the previous behavior. + * Make sure that you have tests for the bug you are fixing, or feature you are adding. + * Make sure the test suites passes after your commit: + * When introducing a new feature, make sure it is properly documented in the README.md + +## Writing proper commits - long version + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on `master`. + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 3. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. + +## Dependencies + +The testing and development tools have a bunch of dependencies, +all managed by [bundler](http://bundler.io/) according to the +[Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). + +By default the tests use a baseline version of Puppet. + +If you have Ruby 2.x or want a specific version of Puppet, +you must set an environment variable such as: + +```sh +export PUPPET_GEM_VERSION="~> 6.1.0" +``` + +You can install all needed gems for spec tests into the modules directory by +running: + +```sh +bundle install --path .vendor/ --without development system_tests release --jobs "$(nproc)" +``` + +If you also want to run acceptance tests: + +```sh +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)" +``` + +Our all in one solution if you don't know if you need to install or update gems: + +```sh +bundle install --path .vendor/ --with system_tests --without development release --jobs "$(nproc)"; bundle update; bundle clean +``` + +As an alternative to the `--jobs "$(nproc)` parameter, you can set an +environment variable: + +```sh +BUNDLE_JOBS="$(nproc)" +``` + +### Note for OS X users + +`nproc` isn't a valid command under OS x. As an alternative, you can do: + +```sh +--jobs "$(sysctl -n hw.ncpu)" +``` + +## The test matrix + +### Syntax and style + +The test suite will run [Puppet Lint](http://puppet-lint.com/) and +[Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to +check various syntax and style things. You can run these locally with: + +```sh +bundle exec rake lint +bundle exec rake validate +``` + +It will also run some [Rubocop](http://batsov.com/rubocop/) tests +against it. You can run those locally ahead of time with: + +```sh +bundle exec rake rubocop +``` + +### Running the unit tests + +The unit test suite covers most of the code, as mentioned above please +add tests if you're adding new functionality. If you've not used +[rspec-puppet](http://rspec-puppet.com/) before then feel free to ask +about how best to test your new feature. + +To run the linter, the syntax checker and the unit tests: + +```sh +bundle exec rake test +``` + +To run your all the unit tests + +```sh +bundle exec rake spec +``` + +To run a specific spec test set the `SPEC` variable: + +```sh +bundle exec rake spec SPEC=spec/foo_spec.rb +``` + +#### Unit tests in docker + +Some people don't want to run the dependencies locally or don't want to install +ruby. We ship a Dockerfile that enables you to run all unit tests and linting. +You only need to run: + +```sh +docker build . +``` + +Please ensure that a docker daemon is running and that your user has the +permission to talk to it. You can specify a remote docker host by setting the +`DOCKER_HOST` environment variable. it will copy the content of the module into +the docker image. So it will not work if a Gemfile.lock exists. + +### Integration tests + +The unit tests just check the code runs, not that it does exactly what +we want on a real machine. For that we're using +[beaker](https://github.com/puppetlabs/beaker). + +This fires up a new virtual machine (using vagrant) and runs a series of +simple tests against it after applying the module. You can run this +with: + +```sh +BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker +``` + +You can replace the string `debian11` with any common operating system. +The following strings are known to work: + +* ubuntu2004 +* 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). + +The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) +repository. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..593e7aa --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,26 @@ + + +## Affected Puppet, Ruby, OS and module versions/distributions + +- Puppet: +- Ruby: +- Distribution: +- Module version: + +## How to reproduce (e.g Puppet code you use) + +## What are you seeing + +## What behaviour did you expect instead + +## Output log + +## Any additional information you'd like to impart diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..342807b --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ + +#### Pull Request (PR) description + + +#### This Pull Request (PR) fixes the following issues + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2974af3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +on: + pull_request: {} + push: + branches: + - main + - master + +concurrency: + group: ${{ github.ref_name }} + cancel-in-progress: true + +jobs: + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..55324aa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: Release + +on: + push: + tags: + - '*' + +jobs: + 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 c1a5025..84fd904 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,23 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns -*.iml -/.bundle/ -/.idea/ -/.vagrant/ -/coverage/ -/bin/ -/doc/ -/Gemfile.local -/Gemfile.lock -/junit/ -/log/ +# 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/ -/tmp/ -/vendor/ -/convert_report.txt -/update_report.txt -.DS_Store -.project -.envrc -/inventory.yaml -/scratch/ -/.vscode/ +/.vagrant/ +/.bundle/ +/.ruby-version +/coverage/ +/log/ +/.idea/ +/.dependencies/ +/.librarian/ +/Puppetfile.lock +*.iml +.*.sw? +/.yardoc/ +/Guardfile diff --git a/.msync.yml b/.msync.yml new file mode 100644 index 0000000..f46ee02 --- /dev/null +++ b/.msync.yml @@ -0,0 +1,5 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +modulesync_config_version: '7.3.0' diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 0000000..d367ada --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,65 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ +# +# Hooks are only enabled if you take action. +# +# To enable the hooks run: +# +# ``` +# bundle exec overcommit --install +# # ensure .overcommit.yml does not harm to you and then +# bundle exec overcommit --sign +# ``` +# +# (it will manage the .git/hooks directory): +# +# Examples howto skip a test for a commit or push: +# +# ``` +# SKIP=RuboCop git commit +# SKIP=PuppetLint git commit +# SKIP=RakeTask git push +# ``` +# +# Don't invoke overcommit at all: +# +# ``` +# OVERCOMMIT_DISABLE=1 git commit +# ``` +# +# Read more about overcommit: https://github.com/brigade/overcommit +# +# To manage this config yourself in your module add +# +# ``` +# .overcommit.yml: +# unmanaged: true +# ``` +# +# to your modules .sync.yml config +--- +PreCommit: + RuboCop: + enabled: true + description: 'Runs rubocop on modified files only' + command: ['bundle', 'exec', 'rubocop'] + PuppetLint: + enabled: true + description: 'Runs puppet-lint on modified files only' + command: ['bundle', 'exec', 'puppet-lint'] + YamlSyntax: + enabled: true + JsonSyntax: + enabled: true + TrailingWhitespace: + enabled: true + +PrePush: + RakeTarget: + enabled: true + description: 'Run rake targets' + targets: + - 'validate' + - 'test' + - 'rubocop' + command: ['bundle', 'exec', 'rake'] diff --git a/.pdkignore b/.pdkignore deleted file mode 100644 index 4f6b6a4..0000000 --- a/.pdkignore +++ /dev/null @@ -1,43 +0,0 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns -*.iml -/.bundle/ -/.idea/ -/.vagrant/ -/coverage/ -/bin/ -/doc/ -/Gemfile.local -/Gemfile.lock -/junit/ -/log/ -/pkg/ -/spec/fixtures/manifests/ -/spec/fixtures/modules/ -/tmp/ -/vendor/ -/convert_report.txt -/update_report.txt -.DS_Store -.project -.envrc -/inventory.yaml -/appveyor.yml -/.fixtures.yml -/Gemfile -/.gitattributes -/.gitignore -/.gitlab-ci.yml -/.pdkignore -/Rakefile -/rakelib/ -/.rspec -/.rubocop.yml -/.travis.yml -/.yardopts -/spec/ -/.vscode/ -/scratch/ diff --git a/.pmtignore b/.pmtignore new file mode 100644 index 0000000..10b9830 --- /dev/null +++ b/.pmtignore @@ -0,0 +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 +*.iml +/.editorconfig +/.fixtures.yml +/.gitignore +/.msync.yml +/.overcommit.yml +/.pmtignore +/.rspec +/.rspec_parallel +/.rubocop.yml +/.sync.yml +.*.sw? +/.yardoc/ +/.yardopts +/Dockerfile +/HISTORY.md diff --git a/.puppet-lint.rc b/.puppet-lint.rc index 9820da1..0a60e8c 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,2 +1,4 @@ ---relative ---no-parameter_order-check \ No newline at end of file +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check +--no-params-empty-string-assignment-check diff --git a/.rspec b/.rspec index 16f9cdb..f634583 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,5 @@ ---color +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + --format documentation +--color diff --git a/.rspec_parallel b/.rspec_parallel new file mode 100644 index 0000000..a9a84f8 --- /dev/null +++ b/.rspec_parallel @@ -0,0 +1,4 @@ +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +--format progress diff --git a/.rubocop.yml b/.rubocop.yml index f5a6c2a..fded90c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,122 +1,7 @@ --- -require: rubocop-rspec -AllCops: - DisplayCopNames: true - TargetRubyVersion: '2.1' - Include: - - "./**/*.rb" - Exclude: - - bin/* - - ".vendor/**/*" - - "**/Gemfile" - - "**/Rakefile" - - pkg/**/* - - spec/fixtures/**/* - - vendor/**/* - - "**/Puppetfile" - - "**/Vagrantfile" - - "**/Guardfile" -Metrics/LineLength: - Description: People have wide screens, use them. - Max: 200 -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/* -RSpec/BeforeAfterAll: - Description: Beware of using after(:all) as it may cause state to leak between tests. - A necessary evil in acceptance testing. - Exclude: - - spec/acceptance/**/*.rb -RSpec/HookArgument: - Description: Prefer explicit :each argument, matching existing module's style - EnforcedStyle: each -Style/BlockDelimiters: - Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to - be consistent then. - EnforcedStyle: braces_for_chaining -Style/ClassAndModuleChildren: - Description: Compact style reduces the required amount of indentation. - EnforcedStyle: compact -Style/EmptyElse: - Description: Enforce against empty else clauses, but allow `nil` for clarity. - EnforcedStyle: empty -Style/FormatString: - Description: Following the main puppet project's style, prefer the % format format. - EnforcedStyle: percent -Style/FormatStringToken: - Description: Following the main puppet project's style, prefer the simpler template - tokens over annotated ones. - EnforcedStyle: template -Style/Lambda: - Description: Prefer the keyword for easier discoverability. - EnforcedStyle: literal -Style/RegexpLiteral: - Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 - EnforcedStyle: percent_r -Style/TernaryParentheses: - Description: Checks for use of parentheses around ternary conditions. Enforce parentheses - on complex expressions for better readability, but seriously consider breaking - it up. - EnforcedStyle: require_parentheses_when_complex -Style/TrailingCommaInArguments: - Description: Prefer always trailing comma on multiline argument lists. This makes - diffs, and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. - EnforcedStyleForMultiline: comma -Style/SymbolArray: - Description: Using percent style obscures symbolic intent of array's contents. - EnforcedStyle: brackets -RSpec/MessageSpies: - EnforcedStyle: receive -Style/Documentation: - Exclude: - - lib/puppet/parser/functions/**/* - - spec/**/* -Style/WordArray: - EnforcedStyle: brackets -Style/CollectionMethods: - Enabled: true -Style/MethodCalledOnDoEndBlock: - Enabled: true -Style/StringMethods: - Enabled: true -Layout/EndOfLine: - Enabled: false -Layout/IndentHeredoc: - Enabled: false -Metrics/AbcSize: - Enabled: false -Metrics/BlockLength: - Enabled: false -Metrics/ClassLength: - Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false -Metrics/MethodLength: - Enabled: false -Metrics/ModuleLength: - Enabled: false -Metrics/ParameterLists: - Enabled: false -Metrics/PerceivedComplexity: - Enabled: false -RSpec/DescribeClass: - Enabled: false -RSpec/ExampleLength: - Enabled: false -RSpec/MessageExpectation: - Enabled: false -RSpec/MultipleExpectations: - Enabled: false -RSpec/NestedGroups: - Enabled: false -Style/AsciiComments: - Enabled: false -Style/IfUnlessModifier: - Enabled: false -Style/SymbolProc: - Enabled: false +# 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 0000000..7f337af --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,122 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-08-17 21:33:09 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: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'lib/puppet/provider/graylog_api.rb' + +# Offense count: 3 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'lib/puppet/provider/graylog_extractor/graylog_api.rb' + - 'lib/puppet/provider/graylog_input/graylog_api.rb' + - 'lib/puppet/provider/graylog_stream/graylog_api.rb' + +# Offense count: 3 +Lint/ShadowingOuterLocalVariable: + Exclude: + - 'lib/puppet/provider/graylog_pipeline/graylog_api.rb' + - 'lib/puppet/provider/graylog_role/graylog_api.rb' + - 'lib/puppet/provider/graylog_stream/graylog_api.rb' + +# Offense count: 6 +Naming/AccessorMethodName: + Exclude: + - 'lib/puppet/provider/graylog_dashboard_widget/graylog_api.rb' + - 'lib/puppet/provider/graylog_extractor/graylog_api.rb' + - 'lib/puppet/provider/graylog_input/graylog_api.rb' + - 'lib/puppet/provider/graylog_pipeline/graylog_api.rb' + - 'lib/puppet/provider/graylog_role/graylog_api.rb' + - 'lib/puppet/provider/graylog_stream/graylog_api.rb' + +# Offense count: 1 +# 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/graylog_stream/graylog_api.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: PreferredMethods, MethodsAcceptingSymbol. +# MethodsAcceptingSymbol: inject, reduce +Style/CollectionMethods: + Exclude: + - 'lib/puppet/provider/graylog_dashboard/graylog_api.rb' + - 'lib/puppet/provider/graylog_role/graylog_api.rb' + +# Offense count: 39 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/HashTransformKeys: + Exclude: + - 'lib/puppet/provider/graylog_api.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'lib/puppet/provider/graylog_input/graylog_api.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapToHash: + Exclude: + - 'lib/puppet/provider/graylog_api.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/puppet/provider/graylog_extractor/graylog_api.rb' + - 'lib/puppet/provider/graylog_input/graylog_api.rb' + - 'lib/puppet/provider/graylog_stream/graylog_api.rb' + - 'lib/puppet/type/graylog_index_set.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/puppet/provider/graylog_extractor/graylog_api.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'lib/puppet/type/graylog_dashboard_layout.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/RedundantInterpolation: + Exclude: + - 'lib/puppet/provider/graylog_api.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ZeroLengthPredicate: + Exclude: + - 'lib/puppet/provider/graylog_extractor/graylog_api.rb' diff --git a/.sync.yml b/.sync.yml deleted file mode 100644 index d76f8a8..0000000 --- a/.sync.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -Gemfile: - required: - ':development': - - gem: 'httparty' - - gem: 'puppet-strings' - git: 'https://github.com/puppetlabs/puppet-strings' - optional: - ':development': - - gem: 'puppet-resource_api' -spec/spec_helper.rb: - mock_with: ':rspec' -appveyor.yml: - delete: true -.gitlab-ci.yml: - delete: true -.travis.yml: - deploy: false - includes: - - env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" - - env: CHECK=parallel_spec - remove_includes: - - env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec - rvm: 2.1.9 -.gitignore: - paths: - - '/scratch/' - - '/.vscode/' -.pdkignore: - paths: - - '/scratch/' - - '/.vscode/' -Rakefile: - extra_disabled_lint_checks: - - 'parameter_order' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 02443b5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -dist: trusty -language: ruby -cache: bundler -before_install: - - bundle -v - - rm -f Gemfile.lock - - gem update --system $RUBYGEMS_VERSION - - gem --version - - bundle -v -script: - - 'bundle exec rake $CHECK' -bundler_args: --without system_tests -rvm: - - 2.5.3 -stages: - - static - - spec - - acceptance - - - if: tag =~ ^v\d - name: deploy -matrix: - fast_finish: true - include: - - - env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" - stage: static - - - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec - rvm: 2.4.5 - stage: spec - - - env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec - rvm: 2.5.3 - stage: spec - - - env: DEPLOY_TO_FORGE=yes - stage: deploy - - - env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" - - - env: CHECK=parallel_spec -branches: - only: - - master - - /^v\d/ -notifications: - email: false diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 29c933b..0000000 --- a/.yardopts +++ /dev/null @@ -1 +0,0 @@ ---markup markdown diff --git a/Gemfile b/Gemfile index 7168f73..a4a3b20 100644 --- a/Gemfile +++ b/Gemfile @@ -1,74 +1,32 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} +source ENV['GEM_SOURCE'] || 'https://rubygems.org' - if place_or_version && (git_url = place_or_version.match(git_url_regex)) - [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact - elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) - ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] - else - [place_or_version, { require: false }] - end +group :test do + gem 'voxpupuli-test', '~> 7.0', :require => false + gem 'coveralls', :require => false + gem 'simplecov-console', :require => false + gem 'puppet_metadata', '~> 3.5', :require => false end -ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments -minor_version = ruby_version_segments[0..1].join('.') - group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) - gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "httparty", require: false - gem "puppet-strings", require: false, git: 'https://github.com/puppetlabs/puppet-strings' - gem "puppet-resource_api", require: false + gem 'guard-rake', :require => false + gem 'overcommit', '>= 0.39.1', :require => false end -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - -gems = {} - -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables - -gems['facter'] = location_for(facter_version) if facter_version -gems['hiera'] = location_for(hiera_version) if hiera_version - -if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} - # If we're using a Puppet gem on Windows which handles its own win32-xxx gem - # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). - gems['win32-dir'] = ['<= 0.4.9', require: false] - gems['win32-eventlog'] = ['<= 0.6.5', require: false] - gems['win32-process'] = ['<= 0.7.5', require: false] - gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['0.8.8', require: false] +group :system_tests do + gem 'voxpupuli-acceptance', '~> 3.0', :require => false end -gems.each do |gem_name, gem_params| - gem gem_name, *gem_params +group :release do + gem 'voxpupuli-release', '~> 3.0', :require => false end -# Evaluate Gemfile.local and ~/.gemfile if they exist -extra_gemfiles = [ - "#{__FILE__}.local", - File.join(Dir.home, '.gemfile'), -] +gem 'rake', :require => false +gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] + +puppetversion = ENV['PUPPET_GEM_VERSION'] || '~> 7.24' +gem 'puppet', puppetversion, :require => false, :groups => [:test] -extra_gemfiles.each do |gemfile| - if File.file?(gemfile) && File.readable?(gemfile) - eval(File.read(gemfile), binding) - end -end # vim: syntax=ruby diff --git a/REFERENCE.md b/REFERENCE.md index a0b43ac..763ff4a 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1,26 +1,27 @@ # Reference + ## Table of Contents -**Defined types** - -* [`graylog_api::extractor::regex`](#graylog_apiextractorregex): Defines a Regex extractor. -* [`graylog_api::extractor::regex_replace`](#graylog_apiextractorregex_replace): Defines a Regex replace extractor. -* [`graylog_api::grok::pattern_file`](#graylog_apigrokpattern_file): Loads a full file worth of Grok patterns into Graylog. -* [`graylog_api::input::beats`](#graylog_apiinputbeats): Defines a (old-style) Beats input. -* [`graylog_api::input::beats2`](#graylog_apiinputbeats2): Defines a (new-style) Beats input. -* [`graylog_api::input::cef_tcp`](#graylog_apiinputcef_tcp): Defines a CEF-TCP input. -* [`graylog_api::input::cef_udp`](#graylog_apiinputcef_udp): Defines a CEF-UDP input. -* [`graylog_api::input::gelf_http`](#graylog_apiinputgelf_http): Defines a GELF-HTTP input. -* [`graylog_api::input::gelf_tcp`](#graylog_apiinputgelf_tcp): Defines a GELF-TCP input. -* [`graylog_api::input::gelf_udp`](#graylog_apiinputgelf_udp): Defines a GELF-UDP input. -* [`graylog_api::input::syslog_tcp`](#graylog_apiinputsyslog_tcp): Defines a Syslog-TCP input. -* [`graylog_api::input::syslog_udp`](#graylog_apiinputsyslog_udp): Defines a Syslog-UDP input. -* [`graylog_api::pipeline`](#graylog_apipipeline): Define a processing pipeline. -* [`graylog_api::pipeline::rule`](#graylog_apipipelinerule): Defines a pipeline rule. - -**Resource types** +### Defined types + +* [`graylog_api::extractor::regex`](#graylog_api--extractor--regex): Defines a Regex extractor. +* [`graylog_api::extractor::regex_replace`](#graylog_api--extractor--regex_replace): Defines a Regex replace extractor. +* [`graylog_api::grok::pattern_file`](#graylog_api--grok--pattern_file): Loads a full file worth of Grok patterns into Graylog. +* [`graylog_api::input::beats`](#graylog_api--input--beats): Defines a (old-style) Beats input. +* [`graylog_api::input::beats2`](#graylog_api--input--beats2): Defines a (new-style) Beats input. +* [`graylog_api::input::cef_tcp`](#graylog_api--input--cef_tcp): Defines a CEF-TCP input. +* [`graylog_api::input::cef_udp`](#graylog_api--input--cef_udp): Defines a CEF-UDP input. +* [`graylog_api::input::gelf_http`](#graylog_api--input--gelf_http): Defines a GELF-HTTP input. +* [`graylog_api::input::gelf_tcp`](#graylog_api--input--gelf_tcp): Defines a GELF-TCP input. +* [`graylog_api::input::gelf_udp`](#graylog_api--input--gelf_udp): Defines a GELF-UDP input. +* [`graylog_api::input::syslog_tcp`](#graylog_api--input--syslog_tcp): Defines a Syslog-TCP input. +* [`graylog_api::input::syslog_udp`](#graylog_api--input--syslog_udp): Defines a Syslog-UDP input. +* [`graylog_api::pipeline`](#graylog_api--pipeline): Define a processing pipeline. +* [`graylog_api::pipeline::rule`](#graylog_api--pipeline--rule): Defines a pipeline rule. + +### Resource types * [`graylog_api`](#graylog_api): Sets the API credentials used by the rest of the types in the module. * [`graylog_dashboard`](#graylog_dashboard): Creates an Dashboard. @@ -31,7 +32,7 @@ * [`graylog_index_set`](#graylog_index_set): Defines an Index Set. * [`graylog_input`](#graylog_input): Creates an Input. * [`graylog_ldap_settings`](#graylog_ldap_settings): Configures LDAP authentication. -* [`graylog_lookup_adapter`](#graylog_lookup_adapter): Creates a Lookup Table Data Adapter. +* [`graylog_lookup_adapter`](#graylog_lookup_adapter): @summary#{' '} Creates a Lookup Table Data Adapter. Creates a Data Adapter for use with a Lookup table. At present all configuration must * [`graylog_lookup_cache`](#graylog_lookup_cache): Creates a Lookup Table Cache. * [`graylog_lookup_table`](#graylog_lookup_table): Configures a Lookup Table. * [`graylog_pipeline`](#graylog_pipeline): Creates a processing pipleine. @@ -41,57 +42,73 @@ * [`graylog_stream`](#graylog_stream): Creates a Stream configuration. * [`graylog_user`](#graylog_user): Creates a internal user +### Data types + +* [`Graylog_api::Pipeline::Stage`](#Graylog_api--Pipeline--Stage): Custom Type for Graylog_api pipeline stage +* [`Graylog_api::Pipeline::Stage::Loose`](#Graylog_api--Pipeline--Stage--Loose): custom type for graylog_api pipeline stage loose + ## Defined types -### graylog_api::extractor::regex +### `graylog_api::extractor::regex` Defines a Regex extractor. #### Parameters -The following parameters are available in the `graylog_api::extractor::regex` defined type. +The following parameters are available in the `graylog_api::extractor::regex` defined type: -##### `ensure` +* [`ensure`](#-graylog_api--extractor--regex--ensure) +* [`input`](#-graylog_api--extractor--regex--input) +* [`source_field`](#-graylog_api--extractor--regex--source_field) +* [`target_field`](#-graylog_api--extractor--regex--target_field) +* [`regex_value`](#-graylog_api--extractor--regex--regex_value) +* [`cut_or_copy`](#-graylog_api--extractor--regex--cut_or_copy) +* [`condition_type`](#-graylog_api--extractor--regex--condition_type) +* [`condition_value`](#-graylog_api--extractor--regex--condition_value) +* [`converters`](#-graylog_api--extractor--regex--converters) +* [`order`](#-graylog_api--extractor--regex--order) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `input` +##### `input` Data type: `String` Title of the input this extractor is attached to. -Default value: '' +Default value: `''` -##### `source_field` +##### `source_field` Data type: `String` Source field -Default value: '' +Default value: `''` -##### `target_field` +##### `target_field` Data type: `String` Choose a field name to store the extracted value. It can only contain alphanumeric characters and underscores. Example: http_response_code. -Default value: '' +Default value: `''` -##### `regex_value` +##### `regex_value` Data type: `String` Title of the input this extractor is attached to. -Default value: '' +Default value: `''` -##### `cut_or_copy` +##### `cut_or_copy` Data type: `Optional[String]` @@ -99,7 +116,7 @@ Do you want to copy or cut from source? You cannot use the cutting feature on st Default value: `undef` -##### `condition_type` +##### `condition_type` Data type: `Optional[String]` @@ -107,7 +124,7 @@ Extracting only from messages that match a certain condition helps you avoiding Default value: `undef` -##### `condition_value` +##### `condition_value` Data type: `Optional[String]` @@ -115,7 +132,7 @@ Condition value Default value: `undef` -##### `converters` +##### `converters` Data type: `Optional[Array]` @@ -123,7 +140,7 @@ A list of optional converter types which must be Java class identifiers of conve Default value: `undef` -##### `order` +##### `order` Data type: `Optional[Integer]` @@ -131,51 +148,68 @@ Sort index for this extractor. Default value: `undef` -### graylog_api::extractor::regex_replace +### `graylog_api::extractor::regex_replace` Defines a Regex replace extractor. #### Parameters -The following parameters are available in the `graylog_api::extractor::regex_replace` defined type. +The following parameters are available in the `graylog_api::extractor::regex_replace` defined type: -##### `ensure` +* [`ensure`](#-graylog_api--extractor--regex_replace--ensure) +* [`input`](#-graylog_api--extractor--regex_replace--input) +* [`source_field`](#-graylog_api--extractor--regex_replace--source_field) +* [`target_field`](#-graylog_api--extractor--regex_replace--target_field) +* [`regex`](#-graylog_api--extractor--regex_replace--regex) +* [`cut_or_copy`](#-graylog_api--extractor--regex_replace--cut_or_copy) +* [`condition_type`](#-graylog_api--extractor--regex_replace--condition_type) +* [`condition_value`](#-graylog_api--extractor--regex_replace--condition_value) +* [`converters`](#-graylog_api--extractor--regex_replace--converters) +* [`order`](#-graylog_api--extractor--regex_replace--order) +* [`replacement`](#-graylog_api--extractor--regex_replace--replacement) +* [`replace_all`](#-graylog_api--extractor--regex_replace--replace_all) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `input` +##### `input` Data type: `String` Title of the input this extractor is attached to. -Default value: '' +Default value: `''` -##### `source_field` +##### `source_field` Data type: `String` Source field -Default value: '' +Default value: `''` -##### `target_field` +##### `target_field` Data type: `String` Choose a field name to store the extracted value. It can only contain alphanumeric characters and underscores. Example: http_response_code. -Default value: '' +Default value: `''` -##### `regex_value` +##### `regex` + +Data type: `String` Title of the input this extractor is attached to. -##### `cut_or_copy` +Default value: `''` + +##### `cut_or_copy` Data type: `Optional[String]` @@ -183,7 +217,7 @@ Do you want to copy or cut from source? You cannot use the cutting feature on st Default value: `undef` -##### `condition_type` +##### `condition_type` Data type: `Optional[String]` @@ -191,7 +225,7 @@ Extracting only from messages that match a certain condition helps you avoiding Default value: `undef` -##### `condition_value` +##### `condition_value` Data type: `Optional[String]` @@ -199,7 +233,7 @@ Condition value Default value: `undef` -##### `converters` +##### `converters` Data type: `Optional[Array]` @@ -207,7 +241,7 @@ A list of optional converter types which must be Java class identifiers of conve Default value: `undef` -##### `order` +##### `order` Data type: `Optional[Integer]` @@ -215,31 +249,23 @@ Sort index for this extractor. Default value: `undef` -##### `regex` - -Data type: `String` - - - -Default value: '' - -##### `replacement` +##### `replacement` Data type: `String` -Default value: '' +Default value: `''` -##### `replace_all` +##### `replace_all` -Data type: `Optional[Boolean]` +Data type: `Boolean` Default value: `false` -### graylog_api::grok::pattern_file +### `graylog_api::grok::pattern_file` This loads a full file worth of Grok patterns into Graylog. Since Grok patterns can contain numerous characters that would require escaping in @@ -262,9 +288,11 @@ graylog_api::grok::pattern_file { 'example patterns': #### Parameters -The following parameters are available in the `graylog_api::grok::pattern_file` defined type. +The following parameters are available in the `graylog_api::grok::pattern_file` defined type: + +* [`contents`](#-graylog_api--grok--pattern_file--contents) -##### `contents` +##### `contents` Data type: `String` @@ -274,7 +302,7 @@ are safely skipped. Actual pattern lines begin with the pattern name in all-caps, followed by a space, followed by the pattern itself. See the Graylog documentation for a full description of the Grok pattern format. -### graylog_api::input::beats +### `graylog_api::input::beats` This is the Beats input from Graylog 2.x, still available in Graylog 3.x as 'Beats (deprecated)'. For the new Beats input introduced in Graylog 3.0, see @@ -282,25 +310,40 @@ graylog_api::input::beats2 #### Parameters -The following parameters are available in the `graylog_api::input::beats` defined type. - -##### `ensure` +The following parameters are available in the `graylog_api::input::beats` defined type: + +* [`ensure`](#-graylog_api--input--beats--ensure) +* [`bind_address`](#-graylog_api--input--beats--bind_address) +* [`override_source`](#-graylog_api--input--beats--override_source) +* [`port`](#-graylog_api--input--beats--port) +* [`recv_buffer_size`](#-graylog_api--input--beats--recv_buffer_size) +* [`scope`](#-graylog_api--input--beats--scope) +* [`static_fields`](#-graylog_api--input--beats--static_fields) +* [`tcp_keepalive`](#-graylog_api--input--beats--tcp_keepalive) +* [`tls_cert_file`](#-graylog_api--input--beats--tls_cert_file) +* [`tls_client_auth`](#-graylog_api--input--beats--tls_client_auth) +* [`tls_client_auth_cert_file`](#-graylog_api--input--beats--tls_client_auth_cert_file) +* [`tls_enable`](#-graylog_api--input--beats--tls_enable) +* [`tls_key_file`](#-graylog_api--input--beats--tls_key_file) +* [`tls_key_password`](#-graylog_api--input--beats--tls_key_password) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. -Default value: '0.0.0.0' +Default value: `'0.0.0.0'` -##### `override_source` +##### `override_source` Data type: `Optional[String]` @@ -309,33 +352,33 @@ this if you want to override it with a custom string. Default value: `undef` -##### `port` +##### `port` Data type: `Stdlib::Port` The port to listen on. -Default value: 5044 +Default value: `5044` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. Defaults to 1 MB. -Default value: .to_bytes +Default value: `'1 MB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -343,7 +386,7 @@ Static fields to assign to this input. Default value: `undef` -##### `tcp_keepalive` +##### `tcp_keepalive` Data type: `Boolean` @@ -351,7 +394,7 @@ Whether to enable TCP keepalive packets. Default value: `false` -##### `tls_cert_file` +##### `tls_cert_file` Data type: `String` @@ -362,18 +405,18 @@ Note that this must be the entire certificate chain, and that Graylog is sensitive to exact formatting of PEM certificates, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_client_auth` +##### `tls_client_auth` Data type: `String` Whether to use TLS to authenticate clients. Can be 'disabled', 'optional', or 'required'. -Default value: 'disabled' +Default value: `'disabled'` -##### `tls_client_auth_cert_file` +##### `tls_client_auth_cert_file` Data type: `String` @@ -381,9 +424,9 @@ The path to the file (or directory) which stores the certificates of trusted clients. Has no effect if tls_client_auth is 'disabled' or tls_enable is false. -Default value: '' +Default value: `''` -##### `tls_enable` +##### `tls_enable` Data type: `Boolean` @@ -391,7 +434,7 @@ Whether to enable TLS for securing the input. Default value: `false` -##### `tls_key_file` +##### `tls_key_file` Data type: `String` @@ -401,18 +444,18 @@ effect if tls_enable is false. Note that for PEM private keys, Graylog is sensitive to exact formatting, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_key_password` +##### `tls_key_password` Data type: `String` The password to decrypt to private key specified in tls_key_file. Leave blank if not using TLS, or if the key is not encrypted. -Default value: '' +Default value: `''` -### graylog_api::input::beats2 +### `graylog_api::input::beats2` This is the new Beats input introduced in Graylog 3. For the prior Beats input (still available in as 'Beats (deprecated)'), see @@ -420,25 +463,41 @@ graylog_api::input::beats. #### Parameters -The following parameters are available in the `graylog_api::input::beats2` defined type. - -##### `ensure` +The following parameters are available in the `graylog_api::input::beats2` defined type: + +* [`ensure`](#-graylog_api--input--beats2--ensure) +* [`bind_address`](#-graylog_api--input--beats2--bind_address) +* [`include_beats_prefix`](#-graylog_api--input--beats2--include_beats_prefix) +* [`override_source`](#-graylog_api--input--beats2--override_source) +* [`port`](#-graylog_api--input--beats2--port) +* [`recv_buffer_size`](#-graylog_api--input--beats2--recv_buffer_size) +* [`scope`](#-graylog_api--input--beats2--scope) +* [`static_fields`](#-graylog_api--input--beats2--static_fields) +* [`tcp_keepalive`](#-graylog_api--input--beats2--tcp_keepalive) +* [`tls_cert_file`](#-graylog_api--input--beats2--tls_cert_file) +* [`tls_client_auth`](#-graylog_api--input--beats2--tls_client_auth) +* [`tls_client_auth_cert_file`](#-graylog_api--input--beats2--tls_client_auth_cert_file) +* [`tls_enable`](#-graylog_api--input--beats2--tls_enable) +* [`tls_key_file`](#-graylog_api--input--beats2--tls_key_file) +* [`tls_key_password`](#-graylog_api--input--beats2--tls_key_password) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. -Default value: '0.0.0.0' +Default value: `'0.0.0.0'` -##### `include_beats_prefix` +##### `include_beats_prefix` Data type: `Boolean` @@ -447,7 +506,7 @@ source -> filebeat_source. Default value: `false` -##### `override_source` +##### `override_source` Data type: `Optional[String]` @@ -456,33 +515,33 @@ this if you want to override it with a custom string. Default value: `undef` -##### `port` +##### `port` Data type: `Stdlib::Port` The port to listen on. -Default value: 5044 +Default value: `5044` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. Defaults to 1 MB. -Default value: .to_bytes +Default value: `'1 MB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -490,7 +549,7 @@ Static fields to assign to this input. Default value: `undef` -##### `tcp_keepalive` +##### `tcp_keepalive` Data type: `Boolean` @@ -498,7 +557,7 @@ Whether to enable TCP keepalive packets. Default value: `false` -##### `tls_cert_file` +##### `tls_cert_file` Data type: `String` @@ -509,18 +568,18 @@ Note that this must be the entire certificate chain, and that Graylog is sensitive to exact formatting of PEM certificates, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_client_auth` +##### `tls_client_auth` Data type: `String` Whether to use TLS to authenticate clients. Can be 'disabled', 'optional', or 'required'. -Default value: 'disabled' +Default value: `'disabled'` -##### `tls_client_auth_cert_file` +##### `tls_client_auth_cert_file` Data type: `String` @@ -528,9 +587,9 @@ The path to the file (or directory) which stores the certificates of trusted clients. Has no effect if tls_client_auth is 'disabled' or tls_enable is false. -Default value: '' +Default value: `''` -##### `tls_enable` +##### `tls_enable` Data type: `Boolean` @@ -538,7 +597,7 @@ Whether to enable TLS for securing the input. Default value: `false` -##### `tls_key_file` +##### `tls_key_file` Data type: `String` @@ -548,67 +607,87 @@ effect if tls_enable is false. Note that for PEM private keys, Graylog is sensitive to exact formatting, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_key_password` +##### `tls_key_password` Data type: `String` The password to decrypt to private key specified in tls_key_file. Leave blank if not using TLS, or if the key is not encrypted. -Default value: '' +Default value: `''` -### graylog_api::input::cef_tcp +### `graylog_api::input::cef_tcp` Defines an input accepting CEF messages over TCP. #### Parameters -The following parameters are available in the `graylog_api::input::cef_tcp` defined type. - -##### `ensure` +The following parameters are available in the `graylog_api::input::cef_tcp` defined type: + +* [`ensure`](#-graylog_api--input--cef_tcp--ensure) +* [`bind_address`](#-graylog_api--input--cef_tcp--bind_address) +* [`locale`](#-graylog_api--input--cef_tcp--locale) +* [`max_message_size`](#-graylog_api--input--cef_tcp--max_message_size) +* [`num_worker_threads`](#-graylog_api--input--cef_tcp--num_worker_threads) +* [`port`](#-graylog_api--input--cef_tcp--port) +* [`recv_buffer_size`](#-graylog_api--input--cef_tcp--recv_buffer_size) +* [`scope`](#-graylog_api--input--cef_tcp--scope) +* [`static_fields`](#-graylog_api--input--cef_tcp--static_fields) +* [`tcp_keepalive`](#-graylog_api--input--cef_tcp--tcp_keepalive) +* [`timezone`](#-graylog_api--input--cef_tcp--timezone) +* [`tls_cert_file`](#-graylog_api--input--cef_tcp--tls_cert_file) +* [`tls_client_auth`](#-graylog_api--input--cef_tcp--tls_client_auth) +* [`tls_client_auth_cert_file`](#-graylog_api--input--cef_tcp--tls_client_auth_cert_file) +* [`tls_enable`](#-graylog_api--input--cef_tcp--tls_enable) +* [`tls_key_file`](#-graylog_api--input--cef_tcp--tls_key_file) +* [`tls_key_password`](#-graylog_api--input--cef_tcp--tls_key_password) +* [`use_full_names`](#-graylog_api--input--cef_tcp--use_full_names) +* [`use_null_delimiter`](#-graylog_api--input--cef_tcp--use_null_delimiter) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. Defaults to 0.0.0.0. -Default value: '0.0.0.0' +Default value: `'0.0.0.0'` -##### `locale` +##### `locale` Data type: `String` The locale to use when parsing the CEF timestamps. Format can be either "en"-style or "en_US"-style. -Default value: 'en' +Default value: `'en'` -##### `max_message_size` +##### `max_message_size` Data type: `Integer` The maximum length of a message. -Default value: .to_bytes +Default value: `'2 MB'.to_bytes` -##### `num_worker_threads` +##### `num_worker_threads` Data type: `Integer` How many worker threads the input should use. -Default value: 2 +Default value: `2` -##### `port` +##### `port` Data type: `Stdlib::Port` @@ -616,27 +695,27 @@ The port to listen on. Defaults to 514, however be aware that in many server setups Graylog will not be able a privileged port without additional configuration. -Default value: 5555 +Default value: `5555` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. Defaults to 256 kilobytes. -Default value: .to_bytes +Default value: `'1 MB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). Default is global. -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -644,7 +723,7 @@ Static fields to assign to this input. Default value: `undef` -##### `tcp_keepalive` +##### `tcp_keepalive` Data type: `Boolean` @@ -652,16 +731,16 @@ Whether to enable TCP keepalive packets. Default value: `false` -##### `timezone` +##### `timezone` Data type: `String` The timezone of the timestamps in the CEF messages. Format is TZ Database, e.g. "America/New_York" or "UTC". -Default value: 'UTC' +Default value: `'UTC'` -##### `tls_cert_file` +##### `tls_cert_file` Data type: `String` @@ -671,18 +750,18 @@ Note that this must be the entire certificate chain, and that Graylog is sensitive to exact formatting of PEM certificates, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_client_auth` +##### `tls_client_auth` Data type: `String` Whether to use TLS to authenticate clients. Can be 'disabled', 'optional', or 'required'. -Default value: 'disabled' +Default value: `'disabled'` -##### `tls_client_auth_cert_file` +##### `tls_client_auth_cert_file` Data type: `String` @@ -690,9 +769,9 @@ The path to the file (or directory) which stores the certificates of trusted clients. Has no effect if tls_client_auth is 'disabled' or tls_enable is false. -Default value: '' +Default value: `''` -##### `tls_enable` +##### `tls_enable` Data type: `Boolean` @@ -700,7 +779,7 @@ Whether to enable TLS for securing the input. Default value: `false` -##### `tls_key_file` +##### `tls_key_file` Data type: `String` @@ -709,18 +788,18 @@ effect if tls_enable is false. Note that for PEM private keys, Graylog is sensitive to exact formatting, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_key_password` +##### `tls_key_password` Data type: `String` The password to decrypt to private key specified in tls_key_file. Leave blank if not using TLS, or if the key is not encrypted. -Default value: '' +Default value: `''` -##### `use_full_names` +##### `use_full_names` Data type: `Boolean` @@ -729,7 +808,7 @@ specification). Default value: `false` -##### `use_null_delimiter` +##### `use_null_delimiter` Data type: `Boolean` @@ -738,48 +817,59 @@ used as the delimiter instead. Default value: `false` -### graylog_api::input::cef_udp +### `graylog_api::input::cef_udp` Defines an input accepting CEF messages over UDP. #### Parameters -The following parameters are available in the `graylog_api::input::cef_udp` defined type. +The following parameters are available in the `graylog_api::input::cef_udp` defined type: -##### `ensure` +* [`ensure`](#-graylog_api--input--cef_udp--ensure) +* [`bind_address`](#-graylog_api--input--cef_udp--bind_address) +* [`locale`](#-graylog_api--input--cef_udp--locale) +* [`num_worker_threads`](#-graylog_api--input--cef_udp--num_worker_threads) +* [`port`](#-graylog_api--input--cef_udp--port) +* [`recv_buffer_size`](#-graylog_api--input--cef_udp--recv_buffer_size) +* [`scope`](#-graylog_api--input--cef_udp--scope) +* [`static_fields`](#-graylog_api--input--cef_udp--static_fields) +* [`timezone`](#-graylog_api--input--cef_udp--timezone) +* [`use_full_names`](#-graylog_api--input--cef_udp--use_full_names) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. Defaults to 0.0.0.0. -Default value: '0.0.0.0' +Default value: `'0.0.0.0'` -##### `locale` +##### `locale` Data type: `String` The locale to use when parsing the CEF timestamps. Format can be either "en"-style or "en_US"-style. -Default value: 'en' +Default value: `'en'` -##### `num_worker_threads` +##### `num_worker_threads` Data type: `Integer` How many worker threads the input should use. -Default value: 2 +Default value: `2` -##### `port` +##### `port` Data type: `Stdlib::Port` @@ -787,27 +877,27 @@ The port to listen on. Defaults to 514, however be aware that in many server setups Graylog will not be able a privileged port without additional configuration. -Default value: 5555 +Default value: `5555` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. Defaults to 256 kilobytes. -Default value: .to_bytes +Default value: `'1 MB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). Default is global. -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -815,16 +905,16 @@ Static fields to assign to this input. Default value: `undef` -##### `timezone` +##### `timezone` Data type: `String` The timezone of the timestamps in the CEF messages. Format is TZ Database, e.g. "America/New_York" or "UTC". -Default value: 'UTC' +Default value: `'UTC'` -##### `use_full_names` +##### `use_full_names` Data type: `Boolean` @@ -833,45 +923,59 @@ specification). Default value: `false` -##### `use_null_delimiter` - -Whether to use a null byte as a frame delimiter. If false, a newline is -used as the delimiter instead. - -### graylog_api::input::gelf_http +### `graylog_api::input::gelf_http` Defines an input accepting GELF-formatted JSON over HTTP POST. #### Parameters -The following parameters are available in the `graylog_api::input::gelf_http` defined type. - -##### `ensure` +The following parameters are available in the `graylog_api::input::gelf_http` defined type: + +* [`ensure`](#-graylog_api--input--gelf_http--ensure) +* [`bind_address`](#-graylog_api--input--gelf_http--bind_address) +* [`decompress_size_limit`](#-graylog_api--input--gelf_http--decompress_size_limit) +* [`enable_cors`](#-graylog_api--input--gelf_http--enable_cors) +* [`idle_writer_timeout`](#-graylog_api--input--gelf_http--idle_writer_timeout) +* [`max_chunk_size`](#-graylog_api--input--gelf_http--max_chunk_size) +* [`override_source`](#-graylog_api--input--gelf_http--override_source) +* [`port`](#-graylog_api--input--gelf_http--port) +* [`recv_buffer_size`](#-graylog_api--input--gelf_http--recv_buffer_size) +* [`scope`](#-graylog_api--input--gelf_http--scope) +* [`static_fields`](#-graylog_api--input--gelf_http--static_fields) +* [`tcp_keepalive`](#-graylog_api--input--gelf_http--tcp_keepalive) +* [`tls_cert_file`](#-graylog_api--input--gelf_http--tls_cert_file) +* [`tls_client_auth`](#-graylog_api--input--gelf_http--tls_client_auth) +* [`tls_client_auth_cert_file`](#-graylog_api--input--gelf_http--tls_client_auth_cert_file) +* [`tls_enable`](#-graylog_api--input--gelf_http--tls_enable) +* [`tls_key_file`](#-graylog_api--input--gelf_http--tls_key_file) +* [`tls_key_password`](#-graylog_api--input--gelf_http--tls_key_password) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. -Default value: '0.0.0.0' +Default value: `'0.0.0.0'` -##### `decompress_size_limit` +##### `decompress_size_limit` Data type: `Integer` The maximum number of bytes of decompressed message data will be accepted in a single POST. Defaults to 8 megabytes. -Default value: .to_bytes +Default value: `'8 MB'.to_bytes` -##### `enable_cors` +##### `enable_cors` Data type: `Boolean` @@ -880,24 +984,24 @@ policies. Default value: `true` -##### `idle_writer_timeout` +##### `idle_writer_timeout` Data type: `Integer` How long the server should wait to receive additional messages from the client before closing the connection, in seconds. Set to 0 to disable. -Default value: 60 +Default value: `60` -##### `max_chunk_size` +##### `max_chunk_size` Data type: `Integer` The maximum HTTP chunk size in bytes (e. g. length of HTTP request body). -Default value: 65536 +Default value: `65536` -##### `override_source` +##### `override_source` Data type: `Optional[String]` @@ -906,33 +1010,33 @@ this if you want to override it with a custom string. Default value: `undef` -##### `port` +##### `port` Data type: `Stdlib::Port` The port to listen on. -Default value: 12280 +Default value: `12280` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. -Default value: .to_bytes +Default value: `'1 MB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -940,7 +1044,7 @@ Static fields to assign to this input. Default value: `undef` -##### `tcp_keepalive` +##### `tcp_keepalive` Data type: `Boolean` @@ -948,7 +1052,7 @@ Whether to enable TCP keepalive packets. Default value: `false` -##### `tls_cert_file` +##### `tls_cert_file` Data type: `String` @@ -959,18 +1063,18 @@ Note that this must be the entire certificate chain, and that Graylog is sensitive to exact formatting of PEM certificates, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_client_auth` +##### `tls_client_auth` Data type: `String` Whether to use TLS to authenticate clients. Can be 'disabled', 'optional', or 'required'. -Default value: 'disabled' +Default value: `'disabled'` -##### `tls_client_auth_cert_file` +##### `tls_client_auth_cert_file` Data type: `String` @@ -978,9 +1082,9 @@ The path to the file (or directory) which stores the certificates of trusted clients. Has no effect if tls_client_auth is 'disabled' or tls_enable is false. -Default value: '' +Default value: `''` -##### `tls_enable` +##### `tls_enable` Data type: `Boolean` @@ -988,7 +1092,7 @@ Whether to enable TLS for securing the input. Default value: `false` -##### `tls_key_file` +##### `tls_key_file` Data type: `String` @@ -998,59 +1102,77 @@ effect if tls_enable is false. Note that for PEM private keys, Graylog is sensitive to exact formatting, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_key_password` +##### `tls_key_password` Data type: `String` The password to decrypt to private key specified in tls_key_file. Leave blank if not using TLS, or if the key is not encrypted. -Default value: '' +Default value: `''` -### graylog_api::input::gelf_tcp +### `graylog_api::input::gelf_tcp` Defines an input accepting GELF over TCP, optionally encrypted with TLS. #### Parameters -The following parameters are available in the `graylog_api::input::gelf_tcp` defined type. - -##### `ensure` +The following parameters are available in the `graylog_api::input::gelf_tcp` defined type: + +* [`ensure`](#-graylog_api--input--gelf_tcp--ensure) +* [`bind_address`](#-graylog_api--input--gelf_tcp--bind_address) +* [`decompress_size_limit`](#-graylog_api--input--gelf_tcp--decompress_size_limit) +* [`max_message_size`](#-graylog_api--input--gelf_tcp--max_message_size) +* [`override_source`](#-graylog_api--input--gelf_tcp--override_source) +* [`port`](#-graylog_api--input--gelf_tcp--port) +* [`recv_buffer_size`](#-graylog_api--input--gelf_tcp--recv_buffer_size) +* [`scope`](#-graylog_api--input--gelf_tcp--scope) +* [`static_fields`](#-graylog_api--input--gelf_tcp--static_fields) +* [`tcp_keepalive`](#-graylog_api--input--gelf_tcp--tcp_keepalive) +* [`tls_cert_file`](#-graylog_api--input--gelf_tcp--tls_cert_file) +* [`tls_client_auth`](#-graylog_api--input--gelf_tcp--tls_client_auth) +* [`tls_client_auth_cert_file`](#-graylog_api--input--gelf_tcp--tls_client_auth_cert_file) +* [`tls_enable`](#-graylog_api--input--gelf_tcp--tls_enable) +* [`tls_key_file`](#-graylog_api--input--gelf_tcp--tls_key_file) +* [`tls_key_password`](#-graylog_api--input--gelf_tcp--tls_key_password) +* [`use_null_delimiter`](#-graylog_api--input--gelf_tcp--use_null_delimiter) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. -Default value: '0.0.0.0' +Default value: `'0.0.0.0'` -##### `decompress_size_limit` +##### `decompress_size_limit` Data type: `Integer` The maximum number of bytes of decompressed message data will be accepted in a single POST. -Default value: .to_bytes +Default value: `'8 MB'.to_bytes` -##### `max_message_size` +##### `max_message_size` Data type: `Integer` The maximum length of a message, in bytes. Default value is 2 megabytes. -Default value: .to_bytes +Default value: `'2 MB'.to_bytes` -##### `override_source` +##### `override_source` Data type: `Optional[String]` @@ -1059,33 +1181,33 @@ this if you want to override it with a custom string. Default value: `undef` -##### `port` +##### `port` Data type: `Stdlib::Port` The port to listen on. -Default value: 12201 +Default value: `12201` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. Defaults to 1 MB. -Default value: .to_bytes +Default value: `'1 MB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -1093,7 +1215,7 @@ Static fields to assign to this input. Default value: `undef` -##### `tcp_keepalive` +##### `tcp_keepalive` Data type: `Boolean` @@ -1101,7 +1223,7 @@ Whether to enable TCP keepalive packets. Default value: `false` -##### `tls_cert_file` +##### `tls_cert_file` Data type: `String` @@ -1111,18 +1233,18 @@ Note that this must be the entire certificate chain, and that Graylog is sensitive to exact formatting of PEM certificates, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_client_auth` +##### `tls_client_auth` Data type: `String` Whether to use TLS to authenticate clients. Can be 'disabled', 'optional', or 'required'. -Default value: 'disabled' +Default value: `'disabled'` -##### `tls_client_auth_cert_file` +##### `tls_client_auth_cert_file` Data type: `String` @@ -1130,9 +1252,9 @@ The path to the file (or directory) which stores the certificates of trusted clients. Has no effect if tls_client_auth is 'disabled' or tls_enable is false. -Default value: '' +Default value: `''` -##### `tls_enable` +##### `tls_enable` Data type: `Boolean` @@ -1140,7 +1262,7 @@ Whether to enable TLS for securing the input. Default value: `false` -##### `tls_key_file` +##### `tls_key_file` Data type: `String` @@ -1149,18 +1271,18 @@ effect if tls_enable is false. Note that for PEM private keys, Graylog is sensitive to exact formatting, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_key_password` +##### `tls_key_password` Data type: `String` The password to decrypt to private key specified in tls_key_file. Leave blank if not using TLS, or if the key is not encrypted. -Default value: '' +Default value: `''` -##### `use_null_delimiter` +##### `use_null_delimiter` Data type: `Boolean` @@ -1169,40 +1291,49 @@ used as the delimiter instead. Default value: `true` -### graylog_api::input::gelf_udp +### `graylog_api::input::gelf_udp` Defines an input accepting GELF over UDP. #### Parameters -The following parameters are available in the `graylog_api::input::gelf_udp` defined type. +The following parameters are available in the `graylog_api::input::gelf_udp` defined type: -##### `ensure` +* [`ensure`](#-graylog_api--input--gelf_udp--ensure) +* [`bind_address`](#-graylog_api--input--gelf_udp--bind_address) +* [`decompress_size_limit`](#-graylog_api--input--gelf_udp--decompress_size_limit) +* [`override_source`](#-graylog_api--input--gelf_udp--override_source) +* [`port`](#-graylog_api--input--gelf_udp--port) +* [`recv_buffer_size`](#-graylog_api--input--gelf_udp--recv_buffer_size) +* [`scope`](#-graylog_api--input--gelf_udp--scope) +* [`static_fields`](#-graylog_api--input--gelf_udp--static_fields) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. Defaults to 0.0.0.0. -Default value: '0.0.0.0' +Default value: `'0.0.0.0'` -##### `decompress_size_limit` +##### `decompress_size_limit` Data type: `Integer` The maximum number of bytes of decompressed message data will be accepted in a single POST. Defaults to 8 megabytes. -Default value: .to_bytes +Default value: `'8 MB'.to_bytes` -##### `override_source` +##### `override_source` Data type: `Optional[String]` @@ -1211,33 +1342,33 @@ this if you want to override it with a custom string. Default value: `undef` -##### `port` +##### `port` Data type: `Stdlib::Port` The port to listen on. Defaults to 12280. -Default value: 12201 +Default value: `12201` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. Defaults to 256 kilobytes. -Default value: .to_bytes +Default value: `'256 kB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). Default is global. -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -1245,48 +1376,46 @@ Static fields to assign to this input. Default value: `undef` -### graylog_api::input::syslog_tcp +### `graylog_api::input::syslog_tcp` Defines an input accepting Syslog messages over TCP. #### Parameters -The following parameters are available in the `graylog_api::input::syslog_tcp` defined type. - -##### `ensure` +The following parameters are available in the `graylog_api::input::syslog_tcp` defined type: + +* [`ensure`](#-graylog_api--input--syslog_tcp--ensure) +* [`bind_address`](#-graylog_api--input--syslog_tcp--bind_address) +* [`override_source`](#-graylog_api--input--syslog_tcp--override_source) +* [`port`](#-graylog_api--input--syslog_tcp--port) +* [`recv_buffer_size`](#-graylog_api--input--syslog_tcp--recv_buffer_size) +* [`scope`](#-graylog_api--input--syslog_tcp--scope) +* [`static_fields`](#-graylog_api--input--syslog_tcp--static_fields) +* [`tcp_keepalive`](#-graylog_api--input--syslog_tcp--tcp_keepalive) +* [`tls_cert_file`](#-graylog_api--input--syslog_tcp--tls_cert_file) +* [`tls_client_auth`](#-graylog_api--input--syslog_tcp--tls_client_auth) +* [`tls_client_auth_cert_file`](#-graylog_api--input--syslog_tcp--tls_client_auth_cert_file) +* [`tls_enable`](#-graylog_api--input--syslog_tcp--tls_enable) +* [`tls_key_file`](#-graylog_api--input--syslog_tcp--tls_key_file) +* [`tls_key_password`](#-graylog_api--input--syslog_tcp--tls_key_password) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' - -##### `allow_override_date` - -Whether to allow setting the message timestamp to the current server time, -if the timstamp in the message failed to parse. Defaults to true. +Default value: `'present'` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. Defaults to 0.0.0.0. -Default value: '0.0.0.0' - -##### `expand_structured_data` - -Whether to expand structured data elements by prefixing attributes with -their SD-ID. Defaults to true. - -##### `force_rdns` - -Whether to force reverse DNS resolution of sender's hostname. Use if the -hostname in the message cannot be parsed. Default value is false. -NOTE: Be careful with this setting if you are sending DNS server logs into -this input as it can cause a feedback loop. +Default value: `'0.0.0.0'` -##### `override_source` +##### `override_source` Data type: `Optional[String]` @@ -1295,7 +1424,7 @@ this if you want to override it with a custom string. Default value: `undef` -##### `port` +##### `port` Data type: `Stdlib::Port` @@ -1303,27 +1432,27 @@ The port to listen on. Defaults to 514, however be aware that in many server setups Graylog will not be able a privileged port without additional configuration. -Default value: 5044 +Default value: `5044` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. Defaults to 256 kilobytes. -Default value: .to_bytes +Default value: `'1 MB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). Default is global. -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -1331,12 +1460,7 @@ Static fields to assign to this input. Default value: `undef` -##### `store_full_message` - -Whether to store the full original syslog message as full_message. Defaults -to true. - -##### `tcp_keepalive` +##### `tcp_keepalive` Data type: `Boolean` @@ -1344,7 +1468,7 @@ Whether to enable TCP keepalive packets. Default value: `false` -##### `tls_cert_file` +##### `tls_cert_file` Data type: `String` @@ -1354,18 +1478,18 @@ Note that this must be the entire certificate chain, and that Graylog is sensitive to exact formatting of PEM certificates, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_client_auth` +##### `tls_client_auth` Data type: `String` Whether to use TLS to authenticate clients. Can be 'disabled', 'optional', or 'required'. -Default value: 'disabled' +Default value: `'disabled'` -##### `tls_client_auth_cert_file` +##### `tls_client_auth_cert_file` Data type: `String` @@ -1373,9 +1497,9 @@ The path to the file (or directory) which stores the certificates of trusted clients. Has no effect if tls_client_auth is 'disabled' or tls_enable is false. -Default value: '' +Default value: `''` -##### `tls_enable` +##### `tls_enable` Data type: `Boolean` @@ -1383,7 +1507,7 @@ Whether to enable TLS for securing the input. Default value: `false` -##### `tls_key_file` +##### `tls_key_file` Data type: `String` @@ -1392,39 +1516,46 @@ effect if tls_enable is false. Note that for PEM private keys, Graylog is sensitive to exact formatting, e.g. there must be a trailing newline. -Default value: '' +Default value: `''` -##### `tls_key_password` +##### `tls_key_password` Data type: `String` The password to decrypt to private key specified in tls_key_file. Leave blank if not using TLS, or if the key is not encrypted. -Default value: '' - -##### `use_null_delimiter` - -Whether to use a null byte as a frame delimiter. If false, a newline is -used as the delimiter instead. +Default value: `''` -### graylog_api::input::syslog_udp +### `graylog_api::input::syslog_udp` Defines an input accepting Syslog messages over UDP. #### Parameters -The following parameters are available in the `graylog_api::input::syslog_udp` defined type. +The following parameters are available in the `graylog_api::input::syslog_udp` defined type: -##### `ensure` +* [`ensure`](#-graylog_api--input--syslog_udp--ensure) +* [`allow_override_date`](#-graylog_api--input--syslog_udp--allow_override_date) +* [`bind_address`](#-graylog_api--input--syslog_udp--bind_address) +* [`expand_structured_data`](#-graylog_api--input--syslog_udp--expand_structured_data) +* [`force_rdns`](#-graylog_api--input--syslog_udp--force_rdns) +* [`override_source`](#-graylog_api--input--syslog_udp--override_source) +* [`port`](#-graylog_api--input--syslog_udp--port) +* [`recv_buffer_size`](#-graylog_api--input--syslog_udp--recv_buffer_size) +* [`scope`](#-graylog_api--input--syslog_udp--scope) +* [`static_fields`](#-graylog_api--input--syslog_udp--static_fields) +* [`store_full_message`](#-graylog_api--input--syslog_udp--store_full_message) + +##### `ensure` Data type: `Enum['present','absent']` Whether this input should exist. -Default value: 'present' +Default value: `'present'` -##### `allow_override_date` +##### `allow_override_date` Data type: `Boolean` @@ -1433,15 +1564,15 @@ if the timstamp in the message failed to parse. Defaults to true. Default value: `true` -##### `bind_address` +##### `bind_address` Data type: `String` The IP address to listen on. Defaults to 0.0.0.0. -Default value: '0.0.0.0' +Default value: `'0.0.0.0'` -##### `expand_structured_data` +##### `expand_structured_data` Data type: `Boolean` @@ -1450,7 +1581,7 @@ their SD-ID. Defaults to true. Default value: `true` -##### `force_rdns` +##### `force_rdns` Data type: `Boolean` @@ -1461,7 +1592,7 @@ this input as it can cause a feedback loop. Default value: `false` -##### `override_source` +##### `override_source` Data type: `Optional[String]` @@ -1470,7 +1601,7 @@ this if you want to override it with a custom string. Default value: `undef` -##### `port` +##### `port` Data type: `Stdlib::Port` @@ -1478,27 +1609,27 @@ The port to listen on. Defaults to 514, however be aware that in many server setups Graylog will not be able a privileged port without additional configuration. -Default value: 514 +Default value: `514` -##### `recv_buffer_size` +##### `recv_buffer_size` Data type: `Integer` The size in bytes of the recvBufferSize for network connections to this input. Defaults to 256 kilobytes. -Default value: .to_bytes +Default value: `'256 kB'.to_bytes` -##### `scope` +##### `scope` Data type: `Enum['global','local']` Whether this input is defined on all nodes ('global') or just this node ('local'). Default is global. -Default value: 'global' +Default value: `'global'` -##### `static_fields` +##### `static_fields` Data type: `Optional[Hash]` @@ -1506,7 +1637,7 @@ Static fields to assign to this input. Default value: `undef` -##### `store_full_message` +##### `store_full_message` Data type: `Boolean` @@ -1515,7 +1646,7 @@ to true. Default value: `true` -### graylog_api::pipeline +### `graylog_api::pipeline` This is a convenience wrapper around graylog_pipeline, which prevents frees you from worrying about pipeline syntax. @@ -1575,17 +1706,21 @@ graylog_api::pipeline { 'example': #### Parameters -The following parameters are available in the `graylog_api::pipeline` defined type. +The following parameters are available in the `graylog_api::pipeline` defined type: -##### `description` +* [`description`](#-graylog_api--pipeline--description) +* [`stages`](#-graylog_api--pipeline--stages) +* [`streams`](#-graylog_api--pipeline--streams) + +##### `description` Data type: `String` The description of the pipeline. -Default value: '' +Default value: `''` -##### `stages` +##### `stages` Data type: `Array[Graylog_api::Pipeline::Stage::Loose]` @@ -1602,7 +1737,7 @@ stage in the array will be stage 1, the second stage 2, etc. If you need to set explicit stage priorities to control how multiple pipelines run in parallel, use the graylog_pipeline native type directly. -##### `streams` +##### `streams` Data type: `Variant[String,Array[String]]` @@ -1611,9 +1746,9 @@ case-sensitive. Also note that, if the Pipeline Processor is running before the Message Filter Chain, then the only stream that will have messages at processing time will be the 'All messages' stream. -Default value: [] +Default value: `[]` -### graylog_api::pipeline::rule +### `graylog_api::pipeline::rule` This is a convenience wrapper around graylog_pipeline_rule which ensures no mismatch between the name in the rule source and the name of the resource. @@ -1632,37 +1767,41 @@ graylog_api::pipeline::rule { 'example': #### Parameters -The following parameters are available in the `graylog_api::pipeline::rule` defined type. +The following parameters are available in the `graylog_api::pipeline::rule` defined type: -##### `description` +* [`description`](#-graylog_api--pipeline--rule--description) +* [`condition`](#-graylog_api--pipeline--rule--condition) +* [`action`](#-graylog_api--pipeline--rule--action) + +##### `description` Data type: `String` A description of the rule. -Default value: '' +Default value: `''` -##### `condition` +##### `condition` Data type: `String` The condition in the 'when' clause of the rule. Defaults to true, e.g. by default the rule will match all messages. -Default value: 'true' +Default value: `'true'` -##### `action` +##### `action` Data type: `String` The action to take if the rule matches. Defaults to the empty string (e.g. no action is taken when the rule matches). -Default value: '' +Default value: `''` ## Resource types -### graylog_api +### `graylog_api` This sets the API credentials used by the rest of the types in the module to communicate with the Graylog API. It does not actually represent a @@ -1692,59 +1831,67 @@ The following properties are available in the `graylog_api` type. The API password used to connect to the Graylog server. Should be the password for the root user. -##### `username` +##### `port` -The API username used to connect to the Graylog server. Should be the username for the root user (default 'admin'). +the api port -Default value: admin +##### `server` -##### `port` +The graylog server hostname -the api port +Default value: `localhost` -##### `tls` +##### `ssl_ca_file` -enable tls +The certificate authority file -Default value: false +Default value: `/etc/pki/tls/certs/ca-bundle.crt` -##### `verify_tls` +##### `tls` -enable/disable ssl cert verification +enable tls -Default value: false +Default value: `false` -##### `ssl_ca_file` +##### `username` -The certificate authority file +The API username used to connect to the Graylog server. Should be the username for the root user (default 'admin'). -Default value: /etc/pki/tls/certs/ca-bundle.crt +Default value: `admin` -##### `server` +##### `verify_tls` -The graylog server hostname +enable/disable ssl cert verification -Default value: localhost +Default value: `false` #### Parameters The following parameters are available in the `graylog_api` type. -##### `name` +* [`name`](#-graylog_api--name) +* [`provider`](#-graylog_api--provider) + +##### `name` -Valid values: api +Valid values: `api` namevar must be 'api' -### graylog_dashboard +##### `provider` + +The specific backend to use for this `graylog_api` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. + +### `graylog_dashboard` -Creates an Dashboard. +#{' '} * **See also** -graylog_dashboard_widget -graylog_dashboard_layout + * graylog_dashboard_widget + * graylog_dashboard_layout #### Examples @@ -1761,17 +1908,17 @@ graylog_dashboard { 'Example Dashboard': The following properties are available in the `graylog_dashboard` type. -##### `ensure` +##### `description` -Valid values: present, absent +The description of the Dashboard. -The basic property that the resource should be in. +##### `ensure` -Default value: present +Valid values: `present`, `absent` -##### `description` +The basic property that the resource should be in. -The description of the Dashboard. +Default value: `present` ##### `purge` @@ -1781,19 +1928,27 @@ Whether to remove widgets from this dashboard if they aren't declared in Puppet The following parameters are available in the `graylog_dashboard` type. -##### `name` +* [`name`](#-graylog_dashboard--name) +* [`provider`](#-graylog_dashboard--provider) + +##### `name` namevar The name of the Dashboard. -### graylog_dashboard_layout +##### `provider` + +The specific backend to use for this `graylog_dashboard` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. -Lays out the widgets on a dashboard. +### `graylog_dashboard_layout` + +#{' '} * **See also** -graylog_dashboard -graylog_dashboard_widget + * graylog_dashboard + * graylog_dashboard_widget #### Examples @@ -1826,20 +1981,29 @@ dashboard. The corresponding value is a hash with four keys: The following parameters are available in the `graylog_dashboard_layout` type. -##### `name` +* [`name`](#-graylog_dashboard_layout--name) +* [`provider`](#-graylog_dashboard_layout--provider) + +##### `name` namevar The name of the Dashboard whose layout this is. -### graylog_dashboard_widget +##### `provider` + +The specific backend to use for this `graylog_dashboard_layout` resource. You will seldom need to specify this --- +Puppet will usually discover the appropriate provider for your platform. + +### `graylog_dashboard_widget` The title of this resource should be the name of the dashboard on which the widget appears, followed by !!!, followed by the name of the widget. +#{' '} * **See also** -graylog_dashboard -graylog_dashboard_layout + * graylog_dashboard + * graylog_dashboard_layout #### Examples @@ -1868,14 +2032,6 @@ graylog_dashboard_widget { 'Example Dashboard!!!Example Widget': The following properties are available in the `graylog_dashboard_widget` type. -##### `ensure` - -Valid values: present, absent - -The basic property that the resource should be in. - -Default value: present - ##### `cache_time` The amount of time (in seconds) this widget should cache data before requesting new data. @@ -1884,6 +2040,14 @@ The amount of time (in seconds) this widget should cache data before requesting A hash of configuration values for the widget. Structure of the hash varies by widget type. +##### `ensure` + +Valid values: `present`, `absent` + +The basic property that the resource should be in. + +Default value: `present` + ##### `type` The type of widget. @@ -1892,13 +2056,21 @@ The type of widget. The following parameters are available in the `graylog_dashboard_widget` type. -##### `name` +* [`name`](#-graylog_dashboard_widget--name) +* [`provider`](#-graylog_dashboard_widget--provider) + +##### `name` namevar The name of the dashboard on which this widget appears, followed by !!!, followed by the name of the widget. -### graylog_extractor +##### `provider` + +The specific backend to use for this `graylog_dashboard_widget` resource. You will seldom need to specify this --- +Puppet will usually discover the appropriate provider for your platform. + +### `graylog_extractor` This type covers the raw API and is agnostic to the type of extractor being created. In most cases, you should declare extractors using the @@ -1927,77 +2099,85 @@ graylog_extractor { 'Example Regex extractor': The following properties are available in the `graylog_extractor` type. -##### `ensure` - -Valid values: present, absent - -The basic property that the resource should be in. +##### `condition_type` -Default value: present +Valid values: `none`, `regex`, `string` -##### `input` +Extracting only from messages that match a certain condition helps you avoiding wrong or unnecessary extractions and can also save CPU resources. -Title of the input this extractor is attached to. +Default value: `none` -##### `type` +##### `condition_value` -The type of the Extractor. Must be the Java enum constant for the extractor, such as REGEX +Condition value -##### `source_field` +Default value: `''` -Source field +##### `configuration` -##### `target_field` +A hash of configuration values for the extractor; structure varies by extractor type. -Choose a field name to store the extracted value. It can only contain alphanumeric characters and underscores. Example: http_response_code. +##### `converters` -##### `configuration` +A list of optional converter types which must be Java class identifiers of converters, such as org.graylog2.inputs.converters.NumericConverter -A hash of configuration values for the extractor; structure varies by extractor type. +Default value: `{}` ##### `cut_or_copy` -Valid values: copy, cut +Valid values: `copy`, `cut` Do you want to copy or cut from source? You cannot use the cutting feature on standard fields like message and source. -Default value: copy +Default value: `copy` -##### `condition_type` +##### `ensure` -Valid values: none, regex, string +Valid values: `present`, `absent` -Extracting only from messages that match a certain condition helps you avoiding wrong or unnecessary extractions and can also save CPU resources. +The basic property that the resource should be in. -Default value: none +Default value: `present` -##### `condition_value` +##### `input` -Condition value +Title of the input this extractor is attached to. -Default value: '' +##### `order` -##### `converters` +Sort index for this extractor -A list of optional converter types which must be Java class identifiers of converters, such as org.graylog2.inputs.converters.NumericConverter +##### `source_field` -Default value: {} +Source field -##### `order` +##### `target_field` -Sort index for this extractor +Choose a field name to store the extracted value. It can only contain alphanumeric characters and underscores. Example: http_response_code. + +##### `type` + +The type of the Extractor. Must be the Java enum constant for the extractor, such as REGEX #### Parameters The following parameters are available in the `graylog_extractor` type. -##### `name` +* [`name`](#-graylog_extractor--name) +* [`provider`](#-graylog_extractor--provider) + +##### `name` namevar A descriptive name for this extractor. -### graylog_grok_pattern +##### `provider` + +The specific backend to use for this `graylog_extractor` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. + +### `graylog_grok_pattern` Installs a Grok pattern. Note that when representing Grok patterns in Puppet code or YAML-formatted Hiera data, extra escaping is necessary for @@ -2006,7 +2186,7 @@ graylog_api::grok::pattern_file defined type to define Grok patterns in their own dedicated file. * **See also** -graylog_api::grok::pattern + * graylog_api::grok::pattern #### Examples @@ -2024,11 +2204,11 @@ The following properties are available in the `graylog_grok_pattern` 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` ##### `pattern` @@ -2038,13 +2218,21 @@ The literal pattern string. The following parameters are available in the `graylog_grok_pattern` type. -##### `name` +* [`name`](#-graylog_grok_pattern--name) +* [`provider`](#-graylog_grok_pattern--provider) + +##### `name` namevar The token that represents the pattern. Must be in all-caps. -### graylog_index_set +##### `provider` + +The specific backend to use for this `graylog_grok_pattern` resource. You will seldom need to specify this --- Puppet +will usually discover the appropriate provider for your platform. + +### `graylog_index_set` Creates and configures an Index Set. Use the title 'graylog' to configure the pre-existing default index set created for new installations. @@ -2074,43 +2262,47 @@ graylog_index_set { 'graylog': The following properties are available in the `graylog_index_set` type. -##### `ensure` +##### `description` -Valid values: present, absent +A description of the Index Set -The basic property that the resource should be in. +##### `disable_index_optimization` -Default value: present +Disable Elasticsearch index optimization (force merge) after rotation. + +Default value: `false` ##### `display_name` The name of the Index Set -##### `description` +##### `ensure` -A description of the Index Set +Valid values: `present`, `absent` -##### `shards` +The basic property that the resource should be in. -Number of Elasticsearch shards used per index in this index set. +Default value: `present` -##### `replicas` +##### `index_analyzer` -Number of Elasticsearch replicas used per index in this index set. +Elasticsearch analyzer for this index set. -##### `rotation_strategy` +Default value: `standard` -Valid values: Puppet::Type::Graylog_index_set::ROTATION_STRATEGIES.keys +##### `max_segments` -What type of rotation strategy to use +Maximum number of segments per Elasticsearch index after optimization (force merge). -##### `rotation_strategy_details` +Default value: `1` -Configuration details for the chosen rotation strategy +##### `replicas` + +Number of Elasticsearch replicas used per index in this index set. ##### `retention_strategy` -Valid values: Puppet::Type::Graylog_index_set::RETENTION_STRATEGIES.keys +Valid values: `Puppet::Type::Graylog_index_set::RETENTION_STRATEGIES.keys` What type of retention strategy to use @@ -2118,36 +2310,42 @@ What type of retention strategy to use Configuration details for the chosen rention strategy -##### `index_analyzer` +##### `rotation_strategy` -Elasticsearch analyzer for this index set. +Valid values: `Puppet::Type::Graylog_index_set::ROTATION_STRATEGIES.keys` -Default value: standard +What type of rotation strategy to use -##### `max_segments` +##### `rotation_strategy_details` -Maximum number of segments per Elasticsearch index after optimization (force merge). +Configuration details for the chosen rotation strategy -Default value: 1 +##### `shards` -##### `disable_index_optimization` - -Disable Elasticsearch index optimization (force merge) after rotation. - -Default value: false +Number of Elasticsearch shards used per index in this index set. #### Parameters The following parameters are available in the `graylog_index_set` type. -##### `prefix` +* [`prefix`](#-graylog_index_set--prefix) +* [`provider`](#-graylog_index_set--provider) + +##### `prefix` namevar -A unique prefix used in Elasticsearch indices belonging to this index set. The prefix must start with a letter or number, and can only contain letters, numbers, '_', '-' and '+'. +A unique prefix used in Elasticsearch indices belonging to this index set. The prefix must start with a letter or +number, and can only contain letters, numbers, '_', '-' and '+'. -### graylog_input +##### `provider` +The specific backend to use for this `graylog_index_set` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. + +### `graylog_input` + +#{' '} This type covers the raw API and is agnostic to the type of input being created. In most cases, you should declare inputs using the graylog_api::input::* defined types, which wrap this type and provide @@ -2183,52 +2381,60 @@ graylog_input { 'Example Beats input': The following properties are available in the `graylog_input` type. -##### `ensure` +##### `configuration` -Valid values: present, absent +A hash of configuration values for the input; structure varies by input type. -The basic property that the resource should be in. +##### `ensure` -Default value: present +Valid values: `present`, `absent` -##### `type` +The basic property that the resource should be in. -The type of the Input. Must be the Java class identifier for the input, such as org.graylog.plugins.beats.BeatsInput. +Default value: `present` ##### `scope` -Valid values: local, global +Valid values: `local`, `global` Whether this input is defined on all nodes ('global') or just this node ('local'). -Default value: global - -##### `configuration` - -A hash of configuration values for the input; structure varies by input type. +Default value: `global` ##### `static_fields` A hash of static fields to apply to messages ingested by this input. +##### `type` + +The type of the Input. Must be the Java class identifier for the input, such as org.graylog.plugins.beats.BeatsInput. + #### Parameters The following parameters are available in the `graylog_input` type. -##### `name` +* [`name`](#-graylog_input--name) +* [`provider`](#-graylog_input--provider) + +##### `name` namevar The name of the Input Source -### graylog_ldap_settings +##### `provider` + +The specific backend to use for this `graylog_input` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. + +### `graylog_ldap_settings` Configures LDAP authentication, including the mapping between LDAP Groups and Graylog Roles. Make sure you also configure the Graylog Roles themselves using the graylog_role type. * **See also** -graylog_role + * graylog_role #### Examples @@ -2262,83 +2468,94 @@ graylog_ldap_settings { 'ldap': The following properties are available in the `graylog_ldap_settings` type. -##### `enabled` +##### `active_directory` -Whether to enable LDAP authentication. +Whether the LDAP server is an active directory server. -##### `system_username` +##### `additional_default_groups` -Username to bind to LDAP server as. +Additional groups to apply by default to all users. -##### `system_password` +##### `default_group` -Password to bind to LDAP server with. +The default group users are mapped to. -##### `ldap_uri` +##### `display_name_attribute` -URI of LDAP server, including protocol and port. +The attribute for user display names. -##### `use_start_tls` +##### `enabled` -Whether to use StartTLS +Whether to enable LDAP authentication. -##### `trust_all_certificates` +##### `group_id_attribute` -Whether to automatically trust all certificates when using StartTLS or LDAPS. +The attribute by which LDAP groups are identified. -##### `active_directory` +##### `group_mapping` -Whether the LDAP server is an active directory server. +A hash mapping LDAP groups to Graylog roles. -##### `search_base` +##### `group_search_base` -The search base for user lookups. +The search base for group lookups. -##### `search_pattern` +##### `group_search_pattern` -The LDAP filter for user lookups. +The LDAP filter for group lookups. -##### `default_group` +##### `ldap_uri` -The default group users are mapped to. +URI of LDAP server, including protocol and port. -##### `group_mapping` +##### `search_base` -A hash mapping LDAP groups to Graylog roles. +The search base for user lookups. -##### `group_search_base` +##### `search_pattern` -The search base for group lookups. +The LDAP filter for user lookups. -##### `group_id_attribute` +##### `system_password` -The attribute by which LDAP groups are identified. +Password to bind to LDAP server with. -##### `additional_default_groups` +##### `system_username` -Additional groups to apply by default to all users. +Username to bind to LDAP server as. -##### `group_search_pattern` +##### `trust_all_certificates` -The LDAP filter for group lookups. +Whether to automatically trust all certificates when using StartTLS or LDAPS. -##### `display_name_attribute` +##### `use_start_tls` -The attribute for user display names. +Whether to use StartTLS #### Parameters The following parameters are available in the `graylog_ldap_settings` type. -##### `name` +* [`name`](#-graylog_ldap_settings--name) +* [`provider`](#-graylog_ldap_settings--provider) + +##### `name` -Valid values: ldap +Valid values: `ldap` namevar Must be "ldap", only one instance of the graylog_ldap_settings type is allowed. -### graylog_lookup_adapter +##### `provider` + +The specific backend to use for this `graylog_ldap_settings` resource. You will seldom need to specify this --- Puppet +will usually discover the appropriate provider for your platform. + +### `graylog_lookup_adapter` + +@summary#{' '} + Creates a Lookup Table Data Adapter. Creates a Data Adapter for use with a Lookup table. At present all configuration must be done manually, there are not yet any convenience @@ -2371,37 +2588,45 @@ graylog_lookup_adapter { 'example-adapter': The following properties are available in the `graylog_lookup_adapter` type. -##### `ensure` +##### `configuration` -Valid values: present, absent +A hash of configuration for the Data Adapter. The exact configuration properties support will vary depending on the type of adapter being used. -The basic property that the resource should be in. +##### `description` -Default value: present +A description of the Data Adapter ##### `display_name` The display name (Graylog calls this "title") of the Data Adapter -##### `description` +##### `ensure` -A description of the Data Adapter +Valid values: `present`, `absent` -##### `configuration` +The basic property that the resource should be in. -A hash of configuration for the Data Adapter. The exact configuration properties support will vary depending on the type of adapter being used. +Default value: `present` #### Parameters The following parameters are available in the `graylog_lookup_adapter` type. -##### `name` +* [`name`](#-graylog_lookup_adapter--name) +* [`provider`](#-graylog_lookup_adapter--provider) + +##### `name` namevar The unique name of the Data Adapter. Must consist of only letters, numbers and dashes. -### graylog_lookup_cache +##### `provider` + +The specific backend to use for this `graylog_lookup_adapter` resource. You will seldom need to specify this --- Puppet +will usually discover the appropriate provider for your platform. + +### `graylog_lookup_cache` Creates a Cache for use with a Lookup Table. By default Graylog only supports two cache types, a noop cache called "none" and an in-memory @@ -2431,37 +2656,45 @@ graylog_lookup_cache { 'example-cache': The following properties are available in the `graylog_lookup_cache` type. -##### `ensure` +##### `configuration` -Valid values: present, absent +A hash of configuration for the Lookup Cache. The exact properties will vary depending on the type of cache being managed. -The basic property that the resource should be in. +##### `description` -Default value: present +A description of the Lookup Cache. ##### `display_name` The display name (Graylog calls this "title") of the Lookup Cache. -##### `description` +##### `ensure` -A description of the Lookup Cache. +Valid values: `present`, `absent` -##### `configuration` +The basic property that the resource should be in. -A hash of configuration for the Lookup Cache. The exact properties will vary depending on the type of cache being managed. +Default value: `present` #### Parameters The following parameters are available in the `graylog_lookup_cache` type. -##### `name` +* [`name`](#-graylog_lookup_cache--name) +* [`provider`](#-graylog_lookup_cache--provider) + +##### `name` namevar The unique name of the Lookup Cache. Must consist of only letters, numbers and dashes. -### graylog_lookup_table +##### `provider` + +The specific backend to use for this `graylog_lookup_cache` resource. You will seldom need to specify this --- Puppet +will usually discover the appropriate provider for your platform. + +### `graylog_lookup_table` Configures a Lookup Table. @@ -2487,21 +2720,21 @@ graylog_lookup_table { 'example-data': The following properties are available in the `graylog_lookup_table` type. -##### `ensure` +##### `adapter` -Valid values: present, absent +The name of the Lookup Adapter used for this Lookup Table. -The basic property that the resource should be in. +##### `cache` -Default value: present +The name of the Lookup Cache used for this Lookup Table. -##### `display_name` +##### `default_multi_value` -The display name (Graylog calls this "title") of the Lookup Table. +The default value for a multi-value lookup. -##### `description` +##### `default_multi_value_type` -A description of the Lookup Table. +The default value type for a multi-value lookup. ##### `default_single_value` @@ -2511,33 +2744,41 @@ The default value for a single-value lookup. The default value type for a single-value lookup. -##### `default_multi_value` +##### `description` -The default value for a multi-value lookup. +A description of the Lookup Table. -##### `default_multi_value_type` +##### `display_name` -The default value type for a multi-value lookup. +The display name (Graylog calls this "title") of the Lookup Table. -##### `adapter` +##### `ensure` -The name of the Lookup Adapter used for this Lookup Table. +Valid values: `present`, `absent` -##### `cache` +The basic property that the resource should be in. -The name of the Lookup Cache used for this Lookup Table. +Default value: `present` #### Parameters The following parameters are available in the `graylog_lookup_table` type. -##### `name` +* [`name`](#-graylog_lookup_table--name) +* [`provider`](#-graylog_lookup_table--provider) + +##### `name` namevar The unique name of the Lookup Table. Must consist of only letters, numbers and dashes. -### graylog_pipeline +##### `provider` + +The specific backend to use for this `graylog_lookup_table` resource. You will seldom need to specify this --- Puppet +will usually discover the appropriate provider for your platform. + +### `graylog_pipeline` Creates a processing pipeline. This type takes the pipeline definition as source text; note that the pipeline name in the source text must match the @@ -2546,7 +2787,7 @@ graylog_api::pipeline defined type, which can take care of this for you, as well as accepting e.g. an array of rules to apply rather than source text. * **See also** -graylog_api::pipeline + * graylog_api::pipeline #### Examples @@ -2572,40 +2813,48 @@ graylog_pipeline { 'example pipeline': The following properties are available in the `graylog_pipeline` type. -##### `ensure` - -Valid values: present, absent - -The basic property that the resource should be in. +##### `connected_streams` -Default value: present +Streams to process with this pipeline. Note that case matters, here. \ +Also note that, if the Pipeline Processor is running before the Message \ +Filter Chain, then the only stream that will have messages at processing \ +time will be the 'All messages' stream. ##### `description` A description of the processing pipeline. -##### `source` +##### `ensure` -The source code for the processing pipeline. +Valid values: `present`, `absent` -##### `connected_streams` +The basic property that the resource should be in. -Streams to process with this pipeline. Note that case matters, here. \ -Also note that, if the Pipeline Processor is running before the Message \ -Filter Chain, then the only stream that will have messages at processing \ -time will be the 'All messages' stream. +Default value: `present` + +##### `source` + +The source code for the processing pipeline. #### Parameters The following parameters are available in the `graylog_pipeline` type. -##### `name` +* [`name`](#-graylog_pipeline--name) +* [`provider`](#-graylog_pipeline--provider) + +##### `name` namevar The name of the processing pipeline. -### graylog_pipeline_rule +##### `provider` + +The specific backend to use for this `graylog_pipeline` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. + +### `graylog_pipeline_rule` Creates a Pipeline Rule. Note that the rule name given in the rule source must match the name of the resource as well. You may opt to use the @@ -2613,7 +2862,7 @@ graylog_api::pipeline::rule defined type instead, which manages that automatically. * **See also** -graylog_api::pipeline::rule + * graylog_api::pipeline::rule #### Examples @@ -2637,17 +2886,17 @@ graylog_pipeline_rule { 'example': The following properties are available in the `graylog_pipeline_rule` type. -##### `ensure` +##### `description` -Valid values: present, absent +A description of the pipeline rule. -The basic property that the resource should be in. +##### `ensure` -Default value: present +Valid values: `present`, `absent` -##### `description` +The basic property that the resource should be in. -A description of the pipeline rule. +Default value: `present` ##### `source` @@ -2657,13 +2906,21 @@ The source code for the pipeline rule. The following parameters are available in the `graylog_pipeline_rule` type. -##### `name` +* [`name`](#-graylog_pipeline_rule--name) +* [`provider`](#-graylog_pipeline_rule--provider) + +##### `name` namevar The name of the pipeline rule. -### graylog_plugin_auth_sso +##### `provider` + +The specific backend to use for this `graylog_pipeline_rule` resource. You will seldom need to specify this --- Puppet +will usually discover the appropriate provider for your platform. + +### `graylog_plugin_auth_sso` SSO authentication pluging configuration definition. @@ -2689,78 +2946,86 @@ graylog_auth_sso_plugin_config { 'sso': The following properties are available in the `graylog_plugin_auth_sso` type. -##### `ensure` - -Valid values: present, absent - -The basic property that the resource should be in. +##### `auto_create_user` -Default value: present +Enable this if Graylog should automatically create a user account for externally authenticated users. If disabled, an administrator needs to manually create a user account. -##### `trusted_proxies` +Default value: `false` -Enable this to require the request containing the SSO header as directly coming from a trusted proxy. This is highly recommended to avoid header injection. +##### `default_email_domain` -##### `username_header` +The default domain to use if there is no email header configured -HTTP header containing the implicitly trusted name of the Graylog user +##### `default_role` -##### `fullname_header` +The default Graylog role determines whether a user created can access the entire system, or has limited access. -HTTP header containing the full name of user to create (defaults to the user name). +Default value: `Reader` ##### `email_header` HTTP header containing the email address of user to create -##### `default_email_domain` +##### `ensure` -The default domain to use if there is no email header configured +Valid values: `present`, `absent` -##### `default_role` +The basic property that the resource should be in. -The default Graylog role determines whether a user created can access the entire system, or has limited access. +Default value: `present` -Default value: Reader +##### `fullname_header` + +HTTP header containing the full name of user to create (defaults to the user name). ##### `require_trusted_proxies` Enable this to require the request containing the SSO header as directly coming from a trusted proxy. This is highly recommended to avoid header injection. The current subnet setting is: 127.0.0.1/32, 0:0:0:0:0:0:0:1/128. You can configure the setting in the Graylog server configuration file. -Default value: true +Default value: `true` -##### `auto_create_user` +##### `roles_header` -Enable this if Graylog should automatically create a user account for externally authenticated users. If disabled, an administrator needs to manually create a user account. +Prefix of the HTTP header, can contain a comma-separated list of roles in one header, otherwise all headers with that prefix will be recognized. -Default value: false +Default value: `''` ##### `sync_roles` Enable this if Graylog should automatically synchronize the roles of the user, with that specified in the HTTP header. Only existing roles in Graylog will be added to the user. -Default value: false +Default value: `false` -##### `roles_header` +##### `trusted_proxies` -Prefix of the HTTP header, can contain a comma-separated list of roles in one header, otherwise all headers with that prefix will be recognized. +Enable this to require the request containing the SSO header as directly coming from a trusted proxy. This is highly recommended to avoid header injection. -Default value: '' +##### `username_header` + +HTTP header containing the implicitly trusted name of the Graylog user #### Parameters The following parameters are available in the `graylog_plugin_auth_sso` type. -##### `name` +* [`name`](#-graylog_plugin_auth_sso--name) +* [`provider`](#-graylog_plugin_auth_sso--provider) + +##### `name` -Valid values: sso +Valid values: `sso` namevar Must be "sso", only one instance of the graylog_plugin_auth_sso type is allowed. -### graylog_role +##### `provider` + +The specific backend to use for this `graylog_plugin_auth_sso` resource. You will seldom need to specify this --- Puppet +will usually discover the appropriate provider for your platform. + +### `graylog_role` A user role definition. Note that the Admin and Reader roles are built-in and cannot be modified. @@ -2791,17 +3056,17 @@ graylog_role { 'example': The following properties are available in the `graylog_role` type. -##### `ensure` +##### `description` -Valid values: present, absent +A description of the role. -The basic property that the resource should be in. +##### `ensure` -Default value: present +Valid values: `present`, `absent` -##### `description` +The basic property that the resource should be in. -A description of the role. +Default value: `present` ##### `permissions` @@ -2811,13 +3076,21 @@ Permissions this role provides, see the /system/permissions API endpoint for lis The following parameters are available in the `graylog_role` type. -##### `name` +* [`name`](#-graylog_role--name) +* [`provider`](#-graylog_role--provider) + +##### `name` namevar The name of the role -### graylog_stream +##### `provider` + +The specific backend to use for this `graylog_role` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. + +### `graylog_stream` Creates a Stream configuration. @@ -2834,7 +3107,7 @@ graylog_stream { 'example': type => 'equals', value => 'bar', }, - ], + ],#{' '} } ``` @@ -2842,14 +3115,6 @@ graylog_stream { 'example': The following properties are available in the `graylog_stream` type. -##### `ensure` - -Valid values: present, absent - -The basic property that the resource should be in. - -Default value: present - ##### `description` A description of the stream. @@ -2858,17 +3123,35 @@ A description of the stream. Whether this stream is enabled. -Default value: true +Default value: `true` + +##### `ensure` + +Valid values: `present`, `absent` + +The basic property that the resource should be in. + +Default value: `present` + +##### `index_set` + +The prefix of the index set that stream operates on. ##### `matching_type` -Valid values: AND, OR, and, or, all, any +Valid values: `AND`, `OR`, `and`, `or`, `all`, `any` -Aliases: "and"=>"AND", "or"=>"OR", "all"=>"AND", "any"=>"OR" +Aliases: `"and"=>"AND", "or"=>"OR", "all"=>"AND", "any"=>"OR"` Whether messages must match all rules, or any rule, to belong to the stream. -Default value: AND +Default value: `AND` + +##### `remove_matches_from_default_stream` + +Whether messages that appear in this stream get removed from the default stream. + +Default value: `false` ##### `rules` @@ -2881,27 +3164,25 @@ Each rule is a hash with the following keys: * inverted - boolean, whether to negate the match condition * description - string, a description of the rule -##### `remove_matches_from_default_stream` - -Whether messages that appear in this stream get removed from the default stream. - -Default value: false - -##### `index_set` - -The prefix of the index set that stream operates on. - #### Parameters The following parameters are available in the `graylog_stream` type. -##### `name` +* [`name`](#-graylog_stream--name) +* [`provider`](#-graylog_stream--provider) + +##### `name` namevar The name of the stream. -### graylog_user +##### `provider` + +The specific backend to use for this `graylog_stream` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. + +### `graylog_user` A user definition. Note that the admin user is built-in an cannot be changed. @@ -2913,9 +3194,9 @@ A user definition. Note that the admin user is built-in an cannot be changed. graylog_user { 'test': password => 'B1GnbfoNp9PND6ihXfZFjg', full_name => 'Test user', - email => 'foo@bar', + email => 'foo@bar',#{' '} roles => [ - 'Reader' + 'Reader'#{' '} ] } ``` @@ -2924,22 +3205,28 @@ graylog_user { 'test': The following properties are available in the `graylog_user` type. -##### `ensure` +##### `email` -Valid values: present, absent +User email address -The basic property that the resource should be in. +##### `ensure` -Default value: present +Valid values: `present`, `absent` -##### `email` +The basic property that the resource should be in. -User email address +Default value: `present` ##### `full_name` Full name of the user +##### `permissions` + +User permissions + +Default value: `[]` + ##### `roles` User roles @@ -2948,31 +3235,55 @@ User roles Session timeout -##### `permissions` - -User permissions +##### `startpage` -Default value: [] +User startpage ##### `timezone` User timezone -##### `startpage` - -User startpage - #### Parameters The following parameters are available in the `graylog_user` type. -##### `name` +* [`name`](#-graylog_user--name) +* [`password`](#-graylog_user--password) +* [`provider`](#-graylog_user--provider) + +##### `name` namevar The name of the user -##### `password` +##### `password` User password +##### `provider` + +The specific backend to use for this `graylog_user` resource. You will seldom need to specify this --- Puppet will +usually discover the appropriate provider for your platform. + +## Data types + +### `Graylog_api::Pipeline::Stage` + +Custom Type for Graylog_api pipeline stage + +Alias of + +```puppet +Struct[{ + match => Enum['all','either'], + rules => Array[String,1], +}] +``` + +### `Graylog_api::Pipeline::Stage::Loose` + +custom type for graylog_api pipeline stage loose + +Alias of `Variant[Graylog_api::Pipeline::Stage, Array[String,1], String]` + diff --git a/Rakefile b/Rakefile index f088c19..b4d2a8b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,77 +1,44 @@ -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? -require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? -require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -def changelog_user - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['author'] - raise "unable to find the changelog_user in .sync.yml, or the author in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator user:#{returnVal}" - returnVal +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), +# otherwise attempt to load it directly. +begin + require 'voxpupuli/test/rake' +rescue LoadError + begin + require 'puppetlabs_spec_helper/rake_tasks' + rescue LoadError + end end -def changelog_project - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['name'] - raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator project:#{returnVal}" - returnVal +# load optional tasks for acceptance +# only available if gem group releases is installed +begin + require 'voxpupuli/acceptance/rake' +rescue LoadError end -def changelog_future_release - return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] - raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? - puts "GitHubChangelogGenerator future_release:#{returnVal}" - returnVal +# load optional tasks for releases +# only available if gem group releases is installed +begin + require 'voxpupuli/release/rake_tasks' +rescue LoadError + # voxpupuli-release not present +else + GCGConfig.user = 'voxpupuli' + GCGConfig.project = 'puppet-graylog_api' end -PuppetLint.configuration.send('disable_relative') -PuppetLint.configuration.send('disable_parameter_order') - -if Bundler.rubygems.find_name('github_changelog_generator').any? - GitHubChangelogGenerator::RakeTask.new :changelog do |config| - raise "Set CHANGELOG_GITHUB_TOKEN environment variable eg 'export CHANGELOG_GITHUB_TOKEN=valid_token_here'" if Rake.application.top_level_tasks.include? "changelog" and ENV['CHANGELOG_GITHUB_TOKEN'].nil? - config.user = "#{changelog_user}" - config.project = "#{changelog_project}" - config.future_release = "#{changelog_future_release}" - config.exclude_labels = ['maintenance'] - config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)." - config.add_pr_wo_labels = true - config.issues = false - config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM" - config.configure_sections = { - "Changed" => { - "prefix" => "### Changed", - "labels" => ["backwards-incompatible"], - }, - "Added" => { - "prefix" => "### Added", - "labels" => ["feature", "enhancement"], - }, - "Fixed" => { - "prefix" => "### Fixed", - "labels" => ["bugfix"], - }, - } - end -else - desc 'Generate a Changelog from GitHub' - task :changelog do - raise <= Gem::Version.new('2.2.2')" -EOM +desc "Run main 'test' task and report merged results to coveralls" +task test_with_coveralls: [:test] do + if Dir.exist?(File.expand_path('../lib', __FILE__)) + require 'coveralls/rake/task' + Coveralls::RakeTask.new + Rake::Task['coveralls:push'].invoke + else + puts 'Skipping reporting to coveralls. Module has no lib dir' end end +# vim: syntax=ruby diff --git a/lib/puppet/feature/httparty.rb b/lib/puppet/feature/httparty.rb index 19a64b9..0eacc0f 100644 --- a/lib/puppet/feature/httparty.rb +++ b/lib/puppet/feature/httparty.rb @@ -1 +1 @@ -Puppet.features.add(:httparty, libs: ["httparty"]) \ No newline at end of file +Puppet.features.add(:httparty, libs: ['httparty']) diff --git a/lib/puppet/provider/graylog_api.rb b/lib/puppet/provider/graylog_api.rb index 7b76785..e81b957 100644 --- a/lib/puppet/provider/graylog_api.rb +++ b/lib/puppet/provider/graylog_api.rb @@ -3,7 +3,6 @@ require 'retries' if Puppet.features.retries? class Puppet::Provider::GraylogAPI < Puppet::Provider - confine feature: :json confine feature: :httparty confine feature: :retries @@ -13,7 +12,7 @@ class << self :ssl_ca_file, :verify_tls def api_password - @api_password || ENV['GRAYLOG_API_PASSWORD'] + @api_password || ENV.fetch('GRAYLOG_API_PASSWORD', nil) end def api_port @@ -49,24 +48,25 @@ def major_version end def tls_opts - api_tls ? { verify_tls: verify_tls, ssl_ca_file: ssl_ca_file} : {} + api_tls ? { verify_tls: verify_tls, ssl_ca_file: ssl_ca_file } : {} end - def request(method,path,params={}) + def request(method, path, params = {}) api_password = Puppet::Provider::GraylogAPI.api_password api_port = Puppet::Provider::GraylogAPI.api_port api_username = Puppet::Provider::GraylogAPI.api_username api_tls = Puppet::Provider::GraylogAPI.api_tls api_server = Puppet::Provider::GraylogAPI.api_server - fail "No Graylog_api['api'] resource defined!" unless api_password && api_port # It would be nicer to do this in the Type, but I don't see how without writing it over and over again for each type. + raise "No Graylog_api['api'] resource defined!" unless api_password && api_port # It would be nicer to do this in the Type, but I don't see how without writing it over and over again for each type. + case method when :get, :delete headers = { 'Accept' => 'application/json', 'X-Requested-By' => 'puppet', } - query = params + query = params body = nil when :post, :put headers = { @@ -102,7 +102,6 @@ def request(method,path,params={}) Puppet.debug("Got result #{result.body}") end - rescue HTTParty::ResponseError => e Puppet.send_log(:err, "Got error response #{e.response}") raise e @@ -113,13 +112,14 @@ def request(method,path,params={}) # Under Puppet Apply, undef in puppet-lang becomes :undef instead of nil def recursive_nil_to_undef(data) return data unless Puppet.settings[:name] == 'apply' + case data when nil :undef when Array - data.map {|item| recursive_nil_to_undef(item) } + data.map { |item| recursive_nil_to_undef(item) } when Hash - data.transform_values {|value| recursive_nil_to_undef(value) } + data.transform_values { |value| recursive_nil_to_undef(value) } else data end @@ -127,28 +127,28 @@ def recursive_nil_to_undef(data) # This intentionally only goes one layer deep def symbolize(hsh) - Hash[hsh.map {|k,v| [k.to_sym,v] }] + hsh.map { |k, v| [k.to_sym, v] }.to_h end - def get(path,params={}) - request(:get,path,params) + def get(path, params = {}) + request(:get, path, params) end - def put(path,params={}) - request(:put,path,params) + def put(path, params = {}) + request(:put, path, params) end - def post(path,params={}) - request(:post,path,params) + def post(path, params = {}) + request(:post, path, params) end - def delete(path,params={}) - request(:delete,path,params) + def delete(path, params = {}) + request(:delete, path, params) end def prefetch(resources) items = instances - resources.each_pair do |name,resource| + resources.each_pair do |name, resource| if provider = items.find { |item| item.name == name.to_s } resource.provider = provider end @@ -184,38 +184,38 @@ def destroy # Under Puppet Apply, undef in puppet-lang becomes :undef instead of nil def self.recursive_undef_to_nil(data) return data unless Puppet.settings[:name] == 'apply' + case data when :undef nil when Array - data.map {|item| recursive_undef_to_nil(item) } + data.map { |item| recursive_undef_to_nil(item) } when Hash - data.transform_values {|value| recursive_undef_to_nil(value) } + data.transform_values { |value| recursive_undef_to_nil(value) } else data end end - [:request, :get, :put, :post, :delete, :symbolize, :version, :major_version, :recursive_undef_to_nil].each do |m| + %i[request get put post delete symbolize version major_version recursive_undef_to_nil].each do |m| method = self.method(m) - define_method(m) {|*args| method.call(*args) } + define_method(m) { |*args| method.call(*args) } end def node_id get('/system')['node_id'] end - def simple_flush(path,params) + def simple_flush(path, params) params = recursive_undef_to_nil(params) case @action when :destroy delete("#{path}/#{rest_id}") when :create - response = post("#{path}",params) + response = post("#{path}", params) set_rest_id_on_create(response) if respond_to?(:set_rest_id_on_create) else - put("#{path}/#{rest_id}",params) + put("#{path}/#{rest_id}", params) end end - end diff --git a/lib/puppet/provider/graylog_api/graylog_api.rb b/lib/puppet/provider/graylog_api/graylog_api.rb index 1e8af35..96e9071 100644 --- a/lib/puppet/provider/graylog_api/graylog_api.rb +++ b/lib/puppet/provider/graylog_api/graylog_api.rb @@ -7,7 +7,7 @@ require 'httparty' if Puppet.features.httparty? Puppet::Type.type(:graylog_api).provide(:graylog_api) do - + @doc = 'Graylog Api base type' confine feature: :retries confine feature: :httparty @@ -32,7 +32,7 @@ def self.prefetch(resources) Puppet::Provider::GraylogAPI.verify_tls = verify_tls Puppet::Provider::GraylogAPI.ssl_ca_file = ssl_ca_file wait_for_api(port, server) - resources[:api].provider = new({password: password, port: port, username: username, tls: tls, server: server, verify_tls: verify_tls, ssl_ca_file: ssl_ca_file}) + resources[:api].provider = new({ password: password, port: port, username: username, tls: tls, server: server, verify_tls: verify_tls, ssl_ca_file: ssl_ca_file }) end # We also make sure that the Graylog server is actually up and responding @@ -40,11 +40,11 @@ def self.prefetch(resources) def self.wait_for_api(port, server) scheme = Puppet::Provider::GraylogAPI.api_tls ? 'https' : 'http' tls_opts = Puppet::Provider::GraylogAPI.tls_opts - Puppet.debug("Waiting for Graylog API") + Puppet.debug('Waiting for Graylog API') with_retries(max_tries: 60, base_sleep_seconds: 1, max_sleep_seconds: 1) do HTTParty.head("#{scheme}://#{server}:#{port}", **tls_opts) end rescue Errno::ECONNREFUSED - fail("Graylog API didn't become available on #{server} port #{port} after 30 seconds") + raise("Graylog API didn't become available on #{server} port #{port} after 30 seconds") end end diff --git a/lib/puppet/provider/graylog_dashboard/graylog_api.rb b/lib/puppet/provider/graylog_dashboard/graylog_api.rb index 8213a90..1ba1130 100644 --- a/lib/puppet/provider/graylog_dashboard/graylog_api.rb +++ b/lib/puppet/provider/graylog_dashboard/graylog_api.rb @@ -1,7 +1,7 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_dashboard).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog dashboard' mk_resource_methods attr_accessor :widgets @@ -12,10 +12,10 @@ def self.instances item = new( ensure: :present, name: data['title'], - description: data['description'], + description: data['description'] ) item.rest_id = data['id'] - item.widgets = data['widgets'].map {|w| {name: w['description'], id: w['id']} } + item.widgets = data['widgets'].map { |w| { name: w['description'], id: w['id'] } } item end end @@ -28,29 +28,28 @@ def need_to_purge_widgets? def widgets_in_catalog @widgets_in_catalog ||= resource.catalog.resources.find_all do |res| - res.class.to_s == 'Puppet::Type::Graylog_dashboard_widget' && - res[:name].split('!!!',2).first == resource[:name] + res.instance_of?(Puppet::Type::Graylog_dashboard_widget) && + res[:name].split('!!!', 2).first == resource[:name] end end def widgets_to_purge @widgets_to_purge ||= widgets.select do |widget| - widgets_in_catalog.none? {|w| w[:name].split('!!!',2)[1] == widget[:name] } + widgets_in_catalog.none? { |w| w[:name].split('!!!', 2)[1] == widget[:name] } end end def flush - simple_flush("dashboards",{ - title: resource[:name], - description: resource[:description], - }) + simple_flush('dashboards', { + title: resource[:name], + description: resource[:description], + }) Puppet.debug("@action = '#{@action}'") - if @action.nil? && resource[:purge] - widgets_to_purge.each do |widget| - Puppet.notice("Purging widget '#{widget[:name]}' from Dashboard #{resource[:name]}.") - delete("dashboards/#{rest_id}/widgets/#{widget[:id]}") - end + return unless @action.nil? && resource[:purge] + + widgets_to_purge.each do |widget| + Puppet.notice("Purging widget '#{widget[:name]}' from Dashboard #{resource[:name]}.") + delete("dashboards/#{rest_id}/widgets/#{widget[:id]}") end end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_dashboard_layout/graylog_api.rb b/lib/puppet/provider/graylog_dashboard_layout/graylog_api.rb index f7e73cf..9c178b5 100644 --- a/lib/puppet/provider/graylog_dashboard_layout/graylog_api.rb +++ b/lib/puppet/provider/graylog_dashboard_layout/graylog_api.rb @@ -1,12 +1,12 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_dashboard_layout).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog dashboard layout' mk_resource_methods def self.instances dashboards = get('dashboards')['dashboards'] - + dashboards.map do |dashboard| dashboard_name = dashboard['title'] widgets_data = dashboard['widgets'] @@ -15,7 +15,7 @@ def self.instances positions = {} positions_data.each_pair do |widget_id, position_data| - widget_data = widgets_data.find {|widget| widget['id'] == widget_id } + widget_data = widgets_data.find { |widget| widget['id'] == widget_id } Puppet.err("Could not find widget #{widget_id} on dashboard #{dashboard_name}") unless widget_data widget_name = widget_data ? widget_data['description'] : 'MISSING WIDGET' positions[widget_name] = { @@ -30,18 +30,18 @@ def self.instances new( name: dashboard_name, - positions: positions, + positions: positions ) end end def flush - dashboards = get("dashboards")['dashboards'] - dashboard = dashboards.find {|db| db['title'] == resource[:name] } + dashboards = get('dashboards')['dashboards'] + dashboard = dashboards.find { |db| db['title'] == resource[:name] } dashboard_id = dashboard['id'] - positions_data = resource[:positions].map do |widget_name,position| - widget_data = dashboard['widgets'].find {|widget| widget['description'] == widget_name } + positions_data = resource[:positions].map do |widget_name, position| + widget_data = dashboard['widgets'].find { |widget| widget['description'] == widget_name } { id: widget_data['id'], col: position['x'], @@ -51,6 +51,6 @@ def flush } end - put("dashboards/#{dashboard_id}/positions",{positions: positions_data}) + put("dashboards/#{dashboard_id}/positions", { positions: positions_data }) end -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_dashboard_widget/graylog_api.rb b/lib/puppet/provider/graylog_dashboard_widget/graylog_api.rb index 4a66d21..03a6c58 100644 --- a/lib/puppet/provider/graylog_dashboard_widget/graylog_api.rb +++ b/lib/puppet/provider/graylog_dashboard_widget/graylog_api.rb @@ -1,12 +1,12 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_dashboard_widget).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog dashboard widget' mk_resource_methods def self.instances dashboards = get('dashboards')['dashboards'] - + all_widgets = [] dashboards.each do |dashboard| @@ -18,7 +18,7 @@ def self.instances name: "#{dashboard_name}!!!#{data['description']}", cache_time: data['cache_time'], config: data['config'], - type: data['type'], + type: data['type'] ) widget.rest_id = id all_widgets << widget @@ -32,16 +32,16 @@ def set_rest_id_on_create(response) end def flush - dashboards = get("dashboards")['dashboards'] - dashboard_name, widget_name = resource[:name].split('!!!',2) - dashboard = dashboards.find {|db| db['title'] == dashboard_name } + dashboards = get('dashboards')['dashboards'] + dashboard_name, widget_name = resource[:name].split('!!!', 2) + dashboard = dashboards.find { |db| db['title'] == dashboard_name } dashboard_id = dashboard['id'] - simple_flush("dashboards/#{dashboard_id}/widgets",{ - description: widget_name, - cache_time: resource[:cache_time], - config: resource[:config], - type: resource[:type], - }) + simple_flush("dashboards/#{dashboard_id}/widgets", { + description: widget_name, + cache_time: resource[:cache_time], + config: resource[:config], + type: resource[:type], + }) end -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_extractor/graylog_api.rb b/lib/puppet/provider/graylog_extractor/graylog_api.rb index d756ad7..b3a1f75 100644 --- a/lib/puppet/provider/graylog_extractor/graylog_api.rb +++ b/lib/puppet/provider/graylog_extractor/graylog_api.rb @@ -1,24 +1,24 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_extractor).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog extractor' EXTRACTOR_TYPES = { copy_input: 'COPY_INPUT', grok: 'GROK', - json: 'JSON', + json: 'JSON', regex: 'REGEX', regex_replace: 'REGEX_REPLACE', split_and_index: 'SPLIT_AND_INDEX', - substring: 'SUBSTRING' + substring: 'SUBSTRING' } mk_resource_methods - - def self.instances + + def self.instances results = get('system/inputs') input_list = results['inputs'] - extractors = input_list.reduce([]) do |acc, input_data| + input_list.reduce([]) do |acc, input_data| results = get("system/inputs/#{input_data['id']}/extractors") extractors = results['extractors'].map do |data| @@ -38,29 +38,27 @@ def self.instances ) extractor.rest_id = data['id'] extractor - end + end - acc.concat(extractors) + acc.concat(extractors) end - - extractors end - + def flush input_rest_id = get_input_rest_id(resource[:input]) simple_flush("system/inputs/#{input_rest_id}/extractors", { - title: resource[:name], - cut_or_copy: resource[:cut_or_copy], - source_field: resource[:source_field], - target_field: resource[:target_field], - extractor_type: resource[:type], - extractor_config: resource[:configuration], - condition_type: resource[:condition_type], - condition_value: resource[:condition_value], - converters: resource[:converters], - order: resource[:order] - }) + title: resource[:name], + cut_or_copy: resource[:cut_or_copy], + source_field: resource[:source_field], + target_field: resource[:target_field], + extractor_type: resource[:type], + extractor_config: resource[:configuration], + condition_type: resource[:condition_type], + condition_value: resource[:condition_value], + converters: resource[:converters], + order: resource[:order] + }) end def set_rest_id_on_create(response) @@ -70,15 +68,12 @@ def set_rest_id_on_create(response) def get_input_rest_id(name) results = get('system/inputs') - id_list = results['inputs'] - .select {|data|data['title'] == name} - .map {|data|data['id']} - - if id_list.length == 0 - raise "Input #{name} doesn't exist" - end + id_list = results['inputs']. + select { |data| data['title'] == name }. + map { |data| data['id'] } + + raise "Input #{name} doesn't exist" if id_list.length == 0 id_list.first end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_grok_pattern/graylog_api.rb b/lib/puppet/provider/graylog_grok_pattern/graylog_api.rb index d935b1b..d231350 100644 --- a/lib/puppet/provider/graylog_grok_pattern/graylog_api.rb +++ b/lib/puppet/provider/graylog_grok_pattern/graylog_api.rb @@ -1,7 +1,7 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_grok_pattern).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog grok pattern' mk_resource_methods def self.instances @@ -10,7 +10,7 @@ def self.instances item = new( ensure: :present, name: data['name'], - pattern: data['pattern'], + pattern: data['pattern'] ) item.rest_id = data['id'] item @@ -18,10 +18,9 @@ def self.instances end def flush - simple_flush("system/grok",{ - name: resource[:name], - pattern: resource[:pattern], - }) + simple_flush('system/grok', { + name: resource[:name], + pattern: resource[:pattern], + }) end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_index_set/graylog_api.rb b/lib/puppet/provider/graylog_index_set/graylog_api.rb index a3fc792..1567630 100644 --- a/lib/puppet/provider/graylog_index_set/graylog_api.rb +++ b/lib/puppet/provider/graylog_index_set/graylog_api.rb @@ -2,7 +2,7 @@ require 'date' Puppet::Type.type(:graylog_index_set).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog index set' mk_resource_methods def self.instances @@ -16,9 +16,9 @@ def self.instances shards: data['shards'], replicas: data['replicas'], rotation_strategy: resource_type::ROTATION_STRATEGIES.key(data['rotation_strategy_class']), - rotation_strategy_details: data['rotation_strategy'].reject {|k,v| k == 'type' }, + rotation_strategy_details: data['rotation_strategy'].reject { |k, _v| k == 'type' }, retention_strategy: resource_type::RETENTION_STRATEGIES.key(data['retention_strategy_class']), - retention_strategy_details: data['retention_strategy'].reject {|k,v| k == 'type' }, + retention_strategy_details: data['retention_strategy'].reject { |k, _v| k == 'type' }, index_analyzer: data['index_analyzer'], max_segments: data['index_optimization_max_num_segments'], disable_index_optimization: data['index_optimization_disabled'] @@ -35,23 +35,22 @@ def name def flush rot_strat = Puppet::Type::Graylog_index_set::ROTATION_STRATEGIES[resource[:rotation_strategy]] ret_strat = Puppet::Type::Graylog_index_set::RETENTION_STRATEGIES[resource[:retention_strategy]] - simple_flush('system/indices/index_sets',{ - index_prefix: resource[:prefix], - title: resource[:display_name], - description: resource[:description], - shards: resource[:shards], - replicas: resource[:replicas], - rotation_strategy_class: rot_strat, - rotation_strategy: resource[:rotation_strategy_details].merge({type: "#{rot_strat}Config"}), - retention_strategy_class: ret_strat, - retention_strategy: resource[:retention_strategy_details].merge({type: "#{ret_strat}Config"}), - index_analyzer: resource[:index_analyzer], - index_optimization_max_num_segments: resource[:max_segments], - index_optimization_disabled: resource[:disable_index_optimization], - creation_date: DateTime.now.iso8601(3), - writable: true, - field_type_refresh_interval: 5000 - }) + simple_flush('system/indices/index_sets', { + index_prefix: resource[:prefix], + title: resource[:display_name], + description: resource[:description], + shards: resource[:shards], + replicas: resource[:replicas], + rotation_strategy_class: rot_strat, + rotation_strategy: resource[:rotation_strategy_details].merge({ type: "#{rot_strat}Config" }), + retention_strategy_class: ret_strat, + retention_strategy: resource[:retention_strategy_details].merge({ type: "#{ret_strat}Config" }), + index_analyzer: resource[:index_analyzer], + index_optimization_max_num_segments: resource[:max_segments], + index_optimization_disabled: resource[:disable_index_optimization], + creation_date: DateTime.now.iso8601(3), + writable: true, + field_type_refresh_interval: 5000 + }) end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_input/graylog_api.rb b/lib/puppet/provider/graylog_input/graylog_api.rb index 9013624..1f680e8 100644 --- a/lib/puppet/provider/graylog_input/graylog_api.rb +++ b/lib/puppet/provider/graylog_input/graylog_api.rb @@ -1,32 +1,32 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_input).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog input' INPUT_TYPES = { gelf_tcp: 'org.graylog2.inputs.gelf.tcp.GELFTCPInput', gelf_udp: 'org.graylog2.inputs.gelf.udp.GELFUDPInput', - gelf_http: 'org.graylog2.inputs.gelf.http.GELFHttpInput', - gelf_amqp: 'org.graylog2.inputs.gelf.amqp.GELFAMQPInput', - gelf_kafka: 'org.graylog2.inputs.gelf.kafka.GELFKafkaInput', - syslog_tcp: 'org.graylog2.inputs.syslog.tcp.SyslogTCPInput', - syslog_udp: 'org.graylog2.inputs.syslog.udp.SyslogUDPInput', - syslog_amqp: 'org.graylog2.inputs.syslog.amqp.SyslogAMQPInput', + gelf_http: 'org.graylog2.inputs.gelf.http.GELFHttpInput', + gelf_amqp: 'org.graylog2.inputs.gelf.amqp.GELFAMQPInput', + gelf_kafka: 'org.graylog2.inputs.gelf.kafka.GELFKafkaInput', + syslog_tcp: 'org.graylog2.inputs.syslog.tcp.SyslogTCPInput', + syslog_udp: 'org.graylog2.inputs.syslog.udp.SyslogUDPInput', + syslog_amqp: 'org.graylog2.inputs.syslog.amqp.SyslogAMQPInput', syslog_kafka: 'org.graylog2.inputs.syslog.kafka.SyslogKafkaInput', - raw_tcp: 'org.graylog2.inputs.raw.tcp.RawTCPInput', - raw_udp: 'org.graylog2.inputs.raw.udp.RawUDPInput', + raw_tcp: 'org.graylog2.inputs.raw.tcp.RawTCPInput', + raw_udp: 'org.graylog2.inputs.raw.udp.RawUDPInput', raw_amqp: 'org.graylog2.inputs.raw.amqp.RawAMQPInput', - raw_kafka: 'org.graylog2.inputs.raw.kafka.RawKafkaInput', - cef_tcp: 'org.graylog.plugins.cef.input.CEFTCPInput', - cef_udp: 'org.graylog.plugins.cef.input.CEFUDPInput', - cef_amqp: 'org.graylog.plugins.cef.input.CEFAmqpInput', - cef_kafka: 'org.graylog.plugins.cef.input.CEFKafkaInput', - aws_cloudtrail: 'org.graylog.aws.inputs.cloudtrail.CloudTrailInput', - aws_cloudwatch: 'org.graylog.aws.inputs.cloudwatch.CloudWatchLogsInput', + raw_kafka: 'org.graylog2.inputs.raw.kafka.RawKafkaInput', + cef_tcp: 'org.graylog.plugins.cef.input.CEFTCPInput', + cef_udp: 'org.graylog.plugins.cef.input.CEFUDPInput', + cef_amqp: 'org.graylog.plugins.cef.input.CEFAmqpInput', + cef_kafka: 'org.graylog.plugins.cef.input.CEFKafkaInput', + aws_cloudtrail: 'org.graylog.aws.inputs.cloudtrail.CloudTrailInput', + aws_cloudwatch: 'org.graylog.aws.inputs.cloudwatch.CloudWatchLogsInput', aws_flow_logs: 'org.graylog.aws.inputs.flowlogs.FlowLogsInput', netflow_udp: 'org.graylog.plugins.netflow.inputs.NetFlowUdpInput', beats: 'org.graylog.plugins.beats.BeatsInput', beats2: 'org.graylog.plugins.beats.Beats2Input', - json_path: 'org.graylog2.inputs.misc.jsonpath.JsonPathInput', + json_path: 'org.graylog2.inputs.misc.jsonpath.JsonPathInput', fake: 'org.graylog2.inputs.random.FakeHttpMessageInput', } @@ -41,7 +41,7 @@ def self.instances type: data['type'], scope: (data['global'] ? 'global' : 'local'), configuration: recursive_undef_to_nil(data['attributes']), - static_fields: data['static_fields'], + static_fields: data['static_fields'] ) input.rest_id = data['id'] input @@ -53,29 +53,29 @@ def set_rest_id_on_create(response) end def flush - simple_flush("system/inputs",{ - title: resource[:name], - type: resource[:type], - global: global?, - configuration: resource[:configuration], - node: node, - }) - update_static_fields if resource[:static_fields].kind_of?(Hash) && @action != :delete + simple_flush('system/inputs', { + title: resource[:name], + type: resource[:type], + global: global?, + configuration: resource[:configuration], + node: node, + }) + update_static_fields if resource[:static_fields].is_a?(Hash) && @action != :delete end def update_static_fields initial = initial_params[:static_fields] fields_to_add, fields_to_remove = if initial - [ - resource[:static_fields].select {|k,v| initial[k] != v }, - initial.keys - resource[:static_fields].keys - ] - else - [resource[:static_fields],[]] - end + [ + resource[:static_fields].select { |k, v| initial[k] != v }, + initial.keys - resource[:static_fields].keys + ] + else + [resource[:static_fields], []] + end - fields_to_add.each_pair do |key,value| - post("system/inputs/#{rest_id}/staticfields", {key: key, value: value}) + fields_to_add.each_pair do |key, value| + post("system/inputs/#{rest_id}/staticfields", { key: key, value: value }) end fields_to_remove.each do |key| @@ -90,5 +90,4 @@ def global? def node global? ? nil : node_id end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_ldap_settings/graylog_api.rb b/lib/puppet/provider/graylog_ldap_settings/graylog_api.rb index 30160a1..42e71f3 100644 --- a/lib/puppet/provider/graylog_ldap_settings/graylog_api.rb +++ b/lib/puppet/provider/graylog_ldap_settings/graylog_api.rb @@ -1,7 +1,7 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_ldap_settings).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog ldap settings' mk_resource_methods def self.instances @@ -10,9 +10,8 @@ def self.instances end def flush - Puppet.info("Flushing graylog_ldap_settings") - data = @property_hash.reject {|k,v| k == :name } - put('system/ldap/settings',recursive_undef_to_nil(data)) + Puppet.info('Flushing graylog_ldap_settings') + data = @property_hash.reject { |k, _v| k == :name } + put('system/ldap/settings', recursive_undef_to_nil(data)) end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_lookup_adapter/graylog_api.rb b/lib/puppet/provider/graylog_lookup_adapter/graylog_api.rb index fe0269c..dca62c3 100644 --- a/lib/puppet/provider/graylog_lookup_adapter/graylog_api.rb +++ b/lib/puppet/provider/graylog_lookup_adapter/graylog_api.rb @@ -1,7 +1,7 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_lookup_adapter).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog lookup adapter' mk_resource_methods def self.instances @@ -12,7 +12,7 @@ def self.instances name: data['name'], description: data['description'], display_name: data['title'], - configuration: recursive_undef_to_nil(data['config']), + configuration: recursive_undef_to_nil(data['config']) ) adapter.rest_id = data['id'] adapter @@ -20,12 +20,11 @@ def self.instances end def flush - simple_flush("system/lookup/adapters",{ - name: resource[:name], - title: resource[:display_name], - description: resource[:description], - config: resource[:configuration], - }) + simple_flush('system/lookup/adapters', { + name: resource[:name], + title: resource[:display_name], + description: resource[:description], + config: resource[:configuration], + }) end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_lookup_cache/graylog_api.rb b/lib/puppet/provider/graylog_lookup_cache/graylog_api.rb index 49d5fd4..308b908 100644 --- a/lib/puppet/provider/graylog_lookup_cache/graylog_api.rb +++ b/lib/puppet/provider/graylog_lookup_cache/graylog_api.rb @@ -1,7 +1,7 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_lookup_cache).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog lookup cache' mk_resource_methods def self.instances @@ -12,7 +12,7 @@ def self.instances name: data['name'], description: data['description'], display_name: data['title'], - configuration: recursive_undef_to_nil(data['config']), + configuration: recursive_undef_to_nil(data['config']) ) cache.rest_id = data['id'] cache @@ -27,7 +27,6 @@ def flush config: resource[:configuration], } data[:id] = rest_id if rest_id - simple_flush("system/lookup/caches", data) + simple_flush('system/lookup/caches', data) end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_lookup_table/graylog_api.rb b/lib/puppet/provider/graylog_lookup_table/graylog_api.rb index 5d6348b..f9ae7a4 100644 --- a/lib/puppet/provider/graylog_lookup_table/graylog_api.rb +++ b/lib/puppet/provider/graylog_lookup_table/graylog_api.rb @@ -1,7 +1,7 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_lookup_table).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog lookup table' mk_resource_methods def self.instances @@ -10,8 +10,8 @@ def self.instances caches = get('system/lookup/caches')['caches'] tables.map do |data| - cache_name = caches.find {|cache| cache['id'] == data['cache_id'] }['name'] - adapter_name = adapters.find {|adapter| adapter['id'] == data['data_adapter_id'] }['name'] + cache_name = caches.find { |cache| cache['id'] == data['cache_id'] }['name'] + adapter_name = adapters.find { |adapter| adapter['id'] == data['data_adapter_id'] }['name'] table = new( ensure: :present, name: data['name'], @@ -22,7 +22,7 @@ def self.instances default_single_value: data['default_single_value'], default_single_value_type: data['default_single_value_type'], default_multi_value: data['default_multi_value'], - default_multi_value_type: data['default_multi_value_type'], + default_multi_value_type: data['default_multi_value_type'] ) table.rest_id = data['id'] table @@ -44,7 +44,6 @@ def flush default_multi_value_type: resource[:default_multi_value_type], } data[:id] = rest_id if rest_id - simple_flush("system/lookup/tables",data) + simple_flush('system/lookup/tables', data) end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_pipeline/graylog_api.rb b/lib/puppet/provider/graylog_pipeline/graylog_api.rb index 69bb1b2..8bc1ecb 100644 --- a/lib/puppet/provider/graylog_pipeline/graylog_api.rb +++ b/lib/puppet/provider/graylog_pipeline/graylog_api.rb @@ -1,12 +1,13 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_pipeline).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog pipeline' mk_resource_methods def self.api_prefix major_version == 2 ? 'plugins/org.graylog.plugins.pipelineprocessor/' : '' end + def api_prefix self.class.api_prefix end @@ -15,7 +16,7 @@ def self.instances pipelines = get("#{api_prefix}system/pipelines/pipeline") connections = get("#{api_prefix}system/pipelines/connections") pipelines.map do |data| - connected_streams = connections.select {|conn| conn['pipeline_ids'].include?(data['id']) }.map do |conn| + connected_streams = connections.select { |conn| conn['pipeline_ids'].include?(data['id']) }.map do |conn| stream_id = conn['stream_id'] stream_data = get("streams/#{stream_id}") stream_data['title'] @@ -25,7 +26,7 @@ def self.instances name: data['title'], description: data['description'], source: data['source'], - connected_streams: connected_streams, + connected_streams: connected_streams ) item.rest_id = data['id'] item @@ -37,20 +38,21 @@ def set_rest_id_on_create(response) end def flush - simple_flush("#{api_prefix}system/pipelines/pipeline",{ - title: resource[:name], - description: resource[:description], - source: resource[:source], - }) + simple_flush("#{api_prefix}system/pipelines/pipeline", { + title: resource[:name], + description: resource[:description], + source: resource[:source], + }) all_streams = get('streams')['streams'] connected_stream_ids = resource[:connected_streams].map do |stream_name| - stream = all_streams.find {|stream| stream['title'] == stream_name } + stream = all_streams.find { |stream| stream['title'] == stream_name } raise "Could not find stream named #{stream_name}" unless stream + stream['id'] end - post("#{api_prefix}system/pipelines/connections/to_pipeline",{ - pipeline_id: self.rest_id, - stream_ids: connected_stream_ids, - }) + post("#{api_prefix}system/pipelines/connections/to_pipeline", { + pipeline_id: rest_id, + stream_ids: connected_stream_ids, + }) end -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_pipeline_rule/graylog_api.rb b/lib/puppet/provider/graylog_pipeline_rule/graylog_api.rb index 086205f..258595e 100644 --- a/lib/puppet/provider/graylog_pipeline_rule/graylog_api.rb +++ b/lib/puppet/provider/graylog_pipeline_rule/graylog_api.rb @@ -1,12 +1,13 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_pipeline_rule).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog pipeline rule' mk_resource_methods def self.api_prefix major_version == 2 ? 'plugins/org.graylog.plugins.pipelineprocessor/' : '' end + def api_prefix self.class.api_prefix end @@ -18,7 +19,7 @@ def self.instances ensure: :present, name: data['title'], description: data['description'], - source: data['source'], + source: data['source'] ) item.rest_id = data['id'] item @@ -26,11 +27,10 @@ def self.instances end def flush - simple_flush("#{api_prefix}system/pipelines/rule",{ - title: resource[:name], - description: resource[:description], - source: resource[:source], - }) + simple_flush("#{api_prefix}system/pipelines/rule", { + title: resource[:name], + description: resource[:description], + source: resource[:source], + }) end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_plugin_auth_sso/graylog_api.rb b/lib/puppet/provider/graylog_plugin_auth_sso/graylog_api.rb index 7f315c5..851b64a 100644 --- a/lib/puppet/provider/graylog_plugin_auth_sso/graylog_api.rb +++ b/lib/puppet/provider/graylog_plugin_auth_sso/graylog_api.rb @@ -1,42 +1,40 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_plugin_auth_sso).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog plugin auth sso' mk_resource_methods def self.instances - data = get('plugins/org.graylog.plugins.auth.sso/config') - [new( - ensure: :present, - name: 'sso', - trusted_proxies: data['trusted_proxies'], - default_role: data['default_group'], - username_header: data['username_header'], - require_trusted_proxies: data['require_trusted_proxies'], - auto_create_user: data['auto_create_user'], - fullname_header: data['fullname_header'], - email_header: data['email_header'], - default_email_domain: data['default_email_domain'], - sync_roles: data['sync_roles'], - roles_header: data['roles_header'] - )] + data = get('plugins/org.graylog.plugins.auth.sso/config') + [new( + ensure: :present, + name: 'sso', + trusted_proxies: data['trusted_proxies'], + default_role: data['default_group'], + username_header: data['username_header'], + require_trusted_proxies: data['require_trusted_proxies'], + auto_create_user: data['auto_create_user'], + fullname_header: data['fullname_header'], + email_header: data['email_header'], + default_email_domain: data['default_email_domain'], + sync_roles: data['sync_roles'], + roles_header: data['roles_header'] + )] end - def flush - Puppet.info("Flushing graylog_plugin_auth_sso") + Puppet.info('Flushing graylog_plugin_auth_sso') put('plugins/org.graylog.plugins.auth.sso/config', { - trusted_proxies: resource[:trusted_proxies], - default_group: resource[:default_role], - username_header: resource[:username_header], - require_trusted_proxies: resource[:require_trusted_proxies], - auto_create_user: resource[:auto_create_user], - fullname_header: resource[:fullname_header], - email_header: resource[:email_header], - default_email_domain: resource[:default_email_domain], - sync_roles: resource[:sync_roles], - roles_header: resource[:roles_header] - }) + trusted_proxies: resource[:trusted_proxies], + default_group: resource[:default_role], + username_header: resource[:username_header], + require_trusted_proxies: resource[:require_trusted_proxies], + auto_create_user: resource[:auto_create_user], + fullname_header: resource[:fullname_header], + email_header: resource[:email_header], + default_email_domain: resource[:default_email_domain], + sync_roles: resource[:sync_roles], + roles_header: resource[:roles_header] + }) end - end diff --git a/lib/puppet/provider/graylog_role/graylog_api.rb b/lib/puppet/provider/graylog_role/graylog_api.rb index 8edb9b9..f49d375 100644 --- a/lib/puppet/provider/graylog_role/graylog_api.rb +++ b/lib/puppet/provider/graylog_role/graylog_api.rb @@ -1,7 +1,7 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_role).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog role' mk_resource_methods attr_writer :permission_cache @@ -10,7 +10,7 @@ def self.instances cache = [] results = get('roles') items = results['roles'].map do |data| - next if ['Admin', 'Reader'].include?(data['name']) + next if %w[Admin Reader].include?(data['name']) permissions = permissions_to_names(data['permissions'], cache) role = new( @@ -33,12 +33,12 @@ def flush Puppet.send_log(:info, "FLUSH: PUPPET: #{resource[:name]}: #{resource[:permissions]}") Puppet.send_log(:info, "FLUSH: TO GRAYLOG #{resource[:name]}: #{permissions}") - simple_flush("roles",{ - name: resource[:name], - description: resource[:description], - permissions: permissions, - read_only: false, - }) + simple_flush('roles', { + name: resource[:name], + description: resource[:description], + permissions: permissions, + read_only: false, + }) end def set_rest_id_on_create(response) @@ -46,7 +46,7 @@ def set_rest_id_on_create(response) end def self.get_ref(permission) - permission[/^streams:\w+:(.+)/, 1] + permission[%r{^streams:\w+:(.+)}, 1] end def self.read_cache(ref, cache) @@ -61,28 +61,25 @@ def self.write_cache(ref, cache) stream['id'] == ref || stream['title'] == ref end - if !stream + unless stream Puppet.send_log(:err, "Stream reference not found #{ref}") raise end - data = { :id => stream['id'], :name => stream['title'] } + data = { id: stream['id'], name: stream['title'] } cache.push(data) data end def self.map_permissions(list, cache, key) list.map do |permission| - if permission.match?(/^streams:\w+:/) + if permission.match?(%r{^streams:\w+:}) ref = get_ref(permission) stream = read_cache(ref, cache) - if !stream - stream = write_cache(ref, cache) - end - + stream ||= write_cache(ref, cache) - permission.sub(/^(streams:\w+):(.+)/, "\\1:#{stream[key]}") + permission.sub(%r{^(streams:\w+):(.+)}, "\\1:#{stream[key]}") else permission end @@ -96,5 +93,4 @@ def self.permissions_to_names(list, cache) def self.permissions_to_ids(list, cache) map_permissions(list, cache, :id) end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_stream/graylog_api.rb b/lib/puppet/provider/graylog_stream/graylog_api.rb index 3860520..df9e661 100644 --- a/lib/puppet/provider/graylog_stream/graylog_api.rb +++ b/lib/puppet/provider/graylog_stream/graylog_api.rb @@ -1,7 +1,7 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_stream).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog stream' mk_resource_methods def self.instances @@ -13,9 +13,9 @@ def self.instances description: data['description'], matching_type: data['matching_type'], enabled: !data['disabled'], - rules: data['rules'].map {|defn| rule_from_data(defn) }, + rules: data['rules'].map { |defn| rule_from_data(defn) }, remove_matches_from_default_stream: data['remove_matches_from_default_stream'], - index_set: index_set_prefix_from_id(data['index_set_id']), + index_set: index_set_prefix_from_id(data['index_set_id']) ) stream.rest_id = data['id'] stream @@ -26,7 +26,7 @@ def self.index_set_prefix_from_id(index_set_id) get("system/indices/index_sets/#{index_set_id}")['prefix'] end - RULE_TYPES = %w{equals matches greater_than less_than field_presence contain always_match} + RULE_TYPES = %w[equals matches greater_than less_than field_presence contain always_match] def self.rule_from_data(d) data = recursive_undef_to_nil(d) @@ -40,23 +40,23 @@ def self.rule_from_data(d) end def flush - simple_flush('streams',{ - title: resource[:name], - description: resource[:description], - matching_type: resource[:matching_type], - rules: resource[:rules].map {|defn| data_from_rule(defn) }, - remove_matches_from_default_stream: resource[:remove_matches_from_default_stream], - index_set_id: index_set_id_from_prefix(resource[:index_set]) - }) + simple_flush('streams', { + title: resource[:name], + description: resource[:description], + matching_type: resource[:matching_type], + rules: resource[:rules].map { |defn| data_from_rule(defn) }, + remove_matches_from_default_stream: resource[:remove_matches_from_default_stream], + index_set_id: index_set_id_from_prefix(resource[:index_set]) + }) - if exists? - update_rules() + return unless exists? - if resource[:enabled] - post("streams/#{rest_id}/resume") - else - post("streams/#{rest_id}/pause") - end + update_rules + + if resource[:enabled] + post("streams/#{rest_id}/resume") + else + post("streams/#{rest_id}/pause") end end @@ -64,19 +64,19 @@ def set_rest_id_on_create(response) @rest_id = response['stream_id'] end - def update_rules() - rules_res = resource[:rules].map {|defn| data_from_rule(defn) } + def update_rules + rules_res = resource[:rules].map { |defn| data_from_rule(defn) } rules_gl = get("streams/#{rest_id}/rules") - rules_res.each {|rule_res| - rule_gl = rules_gl['stream_rules'].find {|rule_gl| rule_res['description'] == rule_gl['description']} + rules_res.each do |rule_res| + rule_gl = rules_gl['stream_rules'].find { |rule_gl| rule_res['description'] == rule_gl['description'] } if rule_gl put("streams/#{rest_id}/rules/#{rule_gl['id']}", rule_res) else post("streams/#{rest_id}/rules", rule_res) end - } + end end def data_from_rule(rule) @@ -90,13 +90,12 @@ def data_from_rule(rule) end def index_set_id_from_prefix(index_set_prefix) - index_sets = get("system/indices/index_sets")['index_sets'] + index_sets = get('system/indices/index_sets')['index_sets'] index_set = if index_set_prefix - index_sets.find {|set| set['index_prefix'] == index_set_prefix } - else - index_sets.find {|set| set['default'] } - end + index_sets.find { |set| set['index_prefix'] == index_set_prefix } + else + index_sets.find { |set| set['default'] } + end index_set['id'] end - -end \ No newline at end of file +end diff --git a/lib/puppet/provider/graylog_user/graylog_api.rb b/lib/puppet/provider/graylog_user/graylog_api.rb index 64b4bdb..5d6dcff 100644 --- a/lib/puppet/provider/graylog_user/graylog_api.rb +++ b/lib/puppet/provider/graylog_user/graylog_api.rb @@ -1,13 +1,14 @@ require_relative '../graylog_api' Puppet::Type.type(:graylog_user).provide(:graylog_api, parent: Puppet::Provider::GraylogAPI) do - + @doc = 'graylog api type for graylog user' mk_resource_methods def self.instances results = get('users') items = results['users'].map do |data| next if data['username'] == 'admin' || data['external'] == true + new( ensure: :present, name: data['username'], @@ -36,12 +37,11 @@ def flush if @action simple_flush('users', params.merge({ - username: resource[:name], - password: resource[:password] - })) + username: resource[:name], + password: resource[:password] + })) else simple_flush('users', params) end end - -end \ No newline at end of file +end diff --git a/lib/puppet/type/graylog_api.rb b/lib/puppet/type/graylog_api.rb index 4b730c0..6a468a1 100644 --- a/lib/puppet/type/graylog_api.rb +++ b/lib/puppet/type/graylog_api.rb @@ -6,7 +6,6 @@ require_relative '../provider/graylog_api' Puppet::Type.newtype(:graylog_api) do - desc <<-END_OF_DOC @summary Sets the API credentials used by the rest of the types in the module. @@ -37,18 +36,18 @@ isrequired def retrieve - "password" + 'password' end - def should_to_s(newvalue) - "password" + def should_to_s(_newvalue) + 'password' end - def is_to_s(value) - "password" + def is_to_s(_value) + 'password' end - def insync?(is) + def insync?(_is) true end end @@ -61,7 +60,7 @@ def retrieve 'username' end - def insync?(is) + def insync?(_is) true end end @@ -71,10 +70,10 @@ def insync?(is) isrequired def retrieve - "port" + 'port' end - def insync?(is) + def insync?(_is) true end end @@ -87,7 +86,7 @@ def retrieve 'tls' end - def insync?(is) + def insync?(_is) true end end @@ -100,7 +99,7 @@ def retrieve 'verify_tls' end - def insync?(is) + def insync?(_is) true end end @@ -109,17 +108,17 @@ def insync?(is) desc 'The certificate authority file' defaultto('/etc/pki/tls/certs/ca-bundle.crt') -# validate do |value| -# unless Puppet::Util.absolute_path?(value) -# fail Puppet::Error, _("File paths must be fully qualified, not '%{path}'") % { path: value } -# end -# end + # validate do |value| + # unless Puppet::Util.absolute_path?(value) + # fail Puppet::Error, _("File paths must be fully qualified, not '%{path}'") % { path: value } + # end + # end def retrieve 'ssl_ca_file' end - def insync?(is) + def insync?(_is) true end end @@ -132,7 +131,7 @@ def retrieve 'server' end - def insync?(is) + def insync?(_is) true end end diff --git a/lib/puppet/type/graylog_dashboard.rb b/lib/puppet/type/graylog_dashboard.rb index 6cfb5b1..2bcf0c3 100644 --- a/lib/puppet/type/graylog_dashboard.rb +++ b/lib/puppet/type/graylog_dashboard.rb @@ -1,11 +1,10 @@ require 'puppet/property/boolean' Puppet::Type.newtype(:graylog_dashboard) do - desc <<-END_OF_DOC @summary Creates an Dashboard. - + #{' '} @see graylog_dashboard_widget @see graylog_dashboard_layout @@ -28,10 +27,10 @@ newproperty(:purge, boolean: true, parent: Puppet::Property::Boolean) do desc "Whether to remove widgets from this dashboard if they aren't declared in Puppet" - def insync?(is) + def insync?(_is) !provider.need_to_purge_widgets? end end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_dashboard_layout.rb b/lib/puppet/type/graylog_dashboard_layout.rb index a27eb11..7933947 100644 --- a/lib/puppet/type/graylog_dashboard_layout.rb +++ b/lib/puppet/type/graylog_dashboard_layout.rb @@ -1,9 +1,8 @@ Puppet::Type.newtype(:graylog_dashboard_layout) do - desc <<-END_OF_DOC @summary Lays out the widgets on a dashboard. - + #{' '} @see graylog_dashboard @see graylog_dashboard_widget @@ -31,7 +30,7 @@ * h - The height of this widget END_OF_PROPERTY validate do |all_widgets| - all_widgets.each_pair do |key,value| + all_widgets.each_pair do |key, value| raise ArgumentError, "Widget #{key} must have a x-position," unless value.has_key?('x') raise Argumenterror, "Widget #{key} must have a y-position." unless value.has_key?('y') raise ArgumentError, "Widget #{key} must have a width." unless value.has_key?('w') @@ -40,7 +39,7 @@ end end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } autorequire('graylog_dashboard') { self[:name] } - autorequire('graylog_dashboard_widget') { self[:positions].keys.map {|widget_name| "#{self[:name]}!!!#{widget_name}" } } + autorequire('graylog_dashboard_widget') { self[:positions].keys.map { |widget_name| "#{self[:name]}!!!#{widget_name}" } } end diff --git a/lib/puppet/type/graylog_dashboard_widget.rb b/lib/puppet/type/graylog_dashboard_widget.rb index 5f81517..6452dc5 100644 --- a/lib/puppet/type/graylog_dashboard_widget.rb +++ b/lib/puppet/type/graylog_dashboard_widget.rb @@ -1,12 +1,11 @@ Puppet::Type.newtype(:graylog_dashboard_widget) do - desc <<-END_OF_DOC @summary Creates an Dashboard Widget. The title of this resource should be the name of the dashboard on which the widget appears, followed by !!!, followed by the name of the widget. - + #{' '} @see graylog_dashboard @see graylog_dashboard_layout @@ -34,7 +33,7 @@ newparam(:name) do desc 'The name of the dashboard on which this widget appears, followed by !!!, followed by the name of the widget.' validate do |value| - raise ArgumentError, "name parameter must include both dashboard name and widget name, separated by !!!; instead was '#{value}'" unless value =~ /.+!!!.+/ + raise ArgumentError, "name parameter must include both dashboard name and widget name, separated by !!!; instead was '#{value}'" unless value =~ %r{.+!!!.+} end end @@ -50,7 +49,6 @@ desc 'The type of widget.' end - - autorequire('graylog_api') {'api'} - autorequire('graylog_dashboard') { self[:name].split('!!!',2).first } + autorequire('graylog_api') { 'api' } + autorequire('graylog_dashboard') { self[:name].split('!!!', 2).first } end diff --git a/lib/puppet/type/graylog_extractor.rb b/lib/puppet/type/graylog_extractor.rb index b3bfed6..a2da0fb 100644 --- a/lib/puppet/type/graylog_extractor.rb +++ b/lib/puppet/type/graylog_extractor.rb @@ -1,6 +1,5 @@ Puppet::Type.newtype(:graylog_extractor) do - - desc <<-END_OF_DOC + desc <<-END_OF_DOC @summary Creates an Extractor. @@ -21,65 +20,65 @@ value => '^#(.*)' }, } - END_OF_DOC - - ensurable + END_OF_DOC - newparam(:name) do - desc 'A descriptive name for this extractor.' - end + ensurable - newproperty(:input) do - desc 'Title of the input this extractor is attached to.' - isrequired - end + newparam(:name) do + desc 'A descriptive name for this extractor.' + end - newproperty(:type) do - desc 'The type of the Extractor. Must be the Java enum constant for the extractor, such as REGEX' - isrequired - end + newproperty(:input) do + desc 'Title of the input this extractor is attached to.' + isrequired + end - newproperty(:source_field) do - desc 'Source field' - isrequired - end + newproperty(:type) do + desc 'The type of the Extractor. Must be the Java enum constant for the extractor, such as REGEX' + isrequired + end - newproperty(:target_field) do - desc 'Choose a field name to store the extracted value. It can only contain alphanumeric characters and underscores. Example: http_response_code.' - isrequired - end + newproperty(:source_field) do + desc 'Source field' + isrequired + end - newproperty(:configuration) do - desc 'A hash of configuration values for the extractor; structure varies by extractor type.' - isrequired - end + newproperty(:target_field) do + desc 'Choose a field name to store the extracted value. It can only contain alphanumeric characters and underscores. Example: http_response_code.' + isrequired + end - newproperty(:cut_or_copy) do - desc 'Do you want to copy or cut from source? You cannot use the cutting feature on standard fields like message and source.' - newvalues(:copy, :cut) - defaultto(:copy) - end + newproperty(:configuration) do + desc 'A hash of configuration values for the extractor; structure varies by extractor type.' + isrequired + end - newproperty(:condition_type) do - desc 'Extracting only from messages that match a certain condition helps you avoiding wrong or unnecessary extractions and can also save CPU resources.' - newvalues(:none, :regex, :string) - defaultto(:none) - end + newproperty(:cut_or_copy) do + desc 'Do you want to copy or cut from source? You cannot use the cutting feature on standard fields like message and source.' + newvalues(:copy, :cut) + defaultto(:copy) + end - newproperty(:condition_value) do - desc 'Condition value' - defaultto('') - end + newproperty(:condition_type) do + desc 'Extracting only from messages that match a certain condition helps you avoiding wrong or unnecessary extractions and can also save CPU resources.' + newvalues(:none, :regex, :string) + defaultto(:none) + end - newproperty(:converters) do - desc 'A list of optional converter types which must be Java class identifiers of converters, such as org.graylog2.inputs.converters.NumericConverter' - defaultto({}) - end + newproperty(:condition_value) do + desc 'Condition value' + defaultto('') + end - newproperty(:order) do - desc 'Sort index for this extractor' - #defaultto(0) - end + newproperty(:converters) do + desc 'A list of optional converter types which must be Java class identifiers of converters, such as org.graylog2.inputs.converters.NumericConverter' + defaultto({}) + end - autorequire('graylog_api') {'api'} + newproperty(:order) do + desc 'Sort index for this extractor' + # defaultto(0) end + + autorequire('graylog_api') { 'api' } +end diff --git a/lib/puppet/type/graylog_grok_pattern.rb b/lib/puppet/type/graylog_grok_pattern.rb index 76f6f69..f14d408 100644 --- a/lib/puppet/type/graylog_grok_pattern.rb +++ b/lib/puppet/type/graylog_grok_pattern.rb @@ -2,7 +2,7 @@ desc <<~END_OF_DOC @summary Installs a Grok pattern. - + Installs a Grok pattern. Note that when representing Grok patterns in Puppet code or YAML-formatted Hiera data, extra escaping is necessary for many regex characters. Thus, it is often more convenient to use the @@ -22,7 +22,7 @@ newparam(:name) do desc 'The token that represents the pattern. Must be in all-caps.' validate do |value| - raise ArgumentError, "Pattern token must match /[A-Z0-9_]+/" unless value =~ /[A-Z0-9_]+/ + raise ArgumentError, 'Pattern token must match /[A-Z0-9_]+/' unless value =~ %r{[A-Z0-9_]+} end end @@ -30,5 +30,5 @@ desc 'The literal pattern string.' end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_index_set.rb b/lib/puppet/type/graylog_index_set.rb index b133961..0d772b7 100644 --- a/lib/puppet/type/graylog_index_set.rb +++ b/lib/puppet/type/graylog_index_set.rb @@ -1,11 +1,10 @@ require 'puppet/property/boolean' Puppet::Type.newtype(:graylog_index_set) do - desc <<-END_OF_DOC @summary Defines an Index Set. - + Creates and configures an Index Set. Use the title 'graylog' to configure the pre-existing default index set created for new installations. @@ -32,7 +31,7 @@ isnamevar desc "A unique prefix used in Elasticsearch indices belonging to this index set. The prefix must start with a letter or number, and can only contain letters, numbers, '_', '-' and '+'." validate do |value| - fail "The prefix must start with a letter or number, and can only contain letters, numbers, '_', '-' and '+'." unless value =~ /^[a-zA-Z0-9][a-zA-Z0-9+_-]*$/ + raise "The prefix must start with a letter or number, and can only contain letters, numbers, '_', '-' and '+'." unless value =~ %r{^[a-zA-Z0-9][a-zA-Z0-9+_-]*$} end end @@ -41,61 +40,61 @@ end newproperty(:description) do - desc "A description of the Index Set" + desc 'A description of the Index Set' end newproperty(:shards) do - desc "Number of Elasticsearch shards used per index in this index set." + desc 'Number of Elasticsearch shards used per index in this index set.' end newproperty(:replicas) do - desc "Number of Elasticsearch replicas used per index in this index set." + desc 'Number of Elasticsearch replicas used per index in this index set.' end Puppet::Type::Graylog_index_set::ROTATION_STRATEGIES = { - age: "org.graylog2.indexer.rotation.strategies.TimeBasedRotationStrategy", - count: "org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategy", - size: "org.graylog2.indexer.rotation.strategies.SizeBasedRotationStrategy", + age: 'org.graylog2.indexer.rotation.strategies.TimeBasedRotationStrategy', + count: 'org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategy', + size: 'org.graylog2.indexer.rotation.strategies.SizeBasedRotationStrategy', } newproperty(:rotation_strategy) do - desc "What type of rotation strategy to use" + desc 'What type of rotation strategy to use' newvalues(*Puppet::Type::Graylog_index_set::ROTATION_STRATEGIES.keys) end newproperty(:rotation_strategy_details) do - desc "Configuration details for the chosen rotation strategy" + desc 'Configuration details for the chosen rotation strategy' end Puppet::Type::Graylog_index_set::RETENTION_STRATEGIES = { - close: "org.graylog2.indexer.retention.strategies.ClosingRetentionStrategy", - delete: "org.graylog2.indexer.retention.strategies.DeletionRetentionStrategy", - noop: "org.graylog2.indexer.retention.strategies.NoopRetentionStrategy", + close: 'org.graylog2.indexer.retention.strategies.ClosingRetentionStrategy', + delete: 'org.graylog2.indexer.retention.strategies.DeletionRetentionStrategy', + noop: 'org.graylog2.indexer.retention.strategies.NoopRetentionStrategy', } newproperty(:retention_strategy) do - desc "What type of retention strategy to use" + desc 'What type of retention strategy to use' newvalues(*Puppet::Type::Graylog_index_set::RETENTION_STRATEGIES.keys) end newproperty(:retention_strategy_details) do - desc "Configuration details for the chosen rention strategy" + desc 'Configuration details for the chosen rention strategy' end newproperty(:index_analyzer) do - desc "Elasticsearch analyzer for this index set." + desc 'Elasticsearch analyzer for this index set.' defaultto('standard') end newproperty(:max_segments) do - desc "Maximum number of segments per Elasticsearch index after optimization (force merge)." + desc 'Maximum number of segments per Elasticsearch index after optimization (force merge).' defaultto(1) end newproperty(:disable_index_optimization, boolean: true, parent: Puppet::Property::Boolean) do - desc "Disable Elasticsearch index optimization (force merge) after rotation." + desc 'Disable Elasticsearch index optimization (force merge) after rotation.' defaultto(false) end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_input.rb b/lib/puppet/type/graylog_input.rb index 80d9cee..8e6aafa 100644 --- a/lib/puppet/type/graylog_input.rb +++ b/lib/puppet/type/graylog_input.rb @@ -1,9 +1,8 @@ Puppet::Type.newtype(:graylog_input) do - desc <<-END_OF_DOC @summary Creates an Input. - + #{' '} This type covers the raw API and is agnostic to the type of input being created. In most cases, you should declare inputs using the graylog_api::input::* defined types, which wrap this type and provide @@ -48,13 +47,13 @@ end newproperty(:configuration) do - desc "A hash of configuration values for the input; structure varies by input type." + desc 'A hash of configuration values for the input; structure varies by input type.' isrequired end newproperty(:static_fields) do - desc "A hash of static fields to apply to messages ingested by this input." + desc 'A hash of static fields to apply to messages ingested by this input.' end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_ldap_settings.rb b/lib/puppet/type/graylog_ldap_settings.rb index 011740e..5bca869 100644 --- a/lib/puppet/type/graylog_ldap_settings.rb +++ b/lib/puppet/type/graylog_ldap_settings.rb @@ -1,7 +1,6 @@ require 'puppet/property/boolean' Puppet::Type.newtype(:graylog_ldap_settings) do - desc <<-END_OF_DOC @summary Configures LDAP authentication. @@ -41,76 +40,76 @@ end newproperty(:enabled, boolean: true, parent: Puppet::Property::Boolean) do - desc "Whether to enable LDAP authentication." + desc 'Whether to enable LDAP authentication.' end newproperty(:system_username) do - desc "Username to bind to LDAP server as." + desc 'Username to bind to LDAP server as.' end newproperty(:system_password) do - desc "Password to bind to LDAP server with." - def should_to_s(value) - "[REDACTED]" + desc 'Password to bind to LDAP server with.' + def should_to_s(_value) + '[REDACTED]' end - def is_to_s(value) - "[REDACTED]" + def is_to_s(_value) + '[REDACTED]' end end newproperty(:ldap_uri) do - desc "URI of LDAP server, including protocol and port." + desc 'URI of LDAP server, including protocol and port.' end newproperty(:use_start_tls) do - desc "Whether to use StartTLS" + desc 'Whether to use StartTLS' end newproperty(:trust_all_certificates, boolean: true, parent: Puppet::Property::Boolean) do - desc "Whether to automatically trust all certificates when using StartTLS or LDAPS." + desc 'Whether to automatically trust all certificates when using StartTLS or LDAPS.' end newproperty(:active_directory, boolean: true, parent: Puppet::Property::Boolean) do - desc "Whether the LDAP server is an active directory server." + desc 'Whether the LDAP server is an active directory server.' end newproperty(:search_base) do - desc "The search base for user lookups." + desc 'The search base for user lookups.' end newproperty(:search_pattern) do - desc "The LDAP filter for user lookups." + desc 'The LDAP filter for user lookups.' end newproperty(:default_group) do - desc "The default group users are mapped to." + desc 'The default group users are mapped to.' end newproperty(:group_mapping) do - desc "A hash mapping LDAP groups to Graylog roles." + desc 'A hash mapping LDAP groups to Graylog roles.' end newproperty(:group_search_base) do - desc "The search base for group lookups." + desc 'The search base for group lookups.' end newproperty(:group_id_attribute) do - desc "The attribute by which LDAP groups are identified." + desc 'The attribute by which LDAP groups are identified.' end newproperty(:additional_default_groups, array_matching: :all) do - desc "Additional groups to apply by default to all users." + desc 'Additional groups to apply by default to all users.' end newproperty(:group_search_pattern) do - desc "The LDAP filter for group lookups." + desc 'The LDAP filter for group lookups.' end newproperty(:display_name_attribute) do - desc "The attribute for user display names." + desc 'The attribute for user display names.' end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } autorequire('graylog_role') { self[:group_mapping].values + [self[:default_group]] } end diff --git a/lib/puppet/type/graylog_lookup_adapter.rb b/lib/puppet/type/graylog_lookup_adapter.rb index 44b0759..6fd9910 100644 --- a/lib/puppet/type/graylog_lookup_adapter.rb +++ b/lib/puppet/type/graylog_lookup_adapter.rb @@ -1,7 +1,6 @@ Puppet::Type.newtype(:graylog_lookup_adapter) do - desc <<-END_OF_DOC - @summary + @summary#{' '} Creates a Lookup Table Data Adapter. Creates a Data Adapter for use with a Lookup table. At present all @@ -33,7 +32,7 @@ newparam(:name) do desc 'The unique name of the Data Adapter. Must consist of only letters, numbers and dashes.' validate do |value| - raise ArgumentError, "#{value} is not a valid name." unless value =~ /^[a-z0-9-]+$/ + raise ArgumentError, "#{value} is not a valid name." unless value =~ %r{^[a-z0-9-]+$} end end @@ -49,5 +48,5 @@ desc 'A hash of configuration for the Data Adapter. The exact configuration properties support will vary depending on the type of adapter being used.' end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_lookup_cache.rb b/lib/puppet/type/graylog_lookup_cache.rb index 7aae73f..c208c15 100644 --- a/lib/puppet/type/graylog_lookup_cache.rb +++ b/lib/puppet/type/graylog_lookup_cache.rb @@ -1,5 +1,4 @@ Puppet::Type.newtype(:graylog_lookup_cache) do - desc <<-END_OF_DOC @summary Creates a Lookup Table Cache. @@ -23,13 +22,13 @@ }, } END_OF_DOC - + ensurable newparam(:name) do desc 'The unique name of the Lookup Cache. Must consist of only letters, numbers and dashes.' validate do |value| - raise ArgumentError, "#{value} is not a valid name." unless value =~ /^[a-z0-9-]+$/ + raise ArgumentError, "#{value} is not a valid name." unless value =~ %r{^[a-z0-9-]+$} end end @@ -45,5 +44,5 @@ desc 'A hash of configuration for the Lookup Cache. The exact properties will vary depending on the type of cache being managed.' end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_lookup_table.rb b/lib/puppet/type/graylog_lookup_table.rb index a526ccb..be2433a 100644 --- a/lib/puppet/type/graylog_lookup_table.rb +++ b/lib/puppet/type/graylog_lookup_table.rb @@ -1,5 +1,4 @@ Puppet::Type.newtype(:graylog_lookup_table) do - desc <<-END_OF_DOC @summary Configures a Lookup Table. @@ -23,7 +22,7 @@ newparam(:name) do desc 'The unique name of the Lookup Table. Must consist of only letters, numbers and dashes.' validate do |value| - raise ArgumentError, "#{value} is not a valid name." unless value =~ /^[a-z0-9-]+$/ + raise ArgumentError, "#{value} is not a valid name." unless value =~ %r{^[a-z0-9-]+$} end end @@ -59,7 +58,7 @@ desc 'The name of the Lookup Cache used for this Lookup Table.' end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } autorequire('graylog_lookup_adapter') { self[:ensure] == 'absent' ? [] : self[:adapter] } autorequire('graylog_lookup_cache') { self[:ensure] == 'absent' ? [] : self[:cache] } autobefore('graylog_lookup_adapter') { self[:ensure] == 'absent' ? self[:adapter] : [] } diff --git a/lib/puppet/type/graylog_pipeline.rb b/lib/puppet/type/graylog_pipeline.rb index e383bd8..fda96c3 100644 --- a/lib/puppet/type/graylog_pipeline.rb +++ b/lib/puppet/type/graylog_pipeline.rb @@ -1,11 +1,10 @@ require 'puppet/property/boolean' Puppet::Type.newtype(:graylog_pipeline) do - desc <<-END_OF_DOC @summary Creates a processing pipleine. - + Creates a processing pipeline. This type takes the pipeline definition as source text; note that the pipeline name in the source text must match the resource title. Overall, you may find it more convenient to use the @@ -52,10 +51,11 @@ end validate do - match_data = self[:source].match(/\A\s*pipeline\s+"(.+?)"/) - fail("Pipeline source does not appear to begin with a pipeline-title declaration!") unless match_data + match_data = self[:source].match(%r{\A\s*pipeline\s+"(.+?)"}) + raise('Pipeline source does not appear to begin with a pipeline-title declaration!') unless match_data + inline_name = match_data.captures[0] - fail("Name in pipeline source (#{inline_name}) doesn't match resource title (#{self[:name]})!") unless inline_name == self[:name] + raise("Name in pipeline source (#{inline_name}) doesn't match resource title (#{self[:name]})!") unless inline_name == self[:name] end autorequire('graylog_api') { 'api' } diff --git a/lib/puppet/type/graylog_pipeline_rule.rb b/lib/puppet/type/graylog_pipeline_rule.rb index f25f79d..df9a564 100644 --- a/lib/puppet/type/graylog_pipeline_rule.rb +++ b/lib/puppet/type/graylog_pipeline_rule.rb @@ -1,7 +1,6 @@ require 'puppet/property/boolean' Puppet::Type.newtype(:graylog_pipeline_rule) do - desc <<-END_OF_DOC @summary Creates a Pipeline Rule. @@ -42,11 +41,12 @@ end validate do - match_data = self[:source].match(/\A\s*rule\s+"(.+?)"/) - fail("Rule source does not appear to begin with a rule-title declaration!") unless match_data + match_data = self[:source].match(%r{\A\s*rule\s+"(.+?)"}) + raise('Rule source does not appear to begin with a rule-title declaration!') unless match_data + inline_name = match_data.captures[0] - fail("Name in rule source (#{inline_name}) doesn't match resource title (#{self[:name]})!") unless inline_name == self[:name] + raise("Name in rule source (#{inline_name}) doesn't match resource title (#{self[:name]})!") unless inline_name == self[:name] end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_plugin_auth_sso.rb b/lib/puppet/type/graylog_plugin_auth_sso.rb index 51e1acd..95eb1b8 100644 --- a/lib/puppet/type/graylog_plugin_auth_sso.rb +++ b/lib/puppet/type/graylog_plugin_auth_sso.rb @@ -1,7 +1,6 @@ require 'puppet/property/boolean' Puppet::Type.newtype(:graylog_plugin_auth_sso) do - desc <<-END_OF_DOC @summary SSO authentication plugin configuration @@ -80,5 +79,5 @@ defaultto('') end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_role.rb b/lib/puppet/type/graylog_role.rb index 0258602..ebad864 100644 --- a/lib/puppet/type/graylog_role.rb +++ b/lib/puppet/type/graylog_role.rb @@ -1,5 +1,4 @@ Puppet::Type.newtype(:graylog_role) do - desc <<-END_OF_DOC @summary Creates a user role. @@ -30,8 +29,8 @@ newparam(:name) do desc 'The name of the role' validate do |value| - fail "The Admin role is built-in and may not be changed" if value == 'Admin' - fail "The Reader role is built-in and may not be changed" if value == 'Reader' + raise 'The Admin role is built-in and may not be changed' if value == 'Admin' + raise 'The Reader role is built-in and may not be changed' if value == 'Reader' end end @@ -40,11 +39,11 @@ end newproperty(:permissions, array_matching: :all) do - desc "Permissions this role provides, see the /system/permissions API endpoint for list of valid permissions." + desc 'Permissions this role provides, see the /system/permissions API endpoint for list of valid permissions.' def insync?(is) is.sort == should.sort end end - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_stream.rb b/lib/puppet/type/graylog_stream.rb index b8ad844..841c23b 100644 --- a/lib/puppet/type/graylog_stream.rb +++ b/lib/puppet/type/graylog_stream.rb @@ -1,7 +1,6 @@ require 'puppet/property/boolean' Puppet::Type.newtype(:graylog_stream) do - desc <<-END_OF_DOC @summary Creates a Stream configuration. @@ -15,7 +14,7 @@ type => 'equals', value => 'bar', }, - ], + ],#{' '} } END_OF_DOC @@ -30,13 +29,12 @@ end newproperty(:enabled, boolean: true, parent: Puppet::Property::Boolean) do - desc "Whether this stream is enabled." + desc 'Whether this stream is enabled.' defaultto(true) end - newproperty(:matching_type) do - desc "Whether messages must match all rules, or any rule, to belong to the stream." + desc 'Whether messages must match all rules, or any rule, to belong to the stream.' newvalues(:AND, :OR) aliasvalue(:and, :AND) aliasvalue(:or, :OR) @@ -62,17 +60,16 @@ end newproperty(:remove_matches_from_default_stream, boolean: true, parent: Puppet::Property::Boolean) do - desc "Whether messages that appear in this stream get removed from the default stream." + desc 'Whether messages that appear in this stream get removed from the default stream.' defaultto(false) end newproperty(:index_set) do - desc "The prefix of the index set that stream operates on." + desc 'The prefix of the index set that stream operates on.' end # TODO: Implement alert_conditions # TODO: Implement alert_receivers # TODO: Implement outputs - - autorequire('graylog_api') {'api'} + autorequire('graylog_api') { 'api' } end diff --git a/lib/puppet/type/graylog_user.rb b/lib/puppet/type/graylog_user.rb index 1f50bc6..dacd6cd 100644 --- a/lib/puppet/type/graylog_user.rb +++ b/lib/puppet/type/graylog_user.rb @@ -1,65 +1,64 @@ - Puppet::Type.newtype(:graylog_user) do - - desc <<-END_OF_DOC +Puppet::Type.newtype(:graylog_user) do + desc <<-END_OF_DOC @summary Creates a internal user - + A user definition. Note that the admin user is built-in an cannot be changed. - + @example graylog_user { 'test': password => 'B1GnbfoNp9PND6ihXfZFjg', full_name => 'Test user', - email => 'foo@bar', + email => 'foo@bar',#{' '} roles => [ - 'Reader' + 'Reader'#{' '} ] } - END_OF_DOC - - ensurable - - newparam(:name) do - desc 'The name of the user' - end - - newparam(:password) do - desc 'User password' - sensitive - end + END_OF_DOC + + ensurable + + newparam(:name) do + desc 'The name of the user' + end + + newparam(:password) do + desc 'User password' + sensitive + end - newproperty(:email) do - desc 'User email address' - isrequired - end + newproperty(:email) do + desc 'User email address' + isrequired + end - newproperty(:full_name) do - desc 'Full name of the user' - isrequired - end + newproperty(:full_name) do + desc 'Full name of the user' + isrequired + end - newproperty(:roles, :array_matching => :all) do - desc 'User roles' - isrequired - end + newproperty(:roles, array_matching: :all) do + desc 'User roles' + isrequired + end - newproperty(:session_timeout_ms) do - desc 'Session timeout' - isrequired - end + newproperty(:session_timeout_ms) do + desc 'Session timeout' + isrequired + end - newproperty(:permissions, :array_matching => :all) do - desc 'User permissions' - defaultto([]) - end + newproperty(:permissions, array_matching: :all) do + desc 'User permissions' + defaultto([]) + end - newproperty(:timezone) do - desc 'User timezone' - end + newproperty(:timezone) do + desc 'User timezone' + end - newproperty(:startpage) do - desc 'User startpage' - end + newproperty(:startpage) do + desc 'User startpage' + end - autorequire('graylog_api') {'api'} - end \ No newline at end of file + autorequire('graylog_api') { 'api' } +end diff --git a/manifests/extractor/regex.pp b/manifests/extractor/regex.pp index 014f43b..1e941db 100644 --- a/manifests/extractor/regex.pp +++ b/manifests/extractor/regex.pp @@ -31,7 +31,7 @@ # @param order # Sort index for this extractor. # -define graylog_api::extractor::regex( +define graylog_api::extractor::regex ( Enum['present','absent'] $ensure = 'present', String $input = '', String $source_field = '', @@ -42,20 +42,20 @@ Optional[String] $condition_value = undef, Optional[Array] $converters = undef, Optional[Integer] $order = undef -){ +) { graylog_extractor { $name: - ensure => $ensure, - input => $input, - type => 'REGEX', - source_field => $source_field, - target_field => $target_field, - cut_or_copy => $cut_or_copy, + ensure => $ensure, + input => $input, + type => 'REGEX', + source_field => $source_field, + target_field => $target_field, + cut_or_copy => $cut_or_copy, condition_type => $condition_type, condition_value => $condition_value, converters => $converters, order => $order, configuration => { - regex_value => $regex_value - } + regex_value => $regex_value, + }, } } diff --git a/manifests/extractor/regex_replace.pp b/manifests/extractor/regex_replace.pp index 398c846..f9cb991 100644 --- a/manifests/extractor/regex_replace.pp +++ b/manifests/extractor/regex_replace.pp @@ -13,7 +13,7 @@ # @param target_field # Choose a field name to store the extracted value. It can only contain alphanumeric characters and underscores. Example: http_response_code. # -# @param regex_value +# @param regex # Title of the input this extractor is attached to. # # @param cut_or_copy @@ -31,35 +31,35 @@ # @param order # Sort index for this extractor. # -define graylog_api::extractor::regex_replace( +define graylog_api::extractor::regex_replace ( Enum['present','absent'] $ensure = 'present', String $input = '', String $source_field = '', String $target_field = '', - String $regex = '', + String $regex = '', String $replacement = '', - Optional[Boolean] $replace_all = false, + Boolean $replace_all = false, Optional[String] $cut_or_copy = undef, Optional[String] $condition_type = undef, Optional[String] $condition_value = undef, Optional[Array] $converters = undef, Optional[Integer] $order = undef -){ +) { graylog_extractor { $name: - ensure => $ensure, - input => $input, - type => 'REGEX_REPLACE', - source_field => $source_field, - target_field => $target_field, - cut_or_copy => $cut_or_copy, + ensure => $ensure, + input => $input, + type => 'REGEX_REPLACE', + source_field => $source_field, + target_field => $target_field, + cut_or_copy => $cut_or_copy, condition_type => $condition_type, condition_value => $condition_value, converters => $converters, order => $order, configuration => { - regex => $regex, - replacement => $replacement, - replace_all => $replace_all - } + regex => $regex, + replacement => $replacement, + replace_all => $replace_all, + }, } } diff --git a/manifests/grok/pattern_file.pp b/manifests/grok/pattern_file.pp index e485dd3..7349a5f 100644 --- a/manifests/grok/pattern_file.pp +++ b/manifests/grok/pattern_file.pp @@ -22,7 +22,7 @@ # are safely skipped. Actual pattern lines begin with the pattern name in # all-caps, followed by a space, followed by the pattern itself. See the # Graylog documentation for a full description of the Grok pattern format. -define graylog_api::grok::pattern_file( +define graylog_api::grok::pattern_file ( String $contents, ) { $contents.split("\n").each |$line| { diff --git a/manifests/input/beats.pp b/manifests/input/beats.pp index 47c85ad..1463426 100644 --- a/manifests/input/beats.pp +++ b/manifests/input/beats.pp @@ -62,7 +62,7 @@ # @param tls_key_password # The password to decrypt to private key specified in tls_key_file. Leave # blank if not using TLS, or if the key is not encrypted. -define graylog_api::input::beats( +define graylog_api::input::beats ( Enum['present','absent'] $ensure = 'present', String $bind_address = '0.0.0.0', Optional[String] $override_source = undef, @@ -77,7 +77,7 @@ Boolean $tls_enable = false, String $tls_key_file = '', String $tls_key_password = '', -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog.plugins.beats.BeatsInput', diff --git a/manifests/input/beats2.pp b/manifests/input/beats2.pp index 3ad26c6..b6ded9c 100644 --- a/manifests/input/beats2.pp +++ b/manifests/input/beats2.pp @@ -66,7 +66,7 @@ # @param tls_key_password # The password to decrypt to private key specified in tls_key_file. Leave # blank if not using TLS, or if the key is not encrypted. -define graylog_api::input::beats2( +define graylog_api::input::beats2 ( Enum['present','absent'] $ensure = 'present', String $bind_address = '0.0.0.0', Boolean $include_beats_prefix = false, @@ -82,7 +82,7 @@ Boolean $tls_enable = false, String $tls_key_file = '', String $tls_key_password = '', -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog.plugins.beats.Beats2Input', diff --git a/manifests/input/cef_tcp.pp b/manifests/input/cef_tcp.pp index 80b5765..64244b0 100644 --- a/manifests/input/cef_tcp.pp +++ b/manifests/input/cef_tcp.pp @@ -78,7 +78,7 @@ # @param use_null_delimiter # Whether to use a null byte as a frame delimiter. If false, a newline is # used as the delimiter instead. -define graylog_api::input::cef_tcp( +define graylog_api::input::cef_tcp ( Enum['present','absent'] $ensure = 'present', String $bind_address = '0.0.0.0', String $locale = 'en', @@ -98,7 +98,7 @@ String $tls_key_password = '', Boolean $use_full_names = false, Boolean $use_null_delimiter = false, -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog.plugins.cef.input.CEFTCPInput', diff --git a/manifests/input/cef_udp.pp b/manifests/input/cef_udp.pp index 35529bd..90ab887 100644 --- a/manifests/input/cef_udp.pp +++ b/manifests/input/cef_udp.pp @@ -40,10 +40,7 @@ # Whether to use full field names in CEF messages (as defined in the CEF # specification). # -# @param use_null_delimiter -# Whether to use a null byte as a frame delimiter. If false, a newline is -# used as the delimiter instead. -define graylog_api::input::cef_udp( +define graylog_api::input::cef_udp ( Enum['present','absent'] $ensure = 'present', String $bind_address = '0.0.0.0', String $locale = 'en', @@ -54,7 +51,7 @@ Optional[Hash] $static_fields = undef, String $timezone = 'UTC', Boolean $use_full_names = false, -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog.plugins.cef.input.CEFTCPInput', diff --git a/manifests/input/gelf_http.pp b/manifests/input/gelf_http.pp index 3f6a79d..8256a69 100644 --- a/manifests/input/gelf_http.pp +++ b/manifests/input/gelf_http.pp @@ -75,7 +75,7 @@ # @param tls_key_password # The password to decrypt to private key specified in tls_key_file. Leave # blank if not using TLS, or if the key is not encrypted. -define graylog_api::input::gelf_http( +define graylog_api::input::gelf_http ( Enum['present','absent'] $ensure = 'present', String $bind_address = '0.0.0.0', Integer $decompress_size_limit = '8 MB'.to_bytes, @@ -94,7 +94,7 @@ Boolean $tls_enable = false, String $tls_key_file = '', String $tls_key_password = '', -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog2.inputs.gelf.http.GELFHttpInput', diff --git a/manifests/input/gelf_tcp.pp b/manifests/input/gelf_tcp.pp index e3a63a6..4b40a7b 100644 --- a/manifests/input/gelf_tcp.pp +++ b/manifests/input/gelf_tcp.pp @@ -69,7 +69,7 @@ # @param use_null_delimiter # Whether to use a null byte as a frame delimiter. If false, a newline is # used as the delimiter instead. -define graylog_api::input::gelf_tcp( +define graylog_api::input::gelf_tcp ( Enum['present','absent'] $ensure = 'present', String $bind_address = '0.0.0.0', Integer $decompress_size_limit = '8 MB'.to_bytes, @@ -87,7 +87,7 @@ String $tls_key_file = '', String $tls_key_password = '', Boolean $use_null_delimiter = true, -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog2.inputs.gelf.tcp.GELFTCPInput', diff --git a/manifests/input/gelf_udp.pp b/manifests/input/gelf_udp.pp index e3261d4..9c17510 100644 --- a/manifests/input/gelf_udp.pp +++ b/manifests/input/gelf_udp.pp @@ -30,7 +30,7 @@ # # @param static_fields # Static fields to assign to this input. -define graylog_api::input::gelf_udp( +define graylog_api::input::gelf_udp ( Enum['present','absent'] $ensure = 'present', String $bind_address = '0.0.0.0', Integer $decompress_size_limit = '8 MB'.to_bytes, @@ -39,7 +39,7 @@ Integer $recv_buffer_size = '256 kB'.to_bytes, Enum['global','local'] $scope = 'global', Optional[Hash] $static_fields = undef, -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog2.inputs.gelf.udp.GELFUDPInput', diff --git a/manifests/input/syslog_tcp.pp b/manifests/input/syslog_tcp.pp index 006429d..338c7c0 100644 --- a/manifests/input/syslog_tcp.pp +++ b/manifests/input/syslog_tcp.pp @@ -6,23 +6,9 @@ # @param ensure # Whether this input should exist. # -# @param allow_override_date -# Whether to allow setting the message timestamp to the current server time, -# if the timstamp in the message failed to parse. Defaults to true. -# # @param bind_address # The IP address to listen on. Defaults to 0.0.0.0. # -# @param expand_structured_data -# Whether to expand structured data elements by prefixing attributes with -# their SD-ID. Defaults to true. -# -# @param force_rdns -# Whether to force reverse DNS resolution of sender's hostname. Use if the -# hostname in the message cannot be parsed. Default value is false. -# NOTE: Be careful with this setting if you are sending DNS server logs into -# this input as it can cause a feedback loop. -# # @param override_source # The source is a hostname derived from the received packet by default. Set # this if you want to override it with a custom string. @@ -43,10 +29,6 @@ # @param static_fields # Static fields to assign to this input. # -# @param store_full_message -# Whether to store the full original syslog message as full_message. Defaults -# to true. -# # @param tcp_keepalive # Whether to enable TCP keepalive packets. # @@ -79,10 +61,7 @@ # The password to decrypt to private key specified in tls_key_file. Leave # blank if not using TLS, or if the key is not encrypted. # -# @param use_null_delimiter -# Whether to use a null byte as a frame delimiter. If false, a newline is -# used as the delimiter instead. -define graylog_api::input::syslog_tcp( +define graylog_api::input::syslog_tcp ( Enum['present','absent'] $ensure = 'present', String $bind_address = '0.0.0.0', Optional[String] $override_source = undef, @@ -97,21 +76,17 @@ Boolean $tls_enable = false, String $tls_key_file = '', String $tls_key_password = '' -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog2.inputs.syslog.tcp.SyslogTCPInput', scope => $scope, static_fields => $static_fields, configuration => { - allow_override_date => $allow_override_date, - bind_address => $bind_address, - expand_structured_data => $expand_structured_data, - force_rdns => $force_rdns, - recv_buffer_size => $recv_buffer_size, - override_source => $override_source, - port => $port, - store_full_message => $store_full_message, + bind_address => $bind_address, + recv_buffer_size => $recv_buffer_size, + override_source => $override_source, + port => $port, tcp_keepalive => $tcp_keepalive, tls_cert_file => $tls_cert_file, tls_client_auth => $tls_client_auth, @@ -119,7 +94,6 @@ tls_enable => $tls_enable, tls_key_file => $tls_key_file, tls_key_password => $tls_key_password, - use_null_delimiter => $use_null_delimiter, }, } -} \ No newline at end of file +} diff --git a/manifests/input/syslog_udp.pp b/manifests/input/syslog_udp.pp index a4d85c7..b1d9732 100644 --- a/manifests/input/syslog_udp.pp +++ b/manifests/input/syslog_udp.pp @@ -46,7 +46,7 @@ # @param store_full_message # Whether to store the full original syslog message as full_message. Defaults # to true. -define graylog_api::input::syslog_udp( +define graylog_api::input::syslog_udp ( Enum['present','absent'] $ensure = 'present', Boolean $allow_override_date = true, String $bind_address = '0.0.0.0', @@ -58,7 +58,7 @@ Enum['global','local'] $scope = 'global', Optional[Hash] $static_fields = undef, Boolean $store_full_message = true, -){ +) { graylog_input { $name: ensure => $ensure, type => 'org.graylog2.inputs.syslog.udp.SyslogUDPInput', diff --git a/manifests/pipeline.pp b/manifests/pipeline.pp index c8c7685..527284b 100644 --- a/manifests/pipeline.pp +++ b/manifests/pipeline.pp @@ -69,9 +69,9 @@ # case-sensitive. Also note that, if the Pipeline Processor is running before # the Message Filter Chain, then the only stream that will have messages at # processing time will be the 'All messages' stream. -define graylog_api::pipeline( - String $description = '', +define graylog_api::pipeline ( Array[Graylog_api::Pipeline::Stage::Loose] $stages, + String $description = '', Variant[String,Array[String]] $streams = [], ) { $stage_bodies = $stages.map |$index,$stage| { diff --git a/manifests/pipeline/rule.pp b/manifests/pipeline/rule.pp index 402087c..b185fc5 100644 --- a/manifests/pipeline/rule.pp +++ b/manifests/pipeline/rule.pp @@ -21,7 +21,7 @@ # @param action # The action to take if the rule matches. Defaults to the empty string (e.g. # no action is taken when the rule matches). -define graylog_api::pipeline::rule( +define graylog_api::pipeline::rule ( String $description = '', String $condition = 'true', # lint:ignore:quoted_booleans String $action = '', diff --git a/spec/default_facts.yml b/spec/default_facts.yml deleted file mode 100644 index ea1e480..0000000 --- a/spec/default_facts.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Use default_module_facts.yml for module specific facts. -# -# Facts specified here will override the values provided by rspec-puppet-facts. ---- -ipaddress: "172.16.254.254" -is_pe: false -macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 70d81e0..9efb4ae 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,51 +1,20 @@ -RSpec.configure do |c| - c.mock_with :rspec -end - -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec-puppet-facts' - -require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) +# frozen_string_literal: true -include RspecPuppetFacts +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -default_facts = { - puppetversion: Puppet.version, - facterversion: Facter.version, -} +# 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', __dir__)) -default_fact_files = [ - File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), - File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), -] +require 'voxpupuli/test/spec_helper' -default_fact_files.each do |f| - next unless File.exist?(f) && File.readable?(f) && File.size?(f) +add_mocked_facts! - begin - default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => e - RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" +if File.exist?(File.join(__dir__, 'default_module_facts.yml')) + facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) + facts&.each do |name, value| + add_custom_fact name.to_sym, value end end - -RSpec.configure do |c| - c.default_facts = default_facts - c.before :each do - # set to strictest setting for testing - # by default Puppet runs at warning level - Puppet.settings[:strict] = :warning - end - c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] - c.after(:suite) do - end -end - -def ensure_module_defined(module_name) - module_name.split('::').reduce(Object) do |last_module, next_module| - last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) - last_module.const_get(next_module, false) - end -end - -# 'spec_overrides' from sync.yml will appear below this line +Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } diff --git a/types/pipeline/stage.pp b/types/pipeline/stage.pp index 499f57a..cb66d1d 100644 --- a/types/pipeline/stage.pp +++ b/types/pipeline/stage.pp @@ -1,3 +1,5 @@ +# @summary Custom Type for Graylog_api pipeline stage +# type Graylog_api::Pipeline::Stage = Struct[{ match => Enum['all','either'], rules => Array[String,1], diff --git a/types/pipeline/stage/loose.pp b/types/pipeline/stage/loose.pp index 3d6d6ae..3c263a4 100644 --- a/types/pipeline/stage/loose.pp +++ b/types/pipeline/stage/loose.pp @@ -1,3 +1,5 @@ +# @summary custom type for graylog_api pipeline stage loose +# type Graylog_api::Pipeline::Stage::Loose = Variant[ Graylog_api::Pipeline::Stage, Array[String,1],