├── .editorconfig ├── .fixtures.yml ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── labeler.yml ├── release.yml └── workflows │ ├── ci.yml │ ├── labeler.yml │ ├── prepare_release.yml │ └── release.yml ├── .gitignore ├── .msync.yml ├── .overcommit.yml ├── .pmtignore ├── .puppet-lint.rc ├── .rubocop.yml ├── .sync.yml ├── CHANGELOG.md ├── Gemfile ├── HISTORY.md ├── LICENSE ├── README.md ├── Rakefile ├── data └── common.yaml ├── hiera.yaml ├── lib └── puppet │ ├── functions │ └── kibana │ │ └── hash2yaml.rb │ ├── provider │ ├── elastic_kibana.rb │ └── kibana_plugin │ │ ├── kibana.rb │ │ └── kibana_plugin.rb │ └── type │ └── kibana_plugin.rb ├── manifests ├── config.pp ├── init.pp ├── install.pp └── service.pp ├── metadata.json ├── spec ├── acceptance │ ├── nodesets │ │ ├── amazonlinux-x64.yml │ │ ├── fedora-28-x64.yml │ │ ├── ubuntu-1204-x64.yml │ │ └── ubuntu-1404-x64.yml │ └── tests │ │ ├── class_v5_spec.rb │ │ └── snapshot.rb ├── classes │ └── kibana_spec.rb ├── fixtures │ ├── artifacts │ │ └── .gitkeep │ ├── hiera.yaml │ └── hieradata │ │ └── default.yaml ├── functions │ └── kibana_hash2yaml.rb ├── helpers │ ├── acceptance │ │ └── tests │ │ │ ├── basic_shared_examples.rb │ │ │ └── class_shared_examples.rb │ └── unit │ │ └── provider │ │ └── kibana_plugin_shared_examples.rb ├── setup_acceptance_node.pp ├── spec_helper.rb ├── spec_helper_acceptance.rb ├── spec_utilities.rb ├── support │ └── acceptance │ │ └── kibana.rb └── unit │ ├── provider │ └── kibana_plugin │ │ ├── kibana_plugin_spec.rb │ │ └── kibana_spec.rb │ └── type │ └── kibana_plugin_spec.rb └── types └── status.pp /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | # Managed by modulesync - DO NOT EDIT 4 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 5 | 6 | root = true 7 | 8 | [*] 9 | charset = utf-8 10 | end_of_line = lf 11 | indent_size = 2 12 | tab_width = 2 13 | indent_style = space 14 | insert_final_newline = true 15 | trim_trailing_whitespace = true 16 | -------------------------------------------------------------------------------- /.fixtures.yml: -------------------------------------------------------------------------------- 1 | fixtures: 2 | repositories: 3 | apt: https://github.com/puppetlabs/puppetlabs-apt.git 4 | elastic_stack: https://github.com/voxpupuli/puppet-elastic-stack.git 5 | stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git 6 | yumrepo_core: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git 7 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution guidelines 2 | 3 | ## Table of contents 4 | 5 | * [Contributing](#contributing) 6 | * [Writing proper commits - short version](#writing-proper-commits-short-version) 7 | * [Writing proper commits - long version](#writing-proper-commits-long-version) 8 | * [Dependencies](#dependencies) 9 | * [Note for OS X users](#note-for-os-x-users) 10 | * [The test matrix](#the-test-matrix) 11 | * [Syntax and style](#syntax-and-style) 12 | * [Running the unit tests](#running-the-unit-tests) 13 | * [Unit tests in docker](#unit-tests-in-docker) 14 | * [Integration tests](#integration-tests) 15 | 16 | This module has grown over time based on a range of contributions from 17 | people using it. If you follow these contributing guidelines your patch 18 | will likely make it into a release a little more quickly. 19 | 20 | ## Contributing 21 | 22 | Please note that this project is released with a Contributor Code of Conduct. 23 | By participating in this project you agree to abide by its terms. 24 | [Contributor Code of Conduct](https://voxpupuli.org/coc/). 25 | 26 | * Fork the repo. 27 | * Create a separate branch for your change. 28 | * 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). 29 | * 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. 30 | * 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. 31 | * Squash your commits down into logical components. Make sure to rebase against our current master. 32 | * Push the branch to your fork and submit a pull request. 33 | 34 | Please be prepared to repeat some of these steps as our contributors review your code. 35 | 36 | 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! 37 | 38 | ## Writing proper commits - short version 39 | 40 | * Make commits of logical units. 41 | * Check for unnecessary whitespace with "git diff --check" before committing. 42 | * Commit using Unix line endings (check the settings around "crlf" in git-config(1)). 43 | * Do not check in commented out code or unneeded files. 44 | * 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. 45 | * Associate the issue in the message. The first line should include the issue number in the form "(#XXXX) Rest of message". 46 | * The body should provide a meaningful commit message, which: 47 | *uses the imperative, present tense: `change`, not `changed` or `changes`. 48 | * includes motivation for the change, and contrasts its implementation with the previous behavior. 49 | * Make sure that you have tests for the bug you are fixing, or feature you are adding. 50 | * Make sure the test suites passes after your commit: 51 | * When introducing a new feature, make sure it is properly documented in the README.md 52 | 53 | ## Writing proper commits - long version 54 | 55 | 1. Make separate commits for logically separate changes. 56 | 57 | Please break your commits down into logically consistent units 58 | which include new or changed tests relevant to the rest of the 59 | change. The goal of doing this is to make the diff easier to 60 | read for whoever is reviewing your code. In general, the easier 61 | your diff is to read, the more likely someone will be happy to 62 | review it and get it into the code base. 63 | 64 | If you are going to refactor a piece of code, please do so as a 65 | separate commit from your feature or bug fix changes. 66 | 67 | We also really appreciate changes that include tests to make 68 | sure the bug is not re-introduced, and that the feature is not 69 | accidentally broken. 70 | 71 | Describe the technical detail of the change(s). If your 72 | description starts to get too long, that is a good sign that you 73 | probably need to split up your commit into more finely grained 74 | pieces. 75 | 76 | Commits which plainly describe the things which help 77 | reviewers check the patch and future developers understand the 78 | code are much more likely to be merged in with a minimum of 79 | bike-shedding or requested changes. Ideally, the commit message 80 | would include information, and be in a form suitable for 81 | inclusion in the release notes for the version of Puppet that 82 | includes them. 83 | 84 | Please also check that you are not introducing any trailing 85 | whitespace or other "whitespace errors". You can do this by 86 | running "git diff --check" on your changes before you commit. 87 | 88 | 2. Sending your patches 89 | 90 | To submit your changes via a GitHub pull request, we _highly_ 91 | recommend that you have them on a topic branch, instead of 92 | directly on `master`. 93 | It makes things much easier to keep track of, especially if 94 | you decide to work on another thing before your first change 95 | is merged in. 96 | 97 | GitHub has some pretty good 98 | [general documentation](http://help.github.com/) on using 99 | their site. They also have documentation on 100 | [creating pull requests](http://help.github.com/send-pull-requests/). 101 | 102 | In general, after pushing your topic branch up to your 103 | repository on GitHub, you can switch to the branch in the 104 | GitHub UI and click "Pull Request" towards the top of the page 105 | in order to open a pull request. 106 | 107 | 108 | 3. Update the related GitHub issue. 109 | 110 | If there is a GitHub issue associated with the change you 111 | submitted, then you should update the ticket to include the 112 | location of your branch, along with any other commentary you 113 | may wish to make. 114 | 115 | ## Dependencies 116 | 117 | The testing and development tools have a bunch of dependencies, 118 | all managed by [bundler](http://bundler.io/) according to the 119 | [Puppet support matrix](http://docs.puppetlabs.com/guides/platforms.html#ruby-versions). 120 | 121 | By default the tests use a baseline version of Puppet. 122 | 123 | If you have Ruby 2.x or want a specific version of Puppet, 124 | you must set an environment variable such as: 125 | 126 | ```sh 127 | export PUPPET_GEM_VERSION="~> 6.1.0" 128 | ``` 129 | 130 | You can install all needed gems for spec tests into the modules directory by 131 | running: 132 | 133 | ```sh 134 | bundle config set --local path '.vendor/' 135 | bundle config set --local without 'development system_tests release' 136 | bundle install --jobs "$(nproc)" 137 | ``` 138 | 139 | If you also want to run acceptance tests: 140 | 141 | ```sh 142 | bundle config set --local path '.vendor/' 143 | bundle config set --local without 'development release' 144 | bundle config set --local with 'system_tests' 145 | bundle install --jobs "$(nproc)" 146 | ``` 147 | 148 | Our all in one solution if you don't know if you need to install or update gems: 149 | 150 | ```sh 151 | bundle config set --local path '.vendor/' 152 | bundle config set --local without 'development release' 153 | bundle config set --local with 'system_tests' 154 | bundle install --jobs "$(nproc)" 155 | bundle update 156 | bundle clean 157 | ``` 158 | 159 | As an alternative to the `--jobs "$(nproc)` parameter, you can set an 160 | environment variable: 161 | 162 | ```sh 163 | BUNDLE_JOBS="$(nproc)" 164 | ``` 165 | 166 | ### Note for OS X users 167 | 168 | `nproc` isn't a valid command under OS x. As an alternative, you can do: 169 | 170 | ```sh 171 | --jobs "$(sysctl -n hw.ncpu)" 172 | ``` 173 | 174 | ## The test matrix 175 | 176 | ### Syntax and style 177 | 178 | The test suite will run [Puppet Lint](http://puppet-lint.com/) and 179 | [Puppet Syntax](https://github.com/gds-operations/puppet-syntax) to 180 | check various syntax and style things. You can run these locally with: 181 | 182 | ```sh 183 | bundle exec rake lint 184 | bundle exec rake validate 185 | ``` 186 | 187 | It will also run some [Rubocop](http://batsov.com/rubocop/) tests 188 | against it. You can run those locally ahead of time with: 189 | 190 | ```sh 191 | bundle exec rake rubocop 192 | ``` 193 | 194 | ### Running the unit tests 195 | 196 | The unit test suite covers most of the code, as mentioned above please 197 | add tests if you're adding new functionality. If you've not used 198 | [rspec-puppet](http://rspec-puppet.com/) before then feel free to ask 199 | about how best to test your new feature. 200 | 201 | To run the linter, the syntax checker and the unit tests: 202 | 203 | ```sh 204 | bundle exec rake test 205 | ``` 206 | 207 | To run your all the unit tests 208 | 209 | ```sh 210 | bundle exec rake spec 211 | ``` 212 | 213 | To run a specific spec test set the `SPEC` variable: 214 | 215 | ```sh 216 | bundle exec rake spec SPEC=spec/foo_spec.rb 217 | ``` 218 | 219 | #### Unit tests in docker 220 | 221 | Some people don't want to run the dependencies locally or don't want to install 222 | ruby. We ship a Dockerfile that enables you to run all unit tests and linting. 223 | You only need to run: 224 | 225 | ```sh 226 | docker build . 227 | ``` 228 | 229 | Please ensure that a docker daemon is running and that your user has the 230 | permission to talk to it. You can specify a remote docker host by setting the 231 | `DOCKER_HOST` environment variable. it will copy the content of the module into 232 | the docker image. So it will not work if a Gemfile.lock exists. 233 | 234 | ### Integration tests 235 | 236 | The unit tests just check the code runs, not that it does exactly what 237 | we want on a real machine. For that we're using 238 | [beaker](https://github.com/puppetlabs/beaker). 239 | 240 | This fires up a new virtual machine (using vagrant) and runs a series of 241 | simple tests against it after applying the module. You can run this 242 | with: 243 | 244 | ```sh 245 | BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker 246 | ``` 247 | 248 | or 249 | 250 | ```sh 251 | BEAKER_PUPPET_COLLECTION=none BEAKER_setfile=archlinux-64 bundle exec rake beaker 252 | ``` 253 | 254 | This latter example will use the distribution's own version of Puppet. 255 | 256 | You can replace the string `debian11` with any common operating system. 257 | The following strings are known to work: 258 | 259 | * ubuntu2004 260 | * ubuntu2204 261 | * debian11 262 | * debian12 263 | * centos9 264 | * archlinux 265 | * almalinux8 266 | * almalinux9 267 | * fedora36 268 | 269 | For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests). 270 | 271 | The source of this file is in our [modulesync_config](https://github.com/voxpupuli/modulesync_config/blob/master/moduleroot/.github/CONTRIBUTING.md.erb) 272 | repository. 273 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | ## Affected Puppet, Ruby, OS and module versions/distributions 12 | 13 | - Puppet: 14 | - Ruby: 15 | - Distribution: 16 | - Module version: 17 | 18 | ## How to reproduce (e.g Puppet code you use) 19 | 20 | ## What are you seeing 21 | 22 | ## What behaviour did you expect instead 23 | 24 | ## Output log 25 | 26 | ## Any additional information you'd like to impart 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 9 | #### Pull Request (PR) description 10 | 13 | 14 | #### This Pull Request (PR) fixes the following issues 15 | 21 | -------------------------------------------------------------------------------- /.github/labeler.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | skip-changelog: 6 | - head-branch: ['^release-*', 'release'] 7 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | # https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes 6 | 7 | changelog: 8 | exclude: 9 | labels: 10 | - duplicate 11 | - invalid 12 | - modulesync 13 | - question 14 | - skip-changelog 15 | - wont-fix 16 | - wontfix 17 | 18 | categories: 19 | - title: Breaking Changes 🛠 20 | labels: 21 | - backwards-incompatible 22 | 23 | - title: New Features 🎉 24 | labels: 25 | - enhancement 26 | 27 | - title: Bug Fixes 🐛 28 | labels: 29 | - bug 30 | 31 | - title: Documentation Updates 📚 32 | labels: 33 | - documentation 34 | - docs 35 | 36 | - title: Dependency Updates ⬆️ 37 | labels: 38 | - dependencies 39 | 40 | - title: Other Changes 41 | labels: 42 | - "*" 43 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | name: CI 6 | 7 | # yamllint disable-line rule:truthy 8 | on: 9 | pull_request: {} 10 | push: 11 | branches: 12 | - main 13 | - master 14 | 15 | concurrency: 16 | group: ${{ github.ref_name }} 17 | cancel-in-progress: true 18 | 19 | jobs: 20 | puppet: 21 | name: Puppet 22 | uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v3 23 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | name: "Pull Request Labeler" 6 | 7 | # yamllint disable-line rule:truthy 8 | on: 9 | pull_request_target: {} 10 | 11 | jobs: 12 | labeler: 13 | permissions: 14 | contents: read 15 | pull-requests: write 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/labeler@v5 19 | -------------------------------------------------------------------------------- /.github/workflows/prepare_release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | name: 'Prepare Release' 6 | 7 | on: 8 | workflow_dispatch: 9 | inputs: 10 | version: 11 | description: 'Module version to be released. Must be a valid semver string without leading v. (1.2.3)' 12 | required: false 13 | 14 | jobs: 15 | release_prep: 16 | uses: 'voxpupuli/gha-puppet/.github/workflows/prepare_release.yml@v3' 17 | with: 18 | version: ${{ github.event.inputs.version }} 19 | allowed_owner: 'voxpupuli' 20 | secrets: 21 | # Configure secrets here: 22 | # https://docs.github.com/en/actions/security-guides/encrypted-secrets 23 | github_pat: '${{ secrets.PCCI_PAT_RELEASE_PREP }}' 24 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | name: Release 6 | 7 | # yamllint disable-line rule:truthy 8 | on: 9 | push: 10 | tags: 11 | - '*' 12 | 13 | jobs: 14 | release: 15 | name: Release 16 | uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v3 17 | with: 18 | allowed_owner: 'voxpupuli' 19 | secrets: 20 | # Configure secrets here: 21 | # https://docs.github.com/en/actions/security-guides/encrypted-secrets 22 | username: ${{ secrets.PUPPET_FORGE_USERNAME }} 23 | api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | /pkg/ 5 | /Gemfile.lock 6 | /Gemfile.local 7 | /vendor/ 8 | /.vendor/ 9 | /spec/fixtures/manifests/ 10 | /spec/fixtures/modules/ 11 | /.vagrant/ 12 | /.bundle/ 13 | /.ruby-version 14 | /coverage/ 15 | /log/ 16 | /.idea/ 17 | /.dependencies/ 18 | /.librarian/ 19 | /Puppetfile.lock 20 | *.iml 21 | .*.sw? 22 | /.yardoc/ 23 | /Guardfile 24 | bolt-debug.log 25 | .rerun.json 26 | -------------------------------------------------------------------------------- /.msync.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | modulesync_config_version: '9.7.0' 6 | -------------------------------------------------------------------------------- /.overcommit.yml: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | # 4 | # Hooks are only enabled if you take action. 5 | # 6 | # To enable the hooks run: 7 | # 8 | # ``` 9 | # bundle exec overcommit --install 10 | # # ensure .overcommit.yml does not harm to you and then 11 | # bundle exec overcommit --sign 12 | # ``` 13 | # 14 | # (it will manage the .git/hooks directory): 15 | # 16 | # Examples howto skip a test for a commit or push: 17 | # 18 | # ``` 19 | # SKIP=RuboCop git commit 20 | # SKIP=PuppetLint git commit 21 | # SKIP=RakeTask git push 22 | # ``` 23 | # 24 | # Don't invoke overcommit at all: 25 | # 26 | # ``` 27 | # OVERCOMMIT_DISABLE=1 git commit 28 | # ``` 29 | # 30 | # Read more about overcommit: https://github.com/brigade/overcommit 31 | # 32 | # To manage this config yourself in your module add 33 | # 34 | # ``` 35 | # .overcommit.yml: 36 | # unmanaged: true 37 | # ``` 38 | # 39 | # to your modules .sync.yml config 40 | --- 41 | PreCommit: 42 | RuboCop: 43 | enabled: true 44 | description: 'Runs rubocop on modified files only' 45 | command: ['bundle', 'exec', 'rubocop'] 46 | RakeTarget: 47 | enabled: true 48 | description: 'Runs lint on modified files only' 49 | targets: 50 | - 'lint' 51 | command: ['bundle', 'exec', 'rake'] 52 | YamlSyntax: 53 | enabled: true 54 | JsonSyntax: 55 | enabled: true 56 | TrailingWhitespace: 57 | enabled: true 58 | 59 | PrePush: 60 | RakeTarget: 61 | enabled: true 62 | description: 'Run rake targets' 63 | targets: 64 | - 'validate' 65 | - 'test' 66 | - 'rubocop' 67 | command: ['bundle', 'exec', 'rake'] 68 | -------------------------------------------------------------------------------- /.pmtignore: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | /docs/ 5 | /pkg/ 6 | /Gemfile 7 | /Gemfile.lock 8 | /Gemfile.local 9 | /vendor/ 10 | /.vendor/ 11 | /spec/ 12 | /Rakefile 13 | /.vagrant/ 14 | /.bundle/ 15 | /.ruby-version 16 | /coverage/ 17 | /log/ 18 | /.idea/ 19 | /.dependencies/ 20 | /.github/ 21 | /.librarian/ 22 | /Puppetfile.lock 23 | /Puppetfile 24 | *.iml 25 | /.editorconfig 26 | /.fixtures.yml 27 | /.gitignore 28 | /.msync.yml 29 | /.overcommit.yml 30 | /.pmtignore 31 | /.rspec 32 | /.rspec_parallel 33 | /.rubocop.yml 34 | /.sync.yml 35 | .*.sw? 36 | /.yardoc/ 37 | /.yardopts 38 | /Dockerfile 39 | /HISTORY.md 40 | -------------------------------------------------------------------------------- /.puppet-lint.rc: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | --fail-on-warnings 5 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Managed by modulesync - DO NOT EDIT 3 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 4 | 5 | inherit_gem: 6 | voxpupuli-test: rubocop.yml 7 | -------------------------------------------------------------------------------- /.sync.yml: -------------------------------------------------------------------------------- 1 | --- 2 | .puppet-lint.rc: 3 | enabled_lint_checks: 4 | - parameter_documentation 5 | - parameter_types 6 | Gemfile: 7 | optional: 8 | ':system_tests': 9 | - gem: rspec-retry 10 | spec/spec_helper_acceptance.rb: 11 | unmanaged: false 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | Each new release typically also includes the latest modulesync defaults. 5 | These should not affect the functionality of the module. 6 | 7 | ## [v8.0.0](https://github.com/voxpupuli/puppet-kibana/tree/v8.0.0) (2023-08-04) 8 | 9 | [Full Changelog](https://github.com/voxpupuli/puppet-kibana/compare/v7.0.1...v8.0.0) 10 | 11 | **Breaking changes:** 12 | 13 | - Drop Puppet 6 support [\#74](https://github.com/voxpupuli/puppet-kibana/pull/74) ([bastelfreak](https://github.com/bastelfreak)) 14 | 15 | **Implemented enhancements:** 16 | 17 | - Add Puppet 8 support [\#76](https://github.com/voxpupuli/puppet-kibana/pull/76) ([bastelfreak](https://github.com/bastelfreak)) 18 | - Remove template erb and puppet\_x folder [\#72](https://github.com/voxpupuli/puppet-kibana/pull/72) ([phaedriel](https://github.com/phaedriel)) 19 | - Add optional parameter plugindir \(Directory containing kibana plugins\) [\#71](https://github.com/voxpupuli/puppet-kibana/pull/71) ([phaedriel](https://github.com/phaedriel)) 20 | - Add sensitive for kibana config [\#68](https://github.com/voxpupuli/puppet-kibana/pull/68) ([phaedriel](https://github.com/phaedriel)) 21 | - Add service\_name and package\_name parameters [\#66](https://github.com/voxpupuli/puppet-kibana/pull/66) ([phaedriel](https://github.com/phaedriel)) 22 | - Allow to change `kibana.yml` ownership [\#64](https://github.com/voxpupuli/puppet-kibana/pull/64) ([phaedriel](https://github.com/phaedriel)) 23 | 24 | **Closed issues:** 25 | 26 | - Support alternative package & service name for Kibana [\#16](https://github.com/voxpupuli/puppet-kibana/issues/16) 27 | 28 | ## [v7.0.1](https://github.com/voxpupuli/puppet-kibana/tree/v7.0.1) (2022-06-13) 29 | 30 | [Full Changelog](https://github.com/voxpupuli/puppet-kibana/compare/v7.0.0...v7.0.1) 31 | 32 | **Fixed bugs:** 33 | 34 | - Allow empty string values in kibana::config [\#44](https://github.com/voxpupuli/puppet-kibana/pull/44) ([smokris](https://github.com/smokris)) 35 | - Crossport hash.rb from elastic/puppet-elasticsearch [\#41](https://github.com/voxpupuli/puppet-kibana/pull/41) ([baurmatt](https://github.com/baurmatt)) 36 | 37 | **Closed issues:** 38 | 39 | - Module dependency for elastic-elastick\_stack [\#57](https://github.com/voxpupuli/puppet-kibana/issues/57) 40 | 41 | **Merged pull requests:** 42 | 43 | - Remove .ruby-version and .tool-versions [\#60](https://github.com/voxpupuli/puppet-kibana/pull/60) ([root-expert](https://github.com/root-expert)) 44 | - Update module name [\#59](https://github.com/voxpupuli/puppet-kibana/pull/59) ([luoymu](https://github.com/luoymu)) 45 | - elastic/elastic\_stack deprecation [\#58](https://github.com/voxpupuli/puppet-kibana/pull/58) ([anesterova](https://github.com/anesterova)) 46 | 47 | ## [v7.0.0](https://github.com/voxpupuli/puppet-kibana/tree/v7.0.0) (2022-03-25) 48 | 49 | [Full Changelog](https://github.com/voxpupuli/puppet-kibana/compare/6.3.1...v7.0.0) 50 | 51 | **Breaking changes:** 52 | 53 | - Drop versions of Puppet which have reached EOL; require puppet 6 or 7 [\#51](https://github.com/voxpupuli/puppet-kibana/pull/51) ([smortex](https://github.com/smortex)) 54 | - Drop support for OS which have reached EOL [\#49](https://github.com/voxpupuli/puppet-kibana/pull/49) ([smortex](https://github.com/smortex)) 55 | 56 | **Implemented enhancements:** 57 | 58 | - Support for multiple Kibana instances [\#10](https://github.com/voxpupuli/puppet-kibana/issues/10) 59 | - Add support for recent operating systems [\#53](https://github.com/voxpupuli/puppet-kibana/pull/53) ([smortex](https://github.com/smortex)) 60 | - Add support Puppet 6 and 7 [\#50](https://github.com/voxpupuli/puppet-kibana/pull/50) ([smortex](https://github.com/smortex)) 61 | 62 | **Closed issues:** 63 | 64 | - Plugin install should either update existing plugin or break with error [\#33](https://github.com/voxpupuli/puppet-kibana/issues/33) 65 | 66 | **Merged pull requests:** 67 | 68 | - Stop using Travis CI [\#48](https://github.com/voxpupuli/puppet-kibana/pull/48) ([jmlrt](https://github.com/jmlrt)) 69 | - Update hiera yaml to version 5 [\#36](https://github.com/voxpupuli/puppet-kibana/pull/36) ([mmoll](https://github.com/mmoll)) 70 | 71 | ## [6.3.1](https://github.com/voxpupuli/puppet-kibana/tree/6.3.1) (2018-10-19) 72 | 73 | #### Fixes 74 | * This module no longer requires or enforces a version of the puppetlabs/apt module, which is transitively handled through the `elastic/elastic_stack` dependency. 75 | * Permit hashes to be passed as configuration parameter values. 76 | 77 | ## 6.3.0 (June 18, 2018) 78 | 79 | This release deprecates Kibana 4.x, which is end-of-life. 80 | 81 | ### Migration Guide 82 | 83 | * Support for 4.x has been deprecated, so consider upgrading to Kibana 5 or later before upgrading this module since only versions 5 and later are supported. 84 | * The module defaults to the upstream package repositories, which now include X-Pack bundled by default. To preserve previous behavior which does _not_ include X-Pack, follow the `README` instructions to configure `oss`-only repositories/packages. 85 | * Use of the `elastic_stack::repo` class for managing package repositories may mean that leftover yum/apt/etc. repositories named `kibana` may persist after upgrade. 86 | 87 | #### Features 88 | * Support for 6.3 style repositories using elastic_stack module 89 | 90 | #### Fixes 91 | 92 | ## 6.0.1 (March 13, 2018) 93 | 94 | #### Fixes 95 | * Fixed language compatibility errors that could arise when using JRuby 1.7 on Puppet Servers. 96 | 97 | ## 6.0.0 (November 14, 2017) 98 | 99 | Major version upgrade with important deprecations: 100 | 101 | * Puppet version 3 is no longer supported. 102 | 103 | The following migration guide is intended to help aid in upgrading this module. 104 | 105 | ### Migration Guide 106 | 107 | #### Puppet 3.x No Longer Supported 108 | 109 | Puppet 4.5.0 is the new minimum required version of Puppet, which offers better safety, module metadata, and Ruby features. 110 | Migrating from Puppet 3 to Puppet 4 is beyond the scope of this guide, but the [official upgrade documentation](https://docs.puppet.com/upgrade/upgrade_steps.html) can help. 111 | As with any version or module upgrade, remember to restart any agents and master servers as needed. 112 | 113 | ## 5.2.0 (November 13, 2017) 114 | 115 | #### Features 116 | * Added support for service status 117 | 118 | ## 5.1.0 (August 18, 2017) 119 | 120 | #### Features 121 | * Installation via package files (`.deb`/`.rpm`) now supported. See documentation for the `package_source` parameter for usage. 122 | * Updated puppetlabs/apt dependency to reflect support for 4.x versions. 123 | 124 | ## 5.0.1 (July 19, 2017) 125 | 126 | This is a bugfix release to properly contain classes within the `kibana` class so that relationship ordering is respected correctly. 127 | 128 | ## 5.0.0 (May 10, 2017) 129 | 130 | ### Summary 131 | Formally release major version 5.0 of the module. 132 | 133 | #### Fixes 134 | * metadata.json dependencies now compatible with Puppet 3.x. 135 | 136 | ## 0.3.0 (April 26, 2017) 137 | 138 | ### Summary 139 | This release backports support for Puppet 3.8. 140 | 141 | ## 0.2.1 (April 10, 2017) 142 | 143 | ### Summary 144 | Bugfix release resolving several minor issues. 145 | 146 | #### Features 147 | * Package revisions now supported for ensure values. 148 | 149 | #### Fixes 150 | * The `url` parameter for 4.x plugins is now properly passed to the plugin install command. 151 | * Nonzero plugin commmands now properly raise errors during catalog runs. 152 | * Boolean values allowed in config hash. 153 | * apt-transport-https package no longer managed by this module. 154 | 155 | ## 0.2.0 (March 20, 2017) 156 | 157 | ### Summary 158 | Minor fixes and full 4.x support. 159 | 160 | #### Features 161 | * Feature parity when managing plugins on Kibana 4.x. 162 | 163 | #### Fixes 164 | * Removed potential conflict with previously-defined apt-transport-https packages. 165 | * Permit boolean values in configuration hashes. 166 | 167 | ## 0.1.1 (March 11, 2017) 168 | 169 | ### Summary 170 | Small bugfix release. 171 | 172 | #### Fixes 173 | * Actually aknowledge and use the manage_repo class flag. 174 | 175 | ## 0.1.0 (March 8, 2017) 176 | 177 | ### Summary 178 | Initial release. 179 | 180 | #### Features 181 | * Support for installing, removing, and updating Kibana and the Kibana service. 182 | * Plugin support. 183 | * Initial support for version 4.x management. 184 | 185 | #### Fixes 186 | 187 | 188 | \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* 189 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | source ENV['GEM_SOURCE'] || 'https://rubygems.org' 5 | 6 | group :test do 7 | gem 'voxpupuli-test', '~> 10.0', :require => false 8 | gem 'puppet_metadata', '~> 5.0', :require => false 9 | end 10 | 11 | group :development do 12 | gem 'guard-rake', :require => false 13 | gem 'overcommit', '>= 0.39.1', :require => false 14 | end 15 | 16 | group :system_tests do 17 | gem 'voxpupuli-acceptance', '~> 3.5', :require => false 18 | gem 'rspec-retry', :require => false 19 | end 20 | 21 | group :release do 22 | gem 'voxpupuli-release', '~> 3.0', :require => false 23 | end 24 | 25 | gem 'rake', :require => false 26 | gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] 27 | 28 | puppetversion = ENV['PUPPET_GEM_VERSION'] || [">= 7.24", "< 9"] 29 | gem 'puppet', puppetversion, :require => false, :groups => [:test] 30 | 31 | # vim: syntax=ruby 32 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | ## [6.3.1](https://github.com/voxpupuli/puppet-kibana/tree/6.3.1) (2018-10-19) 2 | 3 | #### Fixes 4 | * This module no longer requires or enforces a version of the puppetlabs/apt module, which is transitively handled through the `elastic/elastic_stack` dependency. 5 | * Permit hashes to be passed as configuration parameter values. 6 | 7 | ## 6.3.0 (June 18, 2018) 8 | 9 | This release deprecates Kibana 4.x, which is end-of-life. 10 | 11 | ### Migration Guide 12 | 13 | * Support for 4.x has been deprecated, so consider upgrading to Kibana 5 or later before upgrading this module since only versions 5 and later are supported. 14 | * The module defaults to the upstream package repositories, which now include X-Pack bundled by default. To preserve previous behavior which does _not_ include X-Pack, follow the `README` instructions to configure `oss`-only repositories/packages. 15 | * Use of the `elastic_stack::repo` class for managing package repositories may mean that leftover yum/apt/etc. repositories named `kibana` may persist after upgrade. 16 | 17 | #### Features 18 | * Support for 6.3 style repositories using elastic_stack module 19 | 20 | #### Fixes 21 | 22 | ## 6.0.1 (March 13, 2018) 23 | 24 | #### Fixes 25 | * Fixed language compatibility errors that could arise when using JRuby 1.7 on Puppet Servers. 26 | 27 | ## 6.0.0 (November 14, 2017) 28 | 29 | Major version upgrade with important deprecations: 30 | 31 | * Puppet version 3 is no longer supported. 32 | 33 | The following migration guide is intended to help aid in upgrading this module. 34 | 35 | ### Migration Guide 36 | 37 | #### Puppet 3.x No Longer Supported 38 | 39 | Puppet 4.5.0 is the new minimum required version of Puppet, which offers better safety, module metadata, and Ruby features. 40 | Migrating from Puppet 3 to Puppet 4 is beyond the scope of this guide, but the [official upgrade documentation](https://docs.puppet.com/upgrade/upgrade_steps.html) can help. 41 | As with any version or module upgrade, remember to restart any agents and master servers as needed. 42 | 43 | ## 5.2.0 (November 13, 2017) 44 | 45 | #### Features 46 | * Added support for service status 47 | 48 | ## 5.1.0 (August 18, 2017) 49 | 50 | #### Features 51 | * Installation via package files (`.deb`/`.rpm`) now supported. See documentation for the `package_source` parameter for usage. 52 | * Updated puppetlabs/apt dependency to reflect support for 4.x versions. 53 | 54 | ## 5.0.1 (July 19, 2017) 55 | 56 | This is a bugfix release to properly contain classes within the `kibana` class so that relationship ordering is respected correctly. 57 | 58 | ## 5.0.0 (May 10, 2017) 59 | 60 | ### Summary 61 | Formally release major version 5.0 of the module. 62 | 63 | #### Fixes 64 | * metadata.json dependencies now compatible with Puppet 3.x. 65 | 66 | ## 0.3.0 (April 26, 2017) 67 | 68 | ### Summary 69 | This release backports support for Puppet 3.8. 70 | 71 | ## 0.2.1 (April 10, 2017) 72 | 73 | ### Summary 74 | Bugfix release resolving several minor issues. 75 | 76 | #### Features 77 | * Package revisions now supported for ensure values. 78 | 79 | #### Fixes 80 | * The `url` parameter for 4.x plugins is now properly passed to the plugin install command. 81 | * Nonzero plugin commmands now properly raise errors during catalog runs. 82 | * Boolean values allowed in config hash. 83 | * apt-transport-https package no longer managed by this module. 84 | 85 | ## 0.2.0 (March 20, 2017) 86 | 87 | ### Summary 88 | Minor fixes and full 4.x support. 89 | 90 | #### Features 91 | * Feature parity when managing plugins on Kibana 4.x. 92 | 93 | #### Fixes 94 | * Removed potential conflict with previously-defined apt-transport-https packages. 95 | * Permit boolean values in configuration hashes. 96 | 97 | ## 0.1.1 (March 11, 2017) 98 | 99 | ### Summary 100 | Small bugfix release. 101 | 102 | #### Fixes 103 | * Actually aknowledge and use the manage_repo class flag. 104 | 105 | ## 0.1.0 (March 8, 2017) 106 | 107 | ### Summary 108 | Initial release. 109 | 110 | #### Features 111 | * Support for installing, removing, and updating Kibana and the Kibana service. 112 | * Plugin support. 113 | * Initial support for version 4.x management. 114 | 115 | #### Fixes 116 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use thes 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kibana Puppet Module 2 | 3 | [![Build Status](https://github.com/voxpupuli/puppet-kibana/workflows/CI/badge.svg)](https://github.com/voxpupuli/puppet-kibana/actions?query=workflow%3ACI) 4 | [![Release](https://github.com/voxpupuli/puppet-kibana/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/puppet-kibana/actions/workflows/release.yml) 5 | [![Puppet Forge](https://img.shields.io/puppetforge/v/puppet/kibana.svg)](https://forge.puppetlabs.com/puppet/kibana) 6 | [![Puppet Forge - downloads](https://img.shields.io/puppetforge/dt/puppet/kibana.svg)](https://forge.puppetlabs.com/puppet/kibana) 7 | [![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/puppet/kibana.svg)](https://forge.puppetlabs.com/puppet/kibana) 8 | [![Puppet Forge - scores](https://img.shields.io/puppetforge/f/puppet/kibana.svg)](https://forge.puppetlabs.com/puppet/kibana) 9 | [![puppetmodule.info docs](http://www.puppetmodule.info/images/badge.png)](http://www.puppetmodule.info/m/puppet-kibana) 10 | [![Apache-2.0 License](https://img.shields.io/github/license/voxpupuli/puppet-kibana.svg)](LICENSE) 11 | 12 | #### Table of Contents 13 | 14 | 1. [Overview](#overview) 15 | 2. [Module Description - What the module does and why it is useful](#module-description) 16 | 3. [Setup - The basics of getting started with Kibana](#setup) 17 | * [What Kibana affects](#what-kibana-affects) 18 | * [Setup requirements](#setup-requirements) 19 | * [Beginning with Kibana](#beginning-with-kibana) 20 | 4. [Usage - Configuration options and additional functionality](#usage) 21 | 5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) 22 | 5. [Limitations - OS compatibility, etc.](#limitations) 23 | 6. [Development - Guide for contributing to the module](#development) 24 | 25 | ## Overview 26 | 27 | This module manages Kibana for use with Elasticsearch. 28 | 29 | ## Module Description 30 | 31 | In addition to managing the Kibana system package and service, this module also 32 | exposes options to control the configuration file for Kibana. 33 | Kibana plugins are also supported via a native type and provider. 34 | 35 | Dependencies are fairly standard (such as stdlib). 36 | 37 | ## Setup 38 | 39 | ### What Kibana affects 40 | 41 | * The `kibana` system package and service 42 | * `/etc/kibana/kibana.yml` 43 | * `/usr/share/kibana/plugins/*` 44 | 45 | ### Setup Requirements 46 | 47 | In addition to basic puppet settings (such as pluginsync), ensure that the 48 | required dependencies for the module are met (these are listed in 49 | `metadata.json` and listed in the Puppet Forge). 50 | 51 | ### Beginning with kibana 52 | 53 | Quick start: 54 | 55 | ```puppet 56 | class { 'kibana' : } 57 | ``` 58 | 59 | ## Usage 60 | 61 | In order to control Kibana's configuration file, use the `config` parameter: 62 | 63 | ```puppet 64 | class { 'kibana': 65 | config => { 66 | 'server.port' => '8080', 67 | } 68 | } 69 | ``` 70 | 71 | The `kibana` class also supports additional values for the `ensure` parameter 72 | that will be passed along to the `package` resource for Kibana. 73 | For example, to ensure the latest version of Kibana is always installed: 74 | 75 | ```puppet 76 | class { 'kibana': ensure => latest } 77 | ``` 78 | 79 | In order to explicitly ensure that version 5.2.0 of Kibana is installed: 80 | 81 | ```puppet 82 | class { 'kibana': ensure => '5.2.0' } 83 | ``` 84 | 85 | Package revisions are supported too: 86 | 87 | ```puppet 88 | class { 'kibana': ensure => '5.2.2-1' } 89 | ``` 90 | 91 | The `kibana` class also supports removal through use of `ensure => absent`: 92 | 93 | ```puppet 94 | class { 'kibana': ensure => absent } 95 | ``` 96 | 97 | ### OSS Packages and Repository Management 98 | 99 | This module uses the [puppet/elastic_stack](https://forge.puppet.com/puppet/elastic_stack) module to manage the elastic package repositories. 100 | In order to control which major version of package repository to manage, declare the associated repository version in the `elastic_stack::repo` class. 101 | For example, to explicitly set the repository version to 5 instead of the default (which, at the time of this writing, is 6): 102 | 103 | ```puppet 104 | class { 'elastic_stack::repo': 105 | version => 5, 106 | } 107 | 108 | class { 'kibana': 109 | ensure => latest 110 | } 111 | ``` 112 | 113 | This module defaults to the upstream package repositories, which as of 6.3, includes X-Pack. In order to use the purely OSS (open source) package and repository, the appropriate `oss` flag must be set on the `elastic_stack::repo` and `kibana` classes: 114 | 115 | ```puppet 116 | class { 'elastic_stack::repo': 117 | oss => true, 118 | } 119 | 120 | class { 'kibana': 121 | oss => true, 122 | } 123 | ``` 124 | 125 | ### Plugins 126 | 127 | Kibana plugins can be managed by this module. 128 | 129 | #### Kibana 5.x & 6.x 130 | 131 | In the most basic form, official plugins (provided by Elastic) can simply be 132 | specified by name alone: 133 | 134 | ```puppet 135 | kibana_plugin { 'x-pack': } 136 | ``` 137 | 138 | The type also supports installing third-party plugins from a remote URL: 139 | 140 | ```puppet 141 | kibana_plugin { 'health_metric_vis': 142 | url => 'https://github.com/DeanF/health_metric_vis/releases/download/v0.3.4/health_metric_vis-5.2.0.zip', 143 | } 144 | ``` 145 | 146 | When updating plugins, it is important to specify the version of the plugin 147 | that should be installed. 148 | For example, the preceding block of code installed version 0.3.4 of the 149 | `health_metric_vis` plugin. In order to update that plugin to version 0.3.5, 150 | you could use a resource such as the following: 151 | 152 | ```puppet 153 | kibana_plugin { 'health_metric_vis': 154 | url => 'https://github.com/DeanF/health_metric_vis/releases/download/v0.3.5/health_metric_vis-5.2.0.zip', 155 | version => '0.3.5', 156 | } 157 | ``` 158 | 159 | Plugins can also be removed: 160 | 161 | ```puppet 162 | kibana_plugin { 'x-pack': ensure => absent } 163 | ``` 164 | 165 | #### Kibana 4.x 166 | 167 | Plugin operations are similar to 6.x resources, but in keeping with the 168 | `kibana` command-line utility, an organization and version _must_ be specified: 169 | 170 | ```puppet 171 | kibana_plugin { 'marvel': 172 | version => '2.4.4', 173 | organization => 'elasticsearch', 174 | } 175 | ``` 176 | 177 | The `version` and `organization` parameters correspond to the same values for a 178 | given plugin in the plugin's documentation, and the provider assembles the 179 | correct name on the backend on your behalf. 180 | For instance, the previous example will be translated to 181 | 182 | ```shell 183 | kibana plugin --install elasticsearch/marvel/2.4.4 184 | ``` 185 | 186 | For you. 187 | Removal through the use of `ensure => absent` is the same as for 5.x plugins. 188 | 189 | ## Reference 190 | 191 | Class parameters are available in [the auto-generated documentation 192 | pages](https://elastic.github.io/puppet-kibana/puppet_classes/kibana.html). 193 | Autogenerated documentation for types, providers, and ruby helpers is also 194 | available on the same documentation site. 195 | 196 | ## Limitations 197 | 198 | This module is actively tested against the versions and distributions listed in 199 | `metadata.json`. 200 | 201 | ## Development 202 | 203 | See CONTRIBUTING.md with help to get started. 204 | 205 | ### Quickstart 206 | 207 | Install gem dependencies: 208 | 209 | ```shell 210 | $ bundle install 211 | ``` 212 | 213 | Run the test suite (without acceptance tests): 214 | 215 | ```shell 216 | $ bundle exec rake test 217 | ``` 218 | 219 | Run acceptance tests against a platform (requires Docker): 220 | 221 | ```shell 222 | $ bundle exec rake beaker:centos-7-x64 223 | ``` 224 | 225 | ## Support 226 | 227 | Need help? Join us in [#Kibana](https://webchat.freenode.net/#kibana) on Freenode IRC or on the https://discuss.elastic.co/c/kibana discussion forum. 228 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Managed by modulesync - DO NOT EDIT 2 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 3 | 4 | # Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), 5 | # otherwise attempt to load it directly. 6 | begin 7 | require 'voxpupuli/test/rake' 8 | rescue LoadError 9 | begin 10 | require 'puppetlabs_spec_helper/rake_tasks' 11 | rescue LoadError 12 | end 13 | end 14 | 15 | # load optional tasks for acceptance 16 | # only available if gem group releases is installed 17 | begin 18 | require 'voxpupuli/acceptance/rake' 19 | rescue LoadError 20 | end 21 | 22 | # load optional tasks for releases 23 | # only available if gem group releases is installed 24 | begin 25 | require 'voxpupuli/release/rake_tasks' 26 | rescue LoadError 27 | # voxpupuli-release not present 28 | else 29 | GCGConfig.user = 'voxpupuli' 30 | GCGConfig.project = 'puppet-kibana' 31 | end 32 | 33 | desc "Run main 'test' task and report merged results to coveralls" 34 | task test_with_coveralls: [:test] do 35 | if Dir.exist?(File.expand_path('../lib', __FILE__)) 36 | require 'coveralls/rake/task' 37 | Coveralls::RakeTask.new 38 | Rake::Task['coveralls:push'].invoke 39 | else 40 | puts 'Skipping reporting to coveralls. Module has no lib dir' 41 | end 42 | end 43 | 44 | # vim: syntax=ruby 45 | -------------------------------------------------------------------------------- /data/common.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | kibana::ensure: present 3 | kibana::config: {} 4 | kibana::manage_repo: true 5 | kibana::oss: false 6 | kibana::package_source: ~ 7 | kibana::status: enabled 8 | -------------------------------------------------------------------------------- /hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 5 3 | 4 | defaults: 5 | datadir: data 6 | data_hash: 'yaml_data' 7 | 8 | hierarchy: 9 | - name: 'Default values' 10 | path: 'common.yaml' 11 | -------------------------------------------------------------------------------- /lib/puppet/functions/kibana/hash2yaml.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # @summary Converts a puppet hash to YAML string. 4 | Puppet::Functions.create_function(:'kibana::hash2yaml') do 5 | # @param input The hash to be converted to YAML 6 | # @param options A hash of options to control YAML file format 7 | # @return [String] A YAML formatted string 8 | # @example Call the function with the $input hash 9 | # kibana::hash2yaml($input) 10 | dispatch :yaml do 11 | param 'Hash', :input 12 | optional_param 'Hash', :options 13 | end 14 | 15 | require 'yaml' 16 | 17 | def yaml(input, options = {}) 18 | settings = { 19 | 'header' => '# File managed by Puppet.' 20 | } 21 | 22 | settings.merge!(options) 23 | 24 | if settings['header'].to_s.empty? 25 | input.to_yaml 26 | else 27 | "#{settings['header']}\n#{input.to_yaml}" 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/puppet/provider/elastic_kibana.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'json' 4 | 5 | # Parent class for Kibana plugin providers. 6 | class Puppet::Provider::ElasticKibana < Puppet::Provider 7 | class << self 8 | attr_accessor :home_path, :install_args, :plugin_directory, :remove_args, :format_url 9 | end 10 | 11 | # Formats a url for the plugin command-line argument. 12 | # Necessary since different versions of the Kibana plugin CLI tool accept URL 13 | # arguments in differing ways. 14 | # 15 | # @return [Proc] a lambda that accepts the URL and scope binding and returns 16 | # the formatted URL. 17 | def format_url 18 | self.class.format_url ||= ->(url, _) { [url] } 19 | end 20 | 21 | # Discovers plugins present on the system. 22 | # This is essentially the same way that the node code does it, so we do it 23 | # in native ruby to speed up the process and grab arbitrary metadata from the 24 | # plugin json (which _should_ always be present). 25 | # 26 | # @return [Array] array of discovered providers on the host. 27 | def self.present_plugins 28 | plugins = Dir[File.join(home_path, plugin_directory, '*')].select do |directory| 29 | !File.basename(directory).start_with? '.' \ 30 | and File.exist? File.join(directory, 'package.json') 31 | end 32 | plugins.map do |plugin| 33 | j = JSON.parse(File.read(File.join(plugin, 'package.json'))) 34 | { 35 | name: File.basename(plugin), 36 | ensure: :present, 37 | provider: name, 38 | version: j['version'] 39 | } 40 | end 41 | end 42 | 43 | # Enforce the desired state dictated by the properties to flush from the 44 | # provider. 45 | # 46 | # @return nil 47 | def flush 48 | if @property_flush[:ensure] == :absent 49 | # Simply remove the plugin if it should be gone 50 | run_plugin self.class.remove_args + [resource[:name]] 51 | else 52 | run_plugin self.class.remove_args + [resource[:name]] unless @property_flush[:version].nil? 53 | run_plugin self.class.install_args + plugin_url 54 | end 55 | 56 | set_property_hash 57 | end 58 | 59 | # Wrap the plugin command in some helper functionality to set the right 60 | # uid/gid. 61 | # 62 | # @return [String] debugging command output. 63 | def run_plugin(args) 64 | stdout = execute([command(:plugin)] + args, uid: 'kibana', gid: 'kibana') 65 | stdout.exitstatus.zero? ? debug(stdout) : raise(Puppet::Error, stdout) 66 | end 67 | 68 | # Helps to format the plugin name for installation. 69 | # That is, if we have a URL, pass it in correctly to the CLI tool. 70 | # 71 | # @return [Array] array of name elements suitable for use in a 72 | # Puppet::Provider#execute call. 73 | def plugin_url 74 | if !resource[:url].nil? 75 | format_url.call resource[:url], binding 76 | elsif !resource[:organization].nil? 77 | [[resource[:organization], resource[:name], resource[:version]].join('/')] 78 | else 79 | [resource[:name]] 80 | end 81 | end 82 | 83 | # The rest is normal provider boilerplate. 84 | 85 | # version property setter 86 | # 87 | # @return [String] version 88 | def version=(new_version) 89 | @property_flush[:version] = new_version 90 | end 91 | 92 | # version property getter 93 | # 94 | # @return [String] version 95 | def version 96 | @property_hash[:version] 97 | end 98 | 99 | # Sets the ensure property in the @property_flush hash. 100 | # 101 | # @return [Symbol] :present 102 | def create 103 | @property_flush[:ensure] = :present 104 | end 105 | 106 | # Determine whether this resource is present on the system. 107 | # 108 | # @return [Boolean] 109 | def exists? 110 | @property_hash[:ensure] == :present 111 | end 112 | 113 | # Set flushed ensure property to absent. 114 | # 115 | # @return [Symbol] :absent 116 | def destroy 117 | @property_flush[:ensure] = :absent 118 | end 119 | 120 | # Repopulates the @property_hash to the on-system state for the provider. 121 | def set_property_hash 122 | @property_hash = self.class.present_plugins.find do |p| 123 | p[:name] == resource[:name] 124 | end 125 | end 126 | 127 | # Finds and returns all present resources on the host. 128 | # 129 | # @return [Array] array of providers 130 | def self.instances 131 | present_plugins.map do |plugin| 132 | new plugin 133 | end 134 | end 135 | 136 | # Puppet prefetch boilerplate. 137 | # 138 | # @param resources [Hash] collection of resources extant on the system 139 | def self.prefetch(resources) 140 | instances.each do |prov| 141 | if (resource = resources[prov.name]) 142 | resource.provider = prov 143 | end 144 | end 145 | end 146 | 147 | # Provider constructor 148 | def initialize(value = {}) 149 | super(value) 150 | @property_flush = {} 151 | end 152 | end 153 | -------------------------------------------------------------------------------- /lib/puppet/provider/kibana_plugin/kibana.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'puppet/provider/elastic_kibana' 4 | 5 | Puppet::Type.type(:kibana_plugin).provide( 6 | :kibana, 7 | parent: Puppet::Provider::ElasticKibana, 8 | format_url: ->(url, b) { [b.eval('resource[:name]'), '--url', url] }, 9 | home_path: File.join(%w[/ opt kibana]), 10 | install_args: ['plugin', '--install'], 11 | plugin_directory: 'installedPlugins', 12 | remove_args: ['plugin', '--remove'] 13 | ) do 14 | desc 'Native command-line provider for Kibana v4 plugins.' 15 | 16 | commands plugin: File.join(home_path, 'bin', 'kibana') 17 | end 18 | -------------------------------------------------------------------------------- /lib/puppet/provider/kibana_plugin/kibana_plugin.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'puppet/provider/elastic_kibana' 4 | 5 | Puppet::Type.type(:kibana_plugin).provide( 6 | :kibana_plugin, 7 | parent: Puppet::Provider::ElasticKibana, 8 | home_path: File.join(%w[/ usr share kibana]), 9 | install_args: ['install'], 10 | plugin_directory: 'plugins', 11 | remove_args: ['remove'] 12 | ) do 13 | desc 'Native command-line provider for Kibana v5 plugins.' 14 | 15 | commands plugin: File.join(home_path, 'bin', 'kibana-plugin') 16 | end 17 | -------------------------------------------------------------------------------- /lib/puppet/type/kibana_plugin.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Puppet::Type.newtype(:kibana_plugin) do 4 | @doc = 'Manages Kibana plugins.' 5 | 6 | ensurable do 7 | desc 'Whether the plugin should be present or absent.' 8 | 9 | defaultvalues 10 | defaultto :present 11 | end 12 | 13 | newparam(:name, namevar: true) do 14 | desc 'Simple name of the Kibana plugin (not a URL or file path).' 15 | end 16 | 17 | newparam(:organization) do 18 | desc 'Plugin organization to use when installing 4.x-style plugins.' 19 | end 20 | 21 | newparam(:url) do 22 | desc 'URL to use when fetching plugin for installation.' 23 | end 24 | 25 | newproperty(:version) do 26 | desc 'Installed plugin version.' 27 | end 28 | 29 | autorequire(:package) do 30 | self[:ensure] == :absent ? [] : 'kibana' 31 | end 32 | 33 | validate do 34 | raise Puppet::Error, 'version must be set if organization is set' if (self[:ensure] != :absent) && !self[:organization].nil? && self[:version].nil? 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /manifests/config.pp: -------------------------------------------------------------------------------- 1 | # This class is called from kibana to configure the daemon's configuration 2 | # file. 3 | # It is not meant to be called directly. 4 | # 5 | # @author Tyler Langlois 6 | # 7 | class kibana::config { 8 | $_ensure = $kibana::ensure ? { 9 | 'absent' => $kibana::ensure, 10 | default => 'file', 11 | } 12 | 13 | file { '/etc/kibana/kibana.yml': 14 | ensure => $_ensure, 15 | content => Sensitive(kibana::hash2yaml($kibana::config)), 16 | owner => $kibana::kibana_user, 17 | group => $kibana::kibana_group, 18 | mode => '0660', 19 | } 20 | 21 | if $kibana::plugindir { 22 | file { $kibana::plugindir: 23 | ensure => 'directory', 24 | owner => $kibana::kibana_user, 25 | group => $kibana::kibana_group, 26 | mode => '0755', 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /manifests/init.pp: -------------------------------------------------------------------------------- 1 | # @summary The top-level kibana class that declares child classes for managing kibana. 2 | # 3 | # @example Basic installation 4 | # class { 'kibana' : } 5 | # 6 | # @example Module removal 7 | # class { 'kibana' : ensure => absent } 8 | # 9 | # @example Installing a specific version 10 | # class { 'kibana' : ensure => '5.2.1' } 11 | # 12 | # @example Keep latest version of Kibana installed 13 | # class { 'kibana' : ensure => 'latest' } 14 | # 15 | # @example Setting a configuration file value 16 | # class { 'kibana' : config => { 'server.port' => 5602 } } 17 | # 18 | # @param ensure State of Kibana on the system (simple present/absent/latest 19 | # or version number). 20 | # @param config Hash of key-value pairs for Kibana's configuration file 21 | # @param oss whether to manage OSS packages 22 | # @param package_source Local path to package file for file (not repo) based installation 23 | # @param manage_repo Whether to manage the package manager repository 24 | # @param status Service status 25 | # @param service_name Service name 26 | # @param package_name Package name 27 | # @param plugindir 28 | # Directory containing kibana plugins. 29 | # Use this setting if you want to manage the directory 30 | # @param kibana_user owner of kibana.yml 31 | # @param kibana_group group of kibana.yml 32 | # 33 | # @author Tyler Langlois 34 | # 35 | class kibana ( 36 | Variant[Enum['present', 'absent', 'latest'], Pattern[/^\d([.]\d+)*(-[\d\w]+)?$/]] $ensure, 37 | Hash[String[1], Variant[String, Integer, Boolean, Array, Hash]] $config, 38 | Boolean $manage_repo, 39 | Boolean $oss, 40 | Optional[String] $package_source, 41 | Kibana::Status $status, 42 | Optional[Stdlib::Absolutepath] $plugindir = undef, 43 | String[1] $service_name = 'kibana', 44 | String[1] $package_name = 'kibana', 45 | String[1] $kibana_user = 'kibana', 46 | String[1] $kibana_group = 'kibana', 47 | ) { 48 | contain kibana::install 49 | contain kibana::config 50 | contain kibana::service 51 | 52 | if $manage_repo { 53 | contain elastic_stack::repo 54 | 55 | Class['elastic_stack::repo'] 56 | -> Class['kibana::install'] 57 | } 58 | 59 | # Catch absent values, otherwise default to present/installed ordering 60 | case $ensure { 61 | 'absent': { 62 | Class['kibana::service'] 63 | -> Class['kibana::config'] 64 | -> Class['kibana::install'] 65 | } 66 | default: { 67 | Class['kibana::install'] 68 | -> Class['kibana::config'] 69 | ~> Class['kibana::service'] 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /manifests/install.pp: -------------------------------------------------------------------------------- 1 | # This class is called from the kibana class to manage installation. 2 | # It is not meant to be called directly. 3 | # 4 | # @author Tyler Langlois 5 | # 6 | class kibana::install { 7 | if $kibana::manage_repo { 8 | if $facts['os']['family'] == 'Debian' { 9 | include apt 10 | Class['apt::update'] -> Package['kibana'] 11 | } 12 | } 13 | 14 | if $kibana::package_source != undef { 15 | case $facts['os']['family'] { 16 | 'Debian': { Package['kibana'] { provider => 'dpkg' } } 17 | 'RedHat': { Package['kibana'] { provider => 'rpm' } } 18 | default: { fail("unsupported parameter 'source' set for osfamily ${facts['os']['family']}") } 19 | } 20 | } 21 | 22 | $_oss = $kibana::oss ? { 23 | true => '-oss', 24 | default => '', 25 | } 26 | 27 | package { 'kibana': 28 | ensure => $kibana::ensure, 29 | name => "${kibana::package_name}${_oss}", 30 | source => $kibana::package_source, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /manifests/service.pp: -------------------------------------------------------------------------------- 1 | # This class is meant to be called from kibana. 2 | # It ensure the service is running. 3 | # It is not meant to be called directly. 4 | # 5 | # @author Tyler Langlois 6 | # 7 | class kibana::service { 8 | if $kibana::ensure != 'absent' { 9 | case $kibana::status { 10 | # Stop service and disable on boot 11 | 'disabled': { 12 | $_ensure = false 13 | $_enable = false 14 | } 15 | # Start service and enable on boot 16 | 'enabled': { 17 | $_ensure = true 18 | $_enable = true 19 | } 20 | # Start service and disable on boot 21 | 'running': { 22 | $_ensure = true 23 | $_enable = false 24 | } 25 | # Ignore current state and disable on boot 26 | 'unmanaged': { 27 | $_ensure = undef 28 | $_enable = false 29 | } 30 | # Unknown status 31 | default: { 32 | fail('Invalid value for status') 33 | } 34 | } 35 | } else { 36 | # The package will be removed 37 | $_ensure = false 38 | $_enable = false 39 | } 40 | 41 | service { $kibana::service_name: 42 | ensure => $_ensure, 43 | enable => $_enable, 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "puppet-kibana", 3 | "version": "8.0.1-rc0", 4 | "author": "Vox Pupuli", 5 | "summary": "Module for installing, configuring, and managing Kibana.", 6 | "license": "Apache-2.0", 7 | "source": "https://github.com/voxpupuli/puppet-kibana", 8 | "project_page": "https://github.com/voxpupuli/puppet-kibana", 9 | "issues_url": "https://github.com/voxpupuli/puppet-kibana/issues", 10 | "dependencies": [ 11 | { 12 | "name": "puppet/elastic_stack", 13 | "version_requirement": ">= 6.1.0 < 10.0.0" 14 | } 15 | ], 16 | "operatingsystem_support": [ 17 | { 18 | "operatingsystem": "Debian", 19 | "operatingsystemrelease": [ 20 | "10", 21 | "11" 22 | ] 23 | }, 24 | { 25 | "operatingsystem": "CentOS", 26 | "operatingsystemrelease": [ 27 | "7", 28 | "8" 29 | ] 30 | }, 31 | { 32 | "operatingsystem": "RedHat", 33 | "operatingsystemrelease": [ 34 | "7", 35 | "8" 36 | ] 37 | }, 38 | { 39 | "operatingsystem": "Fedora", 40 | "operatingsystemrelease": [ 41 | "34", 42 | "35" 43 | ] 44 | }, 45 | { 46 | "operatingsystem": "Ubuntu", 47 | "operatingsystemrelease": [ 48 | "18.04", 49 | "20.04" 50 | ] 51 | }, 52 | { 53 | "operatingsystem": "Amazon", 54 | "operatingsystemrelease": [ 55 | "2017.03" 56 | ] 57 | } 58 | ], 59 | "requirements": [ 60 | { 61 | "name": "puppet", 62 | "version_requirement": ">= 7.0.0 < 9.0.0" 63 | }, 64 | { 65 | "name": "openvox", 66 | "version_requirement": ">= 7.0.0 < 9.0.0" 67 | } 68 | ] 69 | } 70 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/amazonlinux-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | amazonlinux-x64: 3 | roles: 4 | - master 5 | platform: el-6-x86_64 6 | image: amazonlinux:2017.03 7 | hypervisor: docker 8 | docker_cmd: ["/sbin/init"] 9 | docker_container_name: amazonlinux-x64 10 | docker_preserve_image: true 11 | docker_image_commands: 12 | - rm /etc/init/tty.conf 13 | - yum install -y rubygems20 14 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/fedora-28-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | fedora-28-x64: 3 | roles: 4 | - master 5 | platform: el-7-x86_64 6 | image: fedora:28 7 | hypervisor: docker 8 | docker_cmd: ["/sbin/init"] 9 | docker_container_name: fedora-28-x64 10 | docker_preserve_image: true 11 | docker_image_commands: 12 | - mkdir -p /etc/selinux/targeted/contexts/ 13 | - echo '' > /etc/selinux/targeted/contexts/dbus_contexts 14 | - rm /lib/systemd/system/getty.target 15 | - dnf install -y libstdc++ && dnf clean all 16 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-1204-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-12-04: 3 | roles: 4 | - master 5 | platform: ubuntu-1204-amd64 6 | image: ubuntu:12.04 7 | hypervisor: docker 8 | docker_cmd: ["/sbin/init"] 9 | docker_container_name: ubuntu-1204-amd64 10 | docker_preserve_image: true 11 | docker_image_commands: 12 | - apt-get update 13 | - apt-get install -yq libssl-dev apt-transport-https 14 | - ln -sf /sbin/initctl.distrib /sbin/initctl 15 | - locale-gen en_US en_US.UTF-8 16 | - dpkg-reconfigure locales 17 | -------------------------------------------------------------------------------- /spec/acceptance/nodesets/ubuntu-1404-x64.yml: -------------------------------------------------------------------------------- 1 | HOSTS: 2 | ubuntu-14-04: 3 | roles: 4 | - master 5 | platform: ubuntu-1404-amd64 6 | image: ubuntu:14.04 7 | hypervisor: docker 8 | docker_cmd: ["/sbin/init"] 9 | docker_container_name: ubuntu-1404-amd64 10 | docker_preserve_image: true 11 | docker_image_commands: 12 | - apt-get update 13 | - apt-get install -yq libssl-dev apt-transport-https 14 | - ln -sf /sbin/initctl.distrib /sbin/initctl 15 | - locale-gen en_US en_US.UTF-8 16 | - dpkg-reconfigure locales 17 | -------------------------------------------------------------------------------- /spec/acceptance/tests/class_v5_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper_acceptance' 4 | require 'helpers/acceptance/tests/class_shared_examples' 5 | 6 | # rubocop:disable RSpec/MultipleMemoizedHelpers 7 | describe 'kibana class v5' do 8 | let(:plugin) { 'health_metric_vis' } 9 | let(:plugin_version) { '0.3.4' } 10 | let(:port) { 5602 } 11 | let(:version) { fact('osfamily') == 'RedHat' ? '5.2.0-1' : '5.2.0' } 12 | 13 | let(:manifest) do 14 | <<-MANIFEST 15 | class { 'elastic_stack::repo': 16 | version => 5, 17 | } 18 | 19 | class { 'kibana': 20 | ensure => '#{version}', 21 | config => { 22 | 'server.host' => '0.0.0.0', 23 | 'server.port' => #{port}, 24 | }, 25 | } 26 | 27 | kibana_plugin { '#{plugin}': 28 | ensure => 'present', 29 | url => '#{plugin_url}', 30 | version => '#{plugin_version}', 31 | } 32 | MANIFEST 33 | end 34 | 35 | let(:plugin_url) do 36 | "https://github.com/DeanF/#{plugin}/releases/download/v#{plugin_version}/#{plugin}-#{version.split('-').first}.zip" 37 | end 38 | 39 | include_examples 'class manifests', 40 | '/usr/share/kibana/plugins/health_metric_vis/package.json', 41 | '0.3.5' 42 | end 43 | # rubocop:enable RSpec/MultipleMemoizedHelpers 44 | -------------------------------------------------------------------------------- /spec/acceptance/tests/snapshot.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper_acceptance' 4 | require 'helpers/acceptance/tests/basic_shared_examples' 5 | 6 | describe 'kibana snapshots' do 7 | let(:port) { 5602 } 8 | let(:version) { RSpec.configuration.snapshot_version } 9 | let(:manifest) do 10 | <<-MANIFEST 11 | class { 'kibana': 12 | config => { 13 | 'server.host' => '0.0.0.0', 14 | 'server.port' => #{port}, 15 | }, 16 | manage_repo => false, 17 | oss => #{RSpec.configuration.oss}, 18 | package_source => '/tmp/kibana-snapshot.#{RSpec.configuration.pkg_ext}', 19 | } 20 | MANIFEST 21 | end 22 | 23 | include_examples 'basic acceptance' 24 | end 25 | -------------------------------------------------------------------------------- /spec/classes/kibana_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe 'kibana', type: 'class' do 6 | context 'supported operating systems' do 7 | on_supported_os.each do |os, facts| 8 | context "on #{os}" do 9 | let(:facts) do 10 | facts.merge('scenario' => '', 'common' => '') 11 | end 12 | 13 | describe 'installation' do 14 | context 'kibana class without any parameters' do 15 | it { is_expected.to compile.with_all_deps } 16 | 17 | it 'sets expected defaults' do 18 | expect(subject).to contain_class('kibana').with( 19 | ensure: 'present', 20 | manage_repo: true 21 | ) 22 | end 23 | 24 | it 'declares install before config' do 25 | expect(subject).to contain_class('kibana::install'). 26 | that_comes_before('Class[kibana::config]') 27 | end 28 | 29 | it { is_expected.to contain_class('kibana::config') } 30 | 31 | it 'subscribes service to config' do 32 | expect(subject).to contain_class('kibana::service'). 33 | that_subscribes_to('Class[kibana::config]') 34 | end 35 | 36 | it 'installs the kibana config file' do 37 | expect(subject).to contain_file('/etc/kibana/kibana.yml'). 38 | with( 39 | ensure: 'file', 40 | owner: 'kibana', 41 | group: 'kibana', 42 | mode: '0660' 43 | ). 44 | with_content(sensitive(%r{ 45 | # Managed by Puppet.. 46 | ---. 47 | }xm)) 48 | end 49 | 50 | it 'enables and starts the service' do 51 | expect(subject).to contain_service('kibana').with( 52 | ensure: true, 53 | enable: true 54 | ) 55 | end 56 | 57 | it { is_expected.to contain_package('kibana').with_ensure('present') } 58 | 59 | it do 60 | expect(subject).to contain_class('elastic_stack::repo'). 61 | that_comes_before('Class[kibana::install]') 62 | end 63 | 64 | case facts[:os]['family'] 65 | when 'Debian' 66 | describe "#{facts[:os]['family']} resources" do 67 | it 'updates package cache before installing kibana' do 68 | expect(subject).to contain_class('apt::update'). 69 | that_comes_before('Package[kibana]') 70 | end 71 | end 72 | end 73 | end 74 | end 75 | 76 | describe 'removal' do 77 | let :params do 78 | { 79 | ensure: 'absent' 80 | } 81 | end 82 | 83 | it { is_expected.to compile.with_all_deps } 84 | 85 | it 'sets expected defaults' do 86 | expect(subject).to contain_class('kibana').with( 87 | ensure: 'absent' 88 | ) 89 | end 90 | 91 | it 'manages service before config' do 92 | expect(subject).to contain_class('kibana::service'). 93 | that_comes_before('Class[kibana::config]') 94 | end 95 | 96 | it 'manages config before install' do 97 | expect(subject).to contain_class('kibana::config'). 98 | that_comes_before('Class[kibana::install]') 99 | end 100 | 101 | it { is_expected.to contain_class('kibana::install') } 102 | 103 | it 'stops and disables the service' do 104 | expect(subject).to contain_service('kibana'). 105 | with( 106 | ensure: false, 107 | enable: false 108 | ) 109 | end 110 | 111 | it 'removes the kibana config file' do 112 | expect(subject).to contain_file('/etc/kibana/kibana.yml'). 113 | with(ensure: 'absent') 114 | end 115 | 116 | it { is_expected.to contain_package('kibana').with_ensure('absent') } 117 | end 118 | 119 | describe 'parameter validation for' do 120 | describe 'ensure' do 121 | context 'valid parameter' do 122 | %w[present absent latest 5.2.1 5.2.2-1 5.2.2-bpo1].each do |param| 123 | context param do 124 | let(:params) { { ensure: param } } 125 | 126 | it { is_expected.to compile.with_all_deps } 127 | 128 | it { 129 | expect(subject).to contain_package('kibana'). 130 | with_ensure(param) 131 | } 132 | end 133 | end 134 | end 135 | 136 | context 'bad parameters' do 137 | let(:params) { { ensure: 'foo' } } 138 | 139 | it { is_expected.not_to compile.with_all_deps } 140 | end 141 | end 142 | 143 | describe 'config' do 144 | context 'with valid parameters' do 145 | { 146 | 'server.host' => 'localhost', 147 | 'server.port' => 5601, 148 | 'elasticsearch.ssl.verify' => true, 149 | 'elasticsearch.requestHeadersWhitelist' => ['authorization'], 150 | 'tilemap' => { 'url' => 'https://test' } 151 | }.each do |key, val| 152 | context "'#{val}'" do 153 | let(:params) { { config: { key => val } } } 154 | 155 | it { is_expected.to compile.with_all_deps } 156 | end 157 | end 158 | end 159 | 160 | context 'with bad parameters' do 161 | { 162 | 'server.basePath' => 4.2, 163 | 5601 => :undef, 164 | '' => :undef 165 | }.each do |key, val| 166 | context "'#{val}'" do 167 | let(:params) { { config: { key => val } } } 168 | 169 | it { is_expected.not_to compile.with_all_deps } 170 | end 171 | end 172 | end 173 | end 174 | 175 | describe 'kibana_user' do 176 | let(:params) { { kibana_user: 'testuser' } } 177 | 178 | it { is_expected.to contain_file('/etc/kibana/kibana.yml').with(owner: 'testuser') } 179 | end 180 | 181 | describe 'kibana_group' do 182 | let(:params) { { kibana_group: 'testgroup' } } 183 | 184 | it { is_expected.to contain_file('/etc/kibana/kibana.yml').with(group: 'testgroup') } 185 | end 186 | 187 | describe 'kibana_service' do 188 | let(:params) { { service_name: 'kibana-custom' } } 189 | 190 | it 'enables and starts the custom service' do 191 | expect(subject).to contain_service('kibana-custom').with( 192 | ensure: true, 193 | enable: true 194 | ) 195 | end 196 | end 197 | 198 | describe 'manage_repo' do 199 | let(:params) { { manage_repo: false } } 200 | 201 | it { is_expected.not_to contain_class('elastic_stack::repo') } 202 | end 203 | 204 | describe 'package_source' do 205 | describe 'validation' do 206 | [{ 'foo' => 'bar' }, true, []].each do |param| 207 | context "against #{param.class}" do 208 | let(:params) { { package_source: param } } 209 | 210 | it { is_expected.not_to compile.with_all_deps } 211 | end 212 | end 213 | end 214 | 215 | describe "on #{facts[:os]['family']}" do 216 | let(:package_source) { '/tmp/kibana-5.0.0-linux-x86_64.rpm' } 217 | let(:params) { { package_source: package_source } } 218 | 219 | it { 220 | expect(subject).to contain_package('kibana'). 221 | with_source(package_source) 222 | } 223 | 224 | case facts[:os]['family'] 225 | when 'Debian' 226 | it { 227 | expect(subject).to contain_package('kibana'). 228 | with_provider('dpkg') 229 | } 230 | when 'RedHat' 231 | it { 232 | expect(subject).to contain_package('kibana'). 233 | with_provider('rpm') 234 | } 235 | else 236 | it { is_expected.not_to compile.with_all_deps } 237 | end 238 | end 239 | end 240 | 241 | describe 'kibana_package_name' do 242 | let(:params) { { package_name: 'kibana-custom' } } 243 | 244 | it { 245 | expect(subject).to contain_package('kibana'). 246 | with_name('kibana-custom') 247 | } 248 | end 249 | 250 | describe 'kibana_plugindir' do 251 | let(:params) { { plugindir: '/usr/local/kibana/plugins' } } 252 | 253 | it { is_expected.to contain_file('/usr/local/kibana/plugins').with(mode: '0755') } 254 | end 255 | end 256 | end 257 | end 258 | end 259 | end 260 | -------------------------------------------------------------------------------- /spec/fixtures/artifacts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voxpupuli/puppet-kibana/7a5dd0da9ead35343a451f91a555f0280be6f22e/spec/fixtures/artifacts/.gitkeep -------------------------------------------------------------------------------- /spec/fixtures/hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - yaml 4 | :yaml: 5 | :datadir: './spec/fixtures/hieradata' 6 | :hierarchy: 7 | - '%{::clientcert}' 8 | - 'default' 9 | -------------------------------------------------------------------------------- /spec/fixtures/hieradata/default.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Default key/value pairs 3 | -------------------------------------------------------------------------------- /spec/functions/kibana_hash2yaml.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | describe 'kibana::hash2yaml' do 5 | context 'with header' do 6 | it do 7 | is_expected.to run.with_params({ cle: 1 }, { header: '# HEADER' }).and_return('# HEADER\ncle: 1') 8 | end 9 | end 10 | 11 | context 'without header' do 12 | it do 13 | is_expected.to run.with_params({ cle: 1 }).and_return('# File managed by Puppet.\ncle: 1') 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /spec/helpers/acceptance/tests/basic_shared_examples.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | shared_examples 'basic acceptance' do 4 | context 'example manifest' do 5 | request_path = if RSpec.configuration.is_snapshot && !RSpec.configuration.oss 6 | '/login' 7 | else 8 | '' 9 | end 10 | 11 | it { apply_manifest(manifest, catch_failures: true) } 12 | it { apply_manifest(manifest, catch_changes: true) } 13 | 14 | describe package("kibana#{RSpec.configuration.oss ? '-oss' : ''}") do 15 | it { is_expected.to be_installed } 16 | end 17 | 18 | describe service('kibana') do 19 | it { is_expected.to be_enabled } 20 | it { is_expected.to be_running } 21 | end 22 | 23 | describe port(5602) { it { is_expected.to be_listening } } 24 | 25 | describe "http://localhost:5602#{request_path}" do 26 | # Kibana versions reply to requests differently depending upon whether 27 | # Elasticsearch is up and responding on the backend. In most cases we 28 | # just want to ensure that Kibana has installed and started, so testing 29 | # to confirm whether Kibana is replying with proper HTTP response codes 30 | # is sufficient (earlier versions return 200 in most cases, later 31 | # versions pass through ES unavailability as 503's). 32 | subject { shell("curl -o /dev/null -w '%{http_code}' http://localhost:5602#{request_path}") } 33 | 34 | it('returns OK', :api) do 35 | expect(subject.stdout.to_i).to eq(200).or(eq(503)) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /spec/helpers/acceptance/tests/class_shared_examples.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'helpers/acceptance/tests/basic_shared_examples' 4 | 5 | shared_examples 'class manifests' do |plugin_json_file, plugin_upgrade| 6 | include_examples 'basic acceptance' 7 | 8 | context 'plugin upgrades' do 9 | let(:plugin_version) { plugin_upgrade } 10 | 11 | it { apply_manifest(manifest, catch_failures: true) } 12 | it { apply_manifest(manifest, catch_changes: true) } 13 | 14 | describe file(plugin_json_file) do 15 | its(:content_as_json) { is_expected.to include('version' => plugin_version) } 16 | end 17 | end 18 | 19 | context 'removal' do 20 | let(:manifest) do 21 | <<-MANIFEST 22 | class { 'kibana': 23 | ensure => absent, 24 | } 25 | MANIFEST 26 | end 27 | 28 | it 'applies cleanly' do 29 | apply_manifest( 30 | "kibana_plugin { '#{plugin}': ensure => absent } ->" + manifest, 31 | catch_failures: true 32 | ) 33 | end 34 | 35 | it 'is idempotent' do 36 | apply_manifest(manifest, catch_changes: true) 37 | end 38 | 39 | describe package('kibana') do 40 | it { is_expected.not_to be_installed } 41 | end 42 | 43 | describe service('kibana') do 44 | it { is_expected.not_to be_enabled } 45 | it { is_expected.not_to be_running } 46 | end 47 | 48 | describe port(5602) { it { is_expected.not_to be_listening } } 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /spec/helpers/unit/provider/kibana_plugin_shared_examples.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'json' 4 | 5 | shared_examples 'kibana plugin provider' do 6 | describe 'instances' do 7 | it 'has an instance method' do 8 | expect(described_class).to respond_to :instances 9 | end 10 | 11 | context 'without plugins' do 12 | before do 13 | allow(Dir).to receive(:[]).and_return %w[. ..] 14 | end 15 | 16 | it 'returns no resources' do 17 | expect(described_class.instances.size).to eq(0) 18 | end 19 | end 20 | 21 | context 'with one plugin' do 22 | subject { described_class.instances.first } 23 | 24 | before do 25 | allow(Dir).to receive(:[]).and_return [File.join(plugin_path, plugin_one[:name])] 26 | allow(File).to receive(:read). 27 | with(File.join(plugin_path, plugin_one[:name], 'package.json')). 28 | and_return JSON.dump(name: plugin_one[:name], version: plugin_one[:version]) 29 | allow(File).to receive(:exist?). 30 | with(File.join(plugin_path, plugin_one[:name], 'package.json')). 31 | and_return true 32 | end 33 | 34 | it { expect(subject).to exist } 35 | it { expect(subject.name).to eq(plugin_one[:name]) } 36 | it { expect(subject.version).to eq(plugin_one[:version]) } 37 | end 38 | 39 | context 'with multiple plugins' do 40 | before do 41 | allow(Dir). 42 | to(receive(:[])). 43 | and_return([plugin_one, plugin_two].map { |p| File.join(plugin_path, p[:name]) }) 44 | [plugin_one, plugin_two].each do |plugin| 45 | allow(File).to receive(:read). 46 | with(File.join(plugin_path, plugin[:name], 'package.json')). 47 | and_return JSON.dump(name: plugin[:name], verison: plugin[:version]) 48 | allow(File).to receive(:exist?). 49 | with(File.join(plugin_path, plugin[:name], 'package.json')). 50 | and_return true 51 | end 52 | end 53 | 54 | it 'returns two resources' do 55 | expect(described_class.instances.length).to eq(2) 56 | end 57 | end 58 | end 59 | 60 | describe 'prefetch' do 61 | it 'has a prefetch method' do 62 | expect(described_class).to respond_to :prefetch 63 | end 64 | end 65 | 66 | describe 'flush' do 67 | before do 68 | allow(described_class). 69 | to receive(:command).with(:plugin). 70 | and_return executable 71 | end 72 | 73 | let(:install_name) do 74 | if resource[:organization].nil? 75 | resource[:name] 76 | else 77 | [resource[:organization], resource[:name], resource[:version]].join('/') 78 | end 79 | end 80 | 81 | it 'installs plugins' do 82 | allow(provider).to( 83 | receive(:execute). 84 | with( 85 | [executable] + install_args + [install_name], 86 | uid: 'kibana', gid: 'kibana' 87 | ). 88 | and_return( 89 | Puppet::Util::Execution::ProcessOutput.new('success', 0) 90 | ) 91 | ) 92 | resource[:ensure] = :present 93 | provider.create 94 | provider.flush 95 | expect(provider).to( 96 | have_received(:execute). 97 | with( 98 | [executable] + install_args + [install_name], 99 | uid: 'kibana', gid: 'kibana' 100 | ) 101 | ) 102 | end 103 | 104 | it 'removes plugins' do 105 | allow(provider).to( 106 | receive(:execute). 107 | with( 108 | [executable] + remove_args + [resource[:name]], 109 | uid: 'kibana', gid: 'kibana' 110 | ). 111 | and_return( 112 | Puppet::Util::Execution::ProcessOutput.new('success', 0) 113 | ) 114 | ) 115 | resource[:ensure] = :absent 116 | provider.destroy 117 | provider.flush 118 | expect(provider).to( 119 | have_received(:execute). 120 | with( 121 | [executable] + remove_args + [resource[:name]], 122 | uid: 'kibana', gid: 'kibana' 123 | ) 124 | ) 125 | end 126 | 127 | it 'updates plugins' do 128 | allow(provider).to( 129 | receive(:execute). 130 | with( 131 | [executable] + install_args + [install_name], 132 | uid: 'kibana', gid: 'kibana' 133 | ). 134 | and_return( 135 | Puppet::Util::Execution::ProcessOutput.new('success', 0) 136 | ) 137 | ) 138 | allow(provider).to( 139 | receive(:execute). 140 | with( 141 | [executable] + remove_args + [resource[:name]], 142 | uid: 'kibana', gid: 'kibana' 143 | ). 144 | and_return( 145 | Puppet::Util::Execution::ProcessOutput.new('success', 0) 146 | ) 147 | ) 148 | resource[:ensure] = :present 149 | provider.version = plugin_one[:version] 150 | provider.flush 151 | expect(provider).to( 152 | have_received(:execute). 153 | with( 154 | [executable] + install_args + [install_name], 155 | uid: 'kibana', gid: 'kibana' 156 | ) 157 | ) 158 | expect(provider).to( 159 | have_received(:execute). 160 | with( 161 | [executable] + remove_args + [resource[:name]], 162 | uid: 'kibana', gid: 'kibana' 163 | ) 164 | ) 165 | end 166 | end 167 | 168 | describe 'command execution' do 169 | it 'causes catalog failures' do 170 | allow(provider).to receive(:execute).and_return( 171 | Puppet::Util::Execution::ProcessOutput.new('failed', 70) 172 | ) 173 | resource[:ensure] = :present 174 | expect { provider.flush }.to raise_error(Puppet::Error) 175 | expect(provider).to have_received(:execute) 176 | end 177 | end 178 | end 179 | -------------------------------------------------------------------------------- /spec/setup_acceptance_node.pp: -------------------------------------------------------------------------------- 1 | # Needed for os.distro.codebase fact on ubuntu 16/18 on puppet 6 2 | if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['puppetversion'], '7.0.0') < 0 { 3 | package{'lsb-release': 4 | ensure => present, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Managed by modulesync - DO NOT EDIT 4 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 5 | 6 | # puppetlabs_spec_helper will set up coverage if the env variable is set. 7 | # We want to do this if lib exists and it hasn't been explicitly set. 8 | ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) 9 | 10 | require 'voxpupuli/test/spec_helper' 11 | 12 | RSpec.configure do |c| 13 | c.facterdb_string_keys = false 14 | end 15 | 16 | add_mocked_facts! 17 | 18 | if File.exist?(File.join(__dir__, 'default_module_facts.yml')) 19 | facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) 20 | facts&.each do |name, value| 21 | add_custom_fact name.to_sym, value 22 | end 23 | end 24 | Dir['./spec/support/spec/**/*.rb'].sort.each { |f| require f } 25 | -------------------------------------------------------------------------------- /spec/spec_helper_acceptance.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Managed by modulesync - DO NOT EDIT 4 | # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ 5 | 6 | require 'voxpupuli/acceptance/spec_helper_acceptance' 7 | 8 | configure_beaker(modules: :metadata) 9 | 10 | Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } 11 | -------------------------------------------------------------------------------- /spec/spec_utilities.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'open-uri' 4 | 5 | def to_agent_version(puppet_version) 6 | # REF: https://docs.puppet.com/puppet/latest/reference/about_agent.html 7 | { 8 | # Puppet => Agent 9 | '4.10.4' => '1.10.4', 10 | '4.10.3' => '1.10.3', 11 | '4.10.2' => '1.10.2', 12 | '4.10.1' => '1.10.1', 13 | '4.10.0' => '1.10.0', 14 | '4.9.4' => '1.9.3', 15 | '4.8.2' => '1.8.3', 16 | '4.7.1' => '1.7.2', 17 | '4.7.0' => '1.7.1', 18 | '4.6.2' => '1.6.2', 19 | '4.5.3' => '1.5.3', 20 | '4.4.2' => '1.4.2', 21 | '4.4.1' => '1.4.1', 22 | '4.4.0' => '1.4.0', 23 | '4.3.2' => '1.3.6', 24 | '4.3.1' => '1.3.2', 25 | '4.3.0' => '1.3.0', 26 | '4.2.3' => '1.2.7', 27 | '4.2.2' => '1.2.6', 28 | '4.2.1' => '1.2.2', 29 | '4.2.0' => '1.2.1', 30 | '4.1.0' => '1.1.1', 31 | '4.0.0' => '1.0.1' 32 | }[puppet_version] 33 | end 34 | 35 | def artifact(file) 36 | File.join(%w[spec fixtures artifacts] + [File.basename(file)]) 37 | end 38 | 39 | def get(url, file_path) 40 | puts "Fetching #{url}..." 41 | found = false 42 | until found 43 | uri = URI.parse(url) 44 | conn = Net::HTTP.new(uri.host, uri.port) 45 | conn.use_ssl = true 46 | res = conn.get(uri.path) 47 | if res.header['location'] 48 | url = res.header['location'] 49 | else 50 | found = true 51 | end 52 | end 53 | File.write(file_path, res.body) 54 | end 55 | -------------------------------------------------------------------------------- /spec/support/acceptance/kibana.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rspec/retry' 4 | 5 | require_relative '../../spec_utilities' 6 | 7 | ENV['PUPPET_INSTALL_TYPE'] = 'agent' if ENV['PUPPET_INSTALL_TYPE'].nil? 8 | 9 | RSpec.configure do |c| 10 | # Project root 11 | # proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) 12 | 13 | # Readable test descriptions 14 | c.formatter = :documentation 15 | 16 | c.add_setting :pkg_ext 17 | c.pkg_ext = case fact('osfamily') 18 | when 'Debian' 19 | 'deb' 20 | when 'RedHat' 21 | 'rpm' 22 | end 23 | 24 | c.add_setting :is_snapshot 25 | c.is_snapshot = c.files_to_run.any? { |fn| fn.include? 'snapshot' } 26 | 27 | c.add_setting :oss 28 | 29 | # Copy over the snapshot package if we're running snapshot tests 30 | if c.is_snapshot && !c.pkg_ext.nil? 31 | c.add_setting :snapshot_file 32 | c.snapshot_file = "kibana-snapshot.#{c.pkg_ext}" 33 | 34 | c.add_setting :snapshot_version 35 | c.snapshot_version = File.readlink(artifact(c.snapshot_file)).match(%r{kibana(?:-oss)?-(?.*)[.][a-z]+})[:v] 36 | 37 | c.oss = (!File.readlink(artifact(c.snapshot_file)).match(%r{-oss}).nil?) 38 | else 39 | c.oss = false 40 | end 41 | 42 | # Configure all nodes in nodeset 43 | c.before :suite do 44 | if c.is_snapshot 45 | hosts.each do |host| 46 | scp_to host, artifact(c.snapshot_file), "/tmp/#{c.snapshot_file}" 47 | end 48 | end 49 | end 50 | 51 | c.around :each, :api do |example| 52 | # The initial optimization startup time of Kibana is _incredibly_ slow, 53 | # so we need to be pretty generous with how we retry API call attempts. 54 | example.run_with_retry retry: 10, retry_wait: 5 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /spec/unit/provider/kibana_plugin/kibana_plugin_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | require 'helpers/unit/provider/kibana_plugin_shared_examples' 5 | 6 | # rubocop:disable RSpec/MultipleMemoizedHelpers 7 | describe Puppet::Type.type(:kibana_plugin).provider(:kibana_plugin) do 8 | let(:executable) { "#{home_path}/bin/kibana-plugin" } 9 | let(:home_path) { '/usr/share/kibana' } 10 | let(:install_args) { ['install'] } 11 | let(:plugin_path) { "#{home_path}/plugins" } 12 | let(:provider) { described_class.new(name: plugin_one[:name]) } 13 | let(:remove_args) { ['remove'] } 14 | 15 | let(:plugin_one) do 16 | { 17 | name: 'x-pack', 18 | version: '5.2.1' 19 | } 20 | end 21 | 22 | let(:plugin_two) do 23 | { 24 | name: 'logtrail', 25 | version: '5.2.0' 26 | } 27 | end 28 | 29 | let(:resource) do 30 | Puppet::Type.type(:kibana_plugin).new( 31 | name: plugin_one[:name], 32 | provider: provider, 33 | version: plugin_one[:version] 34 | ) 35 | end 36 | 37 | include_examples 'kibana plugin provider' 38 | 39 | describe 'url' do 40 | before do 41 | allow(described_class). 42 | to receive(:command).with(:plugin). 43 | and_return executable 44 | end 45 | 46 | it 'passes it through to the install command' do 47 | url = 'https://some.sample.url/directory' 48 | allow(provider).to( 49 | receive(:execute). 50 | with( 51 | [executable] + install_args + [url], 52 | uid: 'kibana', gid: 'kibana' 53 | ). 54 | and_return( 55 | Puppet::Util::Execution::ProcessOutput.new('success', 0) 56 | ) 57 | ) 58 | resource[:url] = url 59 | provider.create 60 | provider.flush 61 | expect(provider).to( 62 | have_received(:execute). 63 | with( 64 | [executable] + install_args + [url], 65 | uid: 'kibana', gid: 'kibana' 66 | ) 67 | ) 68 | end 69 | end 70 | end 71 | # rubocop:enable RSpec/MultipleMemoizedHelpers 72 | -------------------------------------------------------------------------------- /spec/unit/provider/kibana_plugin/kibana_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | require 'helpers/unit/provider/kibana_plugin_shared_examples' 5 | 6 | # rubocop:disable RSpec/MultipleMemoizedHelpers 7 | describe Puppet::Type.type(:kibana_plugin).provider(:kibana) do 8 | let(:executable) { "#{home_path}/bin/kibana" } 9 | let(:home_path) { '/opt/kibana' } 10 | let(:install_args) { ['plugin', '--install'] } 11 | let(:plugin_path) { "#{home_path}/installedPlugins" } 12 | let(:provider) { described_class.new(name: plugin_one[:name]) } 13 | let(:remove_args) { ['plugin', '--remove'] } 14 | 15 | let(:plugin_one) do 16 | { 17 | name: 'marvel', 18 | version: '2.4.4' 19 | } 20 | end 21 | 22 | let(:plugin_two) do 23 | { 24 | name: 'graph', 25 | version: '2.4.1' 26 | } 27 | end 28 | 29 | let(:resource) do 30 | Puppet::Type.type(:kibana_plugin).new( 31 | name: plugin_one[:name], 32 | organization: 'elasticsearch', 33 | provider: provider, 34 | version: '2.4.4' 35 | ) 36 | end 37 | 38 | include_examples 'kibana plugin provider' 39 | 40 | describe 'url' do 41 | before do 42 | allow(described_class). 43 | to receive(:command).with(:plugin). 44 | and_return executable 45 | end 46 | 47 | it 'causes --url to be passed to install' do 48 | url = 'https://some.sample.url/directory' 49 | allow(provider).to( 50 | receive(:execute). 51 | with( 52 | [executable] + install_args + [resource[:name], '--url', url], 53 | uid: 'kibana', gid: 'kibana' 54 | ). 55 | and_return( 56 | Puppet::Util::Execution::ProcessOutput.new('success', 0) 57 | ) 58 | ) 59 | resource[:url] = url 60 | provider.create 61 | provider.flush 62 | expect(provider).to( 63 | have_received(:execute). 64 | with( 65 | [executable] + install_args + [resource[:name], '--url', url], 66 | uid: 'kibana', gid: 'kibana' 67 | ) 68 | ) 69 | end 70 | end 71 | end 72 | # rubocop:enable RSpec/MultipleMemoizedHelpers 73 | -------------------------------------------------------------------------------- /spec/unit/type/kibana_plugin_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | describe Puppet::Type.type(:kibana_plugin) do 6 | let(:resource_name) { 'x-pack' } 7 | 8 | describe 'input validation' do 9 | it 'defaults to being installed' do 10 | plugin = described_class.new(name: resource_name) 11 | expect(plugin.should(:ensure)).to eq(:present) 12 | end 13 | 14 | describe 'when validating attributes' do 15 | it 'has an organization parameter' do 16 | expect(described_class.attrtype(:organization)).to eq(:param) 17 | end 18 | 19 | it 'has a url parameter' do 20 | expect(described_class.attrtype(:url)).to eq(:param) 21 | end 22 | 23 | it 'has an ensure property' do 24 | expect(described_class.attrtype(:ensure)).to eq(:property) 25 | end 26 | 27 | it 'has a version property' do 28 | expect(described_class.attrtype(:version)).to eq(:property) 29 | end 30 | end 31 | 32 | describe 'validate' do 33 | it 'requires version when organization is set' do 34 | expect { described_class.new(name: 'marvel', organization: 'elasticsearch') }. 35 | to raise_error(Puppet::Error, %r{version must be set if organization is set}) 36 | end 37 | 38 | it 'does not require version when organization is set when ensure is absent' do 39 | expect do 40 | described_class.new( 41 | name: 'marvel', 42 | ensure: 'absent', 43 | organization: 'elasticsearch' 44 | ) 45 | end.not_to raise_error 46 | end 47 | end 48 | end 49 | 50 | describe 'autorequire' do 51 | let(:kibana_pkg) { Puppet::Type.type(:package).new(name: 'kibana', ensure: :present) } 52 | let(:catalog) do 53 | res = Puppet::Resource::Catalog.new 54 | res.add_resource kibana_pkg 55 | res 56 | end 57 | 58 | it 'autorequires the kibana package' do 59 | resource = described_class.new(name: 'x-pack') 60 | catalog.add_resource resource 61 | req = resource.autorequire 62 | expect(req.size).to eq(1) 63 | expect(req[0].target).to eq(resource) 64 | expect(req[0].source).to eq(kibana_pkg) 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /types/status.pp: -------------------------------------------------------------------------------- 1 | type Kibana::Status = Enum['disabled', 'enabled', 'running', 'unmanaged'] 2 | --------------------------------------------------------------------------------