Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and Puppet-Strings based reference docs #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib"
extlib: "https://github.com/voxpupuli/puppet-extlib"
archive: "https://github.com/voxpupuli/puppet-archive"
systemd: "https://github.com/camptocamp/puppet-systemd"
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--color
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
source 'https://rubygems.org'

puppetversion = ENV.key?('PUPPET_VERSION') ? "#{ENV['PUPPET_VERSION']}" : ['>= 3.3']
ENV['PUPPET_VERSION'].nil? ? puppetversion = '~> 5.0' : puppetversion = ENV['PUPPET_VERSION'].to_s
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.8.2'
gem 'puppet-lint', '>= 1.0.0'
gem 'puppetlabs_spec_helper', '>= 2.11.0'
gem 'rspec-puppet-facts', '>= 1.8.0'
gem 'metadata-json-lint'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this gem explicitly declared, the validate rake task won't check the metadata.json file.

gem 'puppet-strings', '>= 1.0'
gem 'facter', '>= 1.7.0'

gem 'puppet-blacksmith'
35 changes: 13 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Cerebro Puppet Module [![Puppet Forge](https://img.shields.io/puppetforge/v/yano3/cerebro.svg?style=flat-square)](https://forge.puppet.com/yano3/cerebro)
# Cerebro Puppet Module
[![Puppet Forge](https://img.shields.io/puppetforge/v/yano3/cerebro.svg?style=flat-square)](https://forge.puppet.com/yano3/cerebro)
[![License](https://img.shields.io/github/license/yano3/puppet-cerebron.svg)](https://github.com/yano3/puppet-cerebro/blob/master/LICENSE)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because who doesn't like badges! :)


#### Table of Contents

Expand All @@ -18,38 +20,22 @@ Puppet module for managing and configuring [Cerebro](https://github.com/lmenezes

### Beginning with cerebro

```
class { 'cerebro': }
```puppet
include cerebro
```

## Usage

```
```puppet
class { 'cerebro':
version => '0.8.1',
}
```

## Reference

### Parameters

#### Class: `cerebro`

- `version`: Specify Cerebro version.
- `service_ensure`: Determines whether the cerebro service should be running.
- `service_enable`: Determines whether the cerebro service should be enabled when the system is booted.
- `secret`: Specify secret string.
- `hosts`: Specify a list of known hosts.
- `basepath`: Specify application base path.
- `shell`: Specify a shell for cerebro user.
- `manage_user`: Specify whether creating user that cerebro process is executed as.
- `cerebro_user`: Specify the user that cerebro process is executed as.
- `package_url`: Specify a package location.
- `java_opts`: Specify `JAVA_OPTS` variables.
- `java_home`: Specify `JAVA_HOME` path.
- `basic_auth_settings`: Specify basic authentication settings.
- `address`: Specify IP address cerebro listeining on.
See [REFERENCE.md](REFERENCE.md).
This module has been documented with [puppet-strings](https://github.com/puppetlabs/puppet-strings).

## Limitations

Expand All @@ -60,3 +46,8 @@ This module has been tested on:
## Development

Bug reports and pull requests are welcome on GitHub at https://github.com/yano3/puppet-cerebro.

To regenerate the [REFERENCE.MD](REFERENCE.md) file, please run the rake task as follows.
```console
% bundle exec rake strings:generate\[',,,,false,true']
```
163 changes: 163 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Reference
<!-- DO NOT EDIT: This document was generated by Puppet Strings -->

## Table of Contents

**Classes**

_Public Classes_

* [`cerebro`](#cerebro): Installs and configures Cerebro

_Private Classes_

* `cerebro::config`: Configures Cerebro
* `cerebro::install`: Installs Cerebro
* `cerebro::params`:
* `cerebro::service`: Manages Cerebro service
* `cerebro::user`: Creates the cerebro user

## Classes

### cerebro

Installs and configures Cerebro

* **See also**
https://github.com/lmenezes/cerebro

#### Examples

##### Basic usage

```puppet
include cerebro
```

##### Installing a specific version

```puppet
class { 'cerebro':
version => '0.8.1',
}
```

#### Parameters

The following parameters are available in the `cerebro` class.

##### `version`

Data type: `String[1]`

Defines the Cerebro version.

Default value: $cerebro::params::version

##### `service_ensure`

Data type: `Stdlib::Ensure::Service`

Determines whether the cerebro service should be running.

Default value: $cerebro::params::service_ensure

##### `service_enable`

Data type: `Boolean`

Determines whether the cerebro service should be enabled when the system is booted.

Default value: $cerebro::params::service_enable

##### `secret`

Data type: `String`

Specifies the secret string used to sign session cookies etc.

Default value: $cerebro::params::secret

##### `hosts`

Data type: `Array[Struct[{
host => Stdlib::HTTPUrl,
name => String[1]
}]]`

Defines an array of known hosts hashes.

Default value: $cerebro::params::hosts

##### `basepath`

Data type: `Variant[Pattern[/^\/$/],Stdlib::Unixpath]`

Specifies the application base path.

Default value: $cerebro::params::basepath

##### `shell`

Data type: `Stdlib::Unixpath`

Specifies a shell for the cerebro user.

Default value: $cerebro::params::shell

##### `manage_user`

Data type: `Boolean`

Determines whether to creating the user that the cerebro process is executed as.

Default value: $cerebro::params::manage_user

##### `cerebro_user`

Data type: `String[1]`

Specifies the user that cerebro process is executed as.

Default value: $cerebro::params::cerebro_user

##### `package_url`

Data type: `Optional[String[1]]`

Defines a package location for downloading cerebro.

Default value: $cerebro::params::package_url

##### `java_opts`

Data type: `Array[String[1]]`

Defines the `JAVA_OPTS` variables.

Default value: $cerebro::params::java_opts

##### `java_home`

Data type: `Optional[Stdlib::Unixpath]`

Defines the `JAVA_HOME` path.

Default value: $cerebro::params::java_home

##### `basic_auth_settings`

Data type: `Optional[Hash]`

Defines basic authentication settings.

Default value: $cerebro::params::basic_auth_settings

##### `address`

Data type: `Optional[Stdlib::IP::Address]`

Defines the IP address cerebro should listen on.

Default value: $cerebro::params::address

29 changes: 15 additions & 14 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet_blacksmith/rake_tasks'
require 'puppet-strings/tasks'

PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"]
exclude_paths = %w(
pkg/**/*
vendor/**/*
.vendor/**/*
spec/**/*
)
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths

desc "Validate manifests, templates, and ruby files"
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end
desc 'Run tests metadata_lint, release_checks'
task test: [
:metadata_lint,
:release_checks,
]
# vim: syntax=ruby
22 changes: 13 additions & 9 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
class cerebro::config (
$secret = $::cerebro::secret,
$hosts = $::cerebro::hosts,
$basepath = $::cerebro::basepath,
$java_home = $::cerebro::java_home,
$java_opts = $::cerebro::java_opts,
$basic_auth_settings = $::cerebro::basic_auth_settings,
$sysconfig = $::cerebro::sysconfig,
) {
# @summary Configures Cerebro
#
# @api private
class cerebro::config
{
$secret = $cerebro::secret
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the class is private and only ever expected to be declared from the base class, I've moved the variable declarations from being class parameters to being in the body of the class.

$hosts = $cerebro::hosts
$basepath = $cerebro::basepath
$java_home = $cerebro::java_home
$java_opts = $cerebro::java_opts
$basic_auth_settings = $cerebro::basic_auth_settings
$sysconfig = $cerebro::sysconfig

file { '/etc/cerebro/application.conf':
ensure => file,
content => template('cerebro/etc/cerebro/application.conf.erb'),
Expand Down
Loading