#
# === Authors
#
-# Author Name <author@domain.com>
+# Josh Farwell <jfarwell@linuxfoundation.org>
#
# === Copyright
#
-# Copyright 2015 Your name here, unless otherwise noted.
+# Copyright 2015 Josh Farwell, unless otherwise noted.
#
-class mailman3 {
+class mailman3 (
+ $install_mailman = $mailman3::params::install_mailman,
+ $mailman_version = $mailman3::params::version,
+ $override_options = {},
+ $override_secure_options = {},
+) inherits mailman3::params {
+ # Make sure parameters are properly formatted
+ validate_bool($install_mailman)
+ validate_string($mailman_version)
+ validate_hash($override_options)
+ validate_hash($override_secure_options)
+
+ # Merge our default options hash with overrides, right wins over left
+ $options = merge($mailman3::params::default_options, $override_options)
+
+ $secure_options = merge($mailman3::params::default_secure_options,
+ $override_secure_options)
+
+ anchor { 'mailman3::begin': }
+ anchor { 'mailman3::end': }
+
+ class { '::mailman3::install':
+ install_mailman => $install_mailman,
+ mailman_version => $mailman_version,
+ options => $options,
+ }
+
+ Anchor['mailman3::begin'] ->
+ Class['mailman3::install'] ->
+ Anchor['mailman3::end']
}
+# vim: ts=2 sw=2 sts=2 et :
--- /dev/null
+# == Class: mailman3
+#
+# Full description of class mailman3 here.
+#
+# === Parameters
+#
+# Document parameters here.
+#
+# [*sample_parameter*]
+# Explanation of what this parameter affects and what it defaults to.
+# e.g. "Specify one or more upstream ntp servers as an array."
+#
+# === Variables
+#
+# Here you should define a list of variables that this module would require.
+#
+# [*sample_variable*]
+# Explanation of how this variable affects the function of this class and if
+# it has a default. e.g. "The parameter enc_ntp_servers must be set by the
+# External Node Classifier as a comma separated list of hostnames." (Note,
+# global variables should be avoided in favor of class parameters as
+# of Puppet 2.6.)
+#
+# === Examples
+#
+# class { 'mailman3':
+# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
+# }
+#
+# === Authors
+#
+# Josh Farwell
+#
+# === Copyright
+#
+# Copyright 2015 Josh Farwell, unless otherwise noted.
+#
+class mailman3::install (
+ $install_mailman,
+ $mailman_version,
+ $options
+) {
+ validate_bool($install_mailman)
+ validate_string($mailman_version)
+ validate_hash($options)
+
+ # Install mailman3 yum repo - EL7 only at this time
+ yumrepo { 'fedorapeople-mailman3':
+ ensure => present,
+ name => 'fedorapeople-mailman3',
+ baseurl => 'https://repos.fedorapeople.org/repos/abompard/hyperkitty/el-7/x86_64/',
+ gpgcheck => 'no',
+ enabled => true,
+ }
+
+ # Install mailman core if we want to
+ # TODO: Split out into subclasses for each application component
+ if ($install_mailman) {
+ package { 'mailman3':
+ ensure => $mailman_version,
+ }
+ }
+
+}
+
+# vim: ts=2 sw=2 sts=2 et :
--- /dev/null
+# == Class: mailman3
+#
+# Full description of class mailman3 here.
+#
+# === Parameters
+#
+# Document parameters here.
+#
+# [*sample_parameter*]
+# Explanation of what this parameter affects and what it defaults to.
+# e.g. "Specify one or more upstream ntp servers as an array."
+#
+# === Variables
+#
+# Here you should define a list of variables that this module would require.
+#
+# [*sample_variable*]
+# Explanation of how this variable affects the function of this class and if
+# it has a default. e.g. "The parameter enc_ntp_servers must be set by the
+# External Node Classifier as a comma separated list of hostnames." (Note,
+# global variables should be avoided in favor of class parameters as
+# of Puppet 2.6.)
+#
+# === Examples
+#
+# class { 'mailman3':
+# servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
+# }
+#
+# === Authors
+#
+# Josh Farwell <jfarwell@linuxfoundation.org>
+#
+# === Copyright
+#
+# Copyright 2015 Josh Farwell, unless otherwise noted.
+#
+class mailman3::params {
+
+ # TODO: Strategy for organizing this manifest
+ # TODO: Secure_default_options hash
+ # Mangement Booleans
+ $install_mailman = false
+
+ # Mailman Core values
+ $mailman_version = 'installed' # could also be 3.0.0
+ $mailman_user = 'mailman'
+
+ # default options hash
+ $default_options = {
+ 'mailman' => {
+ 'user' => $mailman3::params::mailman_user,
+ },
+ }
+
+}
+# vim: ts=2 sw=2 sts=2 et :
require 'spec_helper'
-describe 'mailman3' do
+
+describe 'mailman3', :type => :class do
context 'with defaults for all parameters' do
- it { should contain_class('mailman3') }
+ it { is_expected.to contain_class('mailman3') }
+ it { is_expected.to contain_class('mailman3::params') }
+ it { is_expected.to contain_anchor('mailman3::begin') }
+ it { is_expected.to contain_class('mailman3::install') }
+ it { is_expected.to contain_anchor('mailman3::end') }
end
end
+
+# vim: ts=2 sw=2 sts=2 et :
--- /dev/null
+require 'spec_helper'
+
+describe 'mailman3::install', :type => :class do
+
+ # default parameters from params.pp
+ let(:params) {
+ {
+ 'install_mailman' => false,
+ 'mailman_version' => 'installed',
+ 'options' => {
+ 'mailman' => {
+ 'user' => 'mailman',
+ },
+ },
+ }
+ }
+
+ # since we don't have default parameters in the class,
+ # we should fail to compile if they're gone
+ context 'with defaults for all parameters' do
+ let (:params) {{}}
+
+ it do
+ expect {
+ should compile
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError,
+ /Must pass /)
+ end
+ end
+
+ # With good parameters
+ context 'with known good parameters' do
+
+ it { is_expected.to contain_yumrepo('fedorapeople-mailman3') }
+
+ # it will need to look for user, but not right now
+ #it { is_expected.to contain_user('mailman') }
+
+ # shouldn't install any packages without explicit flags
+ it do
+ expect {
+ should contain_package('mailman3')
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
+ end
+
+ # should install if the flags are set
+
+ it 'should have mailman if install_mailman is true' do
+ params.merge!({'install_mailman' => true})
+
+ should contain_package('mailman3')
+ end
+
+ end
+
+end
--- /dev/null
+require 'spec_helper'
+
+describe 'mailman3::params' do
+ context 'with defaults' do
+ it { is_expected.to contain_class('mailman3::params')}
+ end
+end
+
+# vim: ts=2 sw=2 sts=2 et :
--- /dev/null
+require 'spec_helper'
+
+at_exit { RSpec::Puppet::Coverage.report! }
+
+# vim: ts=2 sw=2 sts=2 et :
# Learn more about module testing here:
# http://docs.puppetlabs.com/guides/tests_smoke.html
#
-include mailman3
+
+#include mailman3
+class { 'mailman3': install_mailman => true }
+# vim: ts=2 sw=2 sts=2 et :