Skip to content

Commit

Permalink
bumping pdk version, updating documentation and moving to hiera based…
Browse files Browse the repository at this point in the history
… params loading
  • Loading branch information
attachmentgenie committed Nov 30, 2020
1 parent 689458a commit 5dd81e7
Show file tree
Hide file tree
Showing 24 changed files with 286 additions and 150 deletions.
15 changes: 10 additions & 5 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# This file can be used to install module depdencies for unit testing
# See https://github.com/puppetlabs/puppetlabs_spec_helper#using-fixtures for details
---
fixtures:
forge_modules:
archive: 'puppet/archive'
systemd: 'camptocamp/systemd'
stdlib: 'puppetlabs/stdlib'
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
systemd: "https://github.com/camptocamp/puppet-systemd.git"
wget: "https://github.com/maestrodev/puppet-wget.git"
symlinks:
"mailhog": "#{source_dir}"
facts: 'https://github.com/puppetlabs/puppetlabs-facts.git'
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git'
provision: 'https://github.com/puppetlabs/provision.git'
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
EnforcedStyle: braces_for_chaining
Style/BracesAroundHashParameters:
Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0.
See https://github.com/rubocop-hq/rubocop/pull/7643
Enabled: true
Style/ClassAndModuleChildren:
Description: Compact style reduces the required amount of indentation.
EnforcedStyle: compact
Expand Down
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ jobs:
env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec
rvm: 2.5.7
stage: spec
-
before_script:
- "bundle exec rake 'litmus:provision_list[puppet5]'"
- "bundle exec rake 'litmus:install_agent[puppet5]'"
- "bundle exec rake litmus:install_module"
bundler_args:
env: PLATFORMS=puppet5
script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"]
services: docker
stage: acceptance
-
before_script:
- "bundle exec rake 'litmus:provision_list[puppet6]'"
- "bundle exec rake 'litmus:install_agent[puppet6]'"
- "bundle exec rake litmus:install_module"
bundler_args:
env: PLATFORMS=puppet6
script: ["travis_wait 45 bundle exec rake litmus:acceptance:parallel"]
services: docker
stage: acceptance
-
env: DEPLOY_TO_FORGE=yes
stage: deploy
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"jpogran.puppet-vscode",
"puppet.puppet-vscode",
"rebornix.Ruby"
]
}
36 changes: 14 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,17 @@ MailHog is an email testing tool for developers:
- Package/service/configuration files for Mailhog
- Listened-to ports

### Setup Requirements
## Usage

none
All options and configuration can be done through interacting with the parameters
on the main mailhog class.
These are now documented via [Puppet Strings](https://github.com/puppetlabs/puppet-strings)

### Beginning with mailhog
You can view example usage in [REFERENCE](REFERENCE.md).

To have Puppet install Mailhog with the default parameters, declare the mailhog class:
## Reference

``` puppet
class { 'mailhog': }
```

You can customize parameters when declaring the `mailhog` class. For instance,
this declaration installs Mailhog by downloading a tarball instead of instead of using a package.

``` puppet
class { '::mailhog':
install_method => 'wget',
wget_source => 'https://github.com/mailhog/MailHog/releases/download/v0.2.1/MailHog_linux_amd64',
}
```
See [REFERENCE](REFERENCE.md).

## Limitations

Expand All @@ -57,12 +47,14 @@ This module currently only exposes a subset of all configuration options.

### Running tests

This project contains tests for both rspec-puppet and test kitchen to verify functionality. For detailed information on using these tools, please see their respective documentation.
This project contains tests for both rspec-puppet and litmus to verify functionality. For detailed information on using these tools, please see their respective documentation.

#### Testing quickstart:

```
gem install bundler
bundle install
bundle exec rake guard
bundle exec kitchen test
pdk bundle install
pdk bundle exec rake 'litmus:provision_list[puppet6]'
pdk bundle exec rake 'litmus:install_agent[puppet6]'
pdk bundle exec rake litmus:install_module
pdk bundle exec rake litmus:acceptance:parallel
pdk bundle exec rake litmus:tear_down
109 changes: 109 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Reference

<!-- DO NOT EDIT: This document was generated by Puppet Strings -->

## Table of Contents

### Classes

#### Public Classes

* [`mailhog`](#mailhog): Class to install and configure mailhog. Use this module to install and configure mailhog.

#### Private Classes

* `mailhog::config`: Class to configure mailhog.
* `mailhog::install`: Class to install mailhog.
* `mailhog::service`: Class to manage the mailhog service.

## Classes

### `mailhog`

Class to install and configure mailhog.

Use this module to install and configure mailhog.

#### Examples

##### Declaring the class

```puppet
class { '::mailhog':
install_method => 'archive',
archive_source => 'https://github.com/mailhog/MailHog/releases/download/v1.0.1/MailHog_linux_amd64',
}
```

#### Parameters

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

##### `config`

Data type: `String[1]`

Mailhog config.

##### `config_file`

Data type: `Stdlib::Absolutepath`

Mailhog config file.

##### `install_dir`

Data type: `Stdlib::Absolutepath`

Location of mailhog binary release.

##### `install_method`

Data type: `Enum['package','archive']`

How to install mailhog.

##### `manage_service`

Data type: `Boolean`

Manage the mailhog service.

##### `package_name`

Data type: `String[1]`

Name of package to install.

##### `package_version`

Data type: `String[1]`

Version of mailhog to install.

##### `service_name`

Data type: `String[1]`

Name of service to manage.

##### `service_provider`

Data type: `String[1]`

Init system that is used.

##### `service_ensure`

Data type: `Enum['running','stopped']`

The state of the service.

##### `archive_source`

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

Location of mailhog binary release.

Default value: ``undef``

13 changes: 6 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,35 @@ if Bundler.rubygems.find_name('github_changelog_generator').any?
config.header = "# Change log\n\nAll notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org)."
config.add_pr_wo_labels = true
config.issues = false
config.merge_prefix = "### UNCATEGORIZED PRS; GO LABEL THEM"
config.merge_prefix = "### UNCATEGORIZED PRS; LABEL THEM ON GITHUB"
config.configure_sections = {
"Changed" => {
"prefix" => "### Changed",
"labels" => ["backwards-incompatible"],
},
"Added" => {
"prefix" => "### Added",
"labels" => ["feature", "enhancement"],
"labels" => ["enhancement", "feature"],
},
"Fixed" => {
"prefix" => "### Fixed",
"labels" => ["bugfix"],
"labels" => ["bug", "documentation", "bugfix"],
},
}
end
else
desc 'Generate a Changelog from GitHub'
task :changelog do
raise <<EOM
The changelog tasks depends on unreleased features of the github_changelog_generator gem.
The changelog tasks depends on recent features of the github_changelog_generator gem.
Please manually add it to your .sync.yml for now, and run `pdk update`:
---
Gemfile:
optional:
':development':
- gem: 'github_changelog_generator'
git: 'https://github.com/skywinder/github-changelog-generator'
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
version: '~> 1.15'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')"
EOM
end
end
Expand Down
10 changes: 10 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
---
mailhog::config: '-ui-bind-addr=127.0.0.1:8025 -api-bind-addr=127.0.0.1:8025'
mailhog::install_dir: '/usr/bin'
mailhog::install_method: 'package'
mailhog::manage_service: true
mailhog::manage_user: true
mailhog::package_name: 'mailhog'
mailhog::package_version: 'present'
mailhog::service_name: 'mailhog'
mailhog::service_ensure: 'running'
mailhog::service_provider: 'systemd'
2 changes: 2 additions & 0 deletions data/os/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
mailhog::config_file: '/etc/default/mailhog'
2 changes: 2 additions & 0 deletions data/os/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
mailhog::config_file: '/etc/sysconfig/mailhog'
4 changes: 2 additions & 2 deletions examples/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
# http://docs.puppetlabs.com/guides/tests_smoke.html
#
class { '::mailhog':
install_method => 'wget',
wget_source => 'https://github.com/mailhog/MailHog/releases/download/v0.2.1/MailHog_linux_amd64',
install_method => 'archive',
archive_source => 'https://github.com/mailhog/MailHog/releases/download/v1.0.1/MailHog_linux_amd64',
}
3 changes: 1 addition & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Class to configure mailhog.
#
# Dont include this class directly.
#
# @api private
class mailhog::config {
file { 'mailhog-config':
path => $::mailhog::config_file,
Expand Down
33 changes: 17 additions & 16 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,35 @@
# Use this module to install and configure mailhog.
#
# @example Declaring the class
# include ::mailhog
# class { '::mailhog':
# install_method => 'archive',
# archive_source => 'https://github.com/mailhog/MailHog/releases/download/v1.0.1/MailHog_linux_amd64',
# }
#
# @param config Mailhog config.
# @param config_file Mailhog config file.
# @param install_dir Location of mailhog binary release.
# @param install_method How to install mailhog.
# @param manage_service Manage the mailhog service.
# @param manage_user Manage mailhog user and group.
# @param package_name Name of package to install.
# @param package_version Version of mailhog to install.
# @param service_name Name of service to manage.
# @param service_provider Init system that is used.
# @param service_ensure The state of the service.
# @param wget_source Location of mailhog binary release.
# @param archive_source Location of mailhog binary release.
class mailhog (
String $config = $::mailhog::params::config,
String $config_file = $::mailhog::params::config_file,
String $install_dir = $::mailhog::params::install_dir,
Enum['package','wget'] $install_method = $::mailhog::params::install_method,
Boolean $manage_service = $::mailhog::params::manage_service,
Boolean $manage_user = $::mailhog::params::manage_user,
String $package_name = $::mailhog::params::package_name,
String $package_version = $::mailhog::params::package_version,
String $service_name = $::mailhog::params::service_name,
String $service_provider = $::mailhog::params::service_provider,
Enum['running','stopped'] $service_ensure = $::mailhog::params::service_ensure,
Optional[String] $wget_source = $::mailhog::params::wget_source,
) inherits mailhog::params {
String[1] $config ,
Stdlib::Absolutepath $config_file ,
Stdlib::Absolutepath $install_dir ,
Enum['package','archive'] $install_method,
Boolean $manage_service,
String[1] $package_name,
String[1] $package_version,
String[1] $service_name,
String[1] $service_provider,
Enum['running','stopped'] $service_ensure,
Optional[Stdlib::HTTPUrl] $archive_source = undef,
) {
anchor { 'mailhog::begin': }
-> class{ '::mailhog::install': }
-> class{ '::mailhog::config': }
Expand Down
12 changes: 4 additions & 8 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Class to install mailhog.
#
# Dont include this class directly.
#
# @api private
class mailhog::install {
case $::mailhog::install_method {
'package': {
Expand All @@ -10,16 +9,13 @@
name => $::mailhog::package_name,
}
}
'wget': {
'archive': {
file { 'mailhog install dir':
ensure => directory,
path => $::mailhog::install_dir,
}
-> wget::fetch { 'mailhog binary':
source => $::mailhog::wget_source,
destination => "${::mailhog::install_dir}/mailhog",
timeout => 0,
verbose => false,
-> archive { "${::mailhog::install_dir}/mailhog":
source => $::mailhog::archive_source,
}
-> file { 'mailhog binary':
group => 'root',
Expand Down
Loading

0 comments on commit 5dd81e7

Please sign in to comment.