--- /dev/null
+# == Class: mailman3::core
+#
+# 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::core (
+ $install_mailman = $mailman3::params::install_mailman,
+ $mailman_version = $mailman3::params::version,
+) inherits mailman3::params {
+
+ # Make sure parameters are properly formatted
+ validate_bool($install_mailman)
+ validate_string($mailman_version)
+
+ anchor { 'mailman3::core::begin': }
+ anchor { 'mailman3::core::end': }
+
+ class { '::mailman3::core::install':
+ install_mailman => $install_mailman,
+ mailman_version => $mailman_version,
+ }
+
+ #class { '::mailman3::core::config':
+ #default_secure_options => $mailman3::params::default_secure_options,
+ #manage_database => $manage_database,
+ #manage_firewall => $manage_firewall,
+ #options => $options,
+ #override_secure_options => $override_secure_options,
+ #}
+
+ Anchor['mailman3::core::begin'] ->
+ Class['mailman3::core::install'] ->
+ #Class['mailman3::core::config'] ->
+ Anchor['mailman3::core::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::core::install (
+ $install_mailman,
+ $mailman_version,
+) {
+ validate_bool($install_mailman)
+ validate_string($mailman_version)
+
+ if ($install_mailman) {
+
+ include mailman3::repo
+
+ package { 'mailman3':
+ ensure => $mailman_version,
+ require => Class['::mailman3::repo']
+ }
+
+ }
+
+}
+
+# vim: ts=2 sw=2 sts=2 et :
#
# Copyright 2015 Josh Farwell, unless otherwise noted.
#
-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']
-
+class mailman3 {
+ fail "This module's base class cannot be called directly."
}
-# vim: ts=2 sw=2 sts=2 et :
# TODO: Strategy for organizing this manifest
# TODO: Secure_default_options hash
# Mangement Booleans
- $install_mailman = false
+ $install_mailman = true
# Mailman Core values
- $mailman_version = 'installed' # could also be 3.0.0
- $mailman_user = 'mailman'
+ $mailman_version = 'installed' # could also be 3.0.0
+ $site_owner = undef
# default options hash
$default_options = {
- 'mailman' => {
- 'user' => $mailman3::params::mailman_user,
+ 'core' => {
+ 'site_owner' => $mailman3::params::site_owner_email,
},
}
-# == Class: mailman3
+# == Class: mailman3::repo
#
# Full description of class mailman3 here.
#
#
# === Authors
#
-# Josh Farwell
+# Josh Farwell <jfarwell@linuxfoundation.org>
#
# === 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)
+class mailman3::repo {
- # Install mailman3 yum repo - EL7 only at this time
yumrepo { 'fedorapeople-mailman3':
ensure => present,
name => 'fedorapeople-mailman3',
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,
- require => Yumrepo['fedorapeople-mailman3'],
- }
-
- }
-
}
-
-# vim: ts=2 sw=2 sts=2 et :
--- /dev/null
+require 'spec_helper'
+
+describe 'mailman3::core::install', :type => :class do
+
+ # default parameters from params.pp
+ let(:params) {
+ {
+ 'install_mailman' => true,
+ 'mailman_version' => 'installed',
+ }
+ }
+
+ # 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 { is_expected.to_not compile }
+ end
+
+ # With good parameters, we should include repo install packages by default
+ context 'with known good parameters' do
+ it { is_expected.to contain_package('mailman3') }
+ it { is_expected.to contain_class('mailman3::repo') }
+ it { is_expected.to contain_yumrepo('fedorapeople-mailman3') }
+ end
+
+ context 'with install flags disabled' do
+
+ # should not install if the flags are set
+ let(:params) {
+ {
+ 'install_mailman' => false,
+ 'mailman_version' => 'installed',
+ }
+ }
+
+ it { is_expected.to_not contain_package('mailman3') }
+ it { is_expected.to_not contain_class('mailman3::repo') }
+ it { is_expected.to_not contain_yumrepo('fedorapeople-mailman3') }
+
+ end
+
+end
--- /dev/null
+require 'spec_helper'
+
+describe 'mailman3::core', :type => :class do
+
+ context 'with defaults for all parameters' do
+ it { is_expected.to contain_class('mailman3::core') }
+ it { is_expected.to contain_class('mailman3::params') }
+ it { is_expected.to contain_anchor('mailman3::core::begin') }
+ it { is_expected.to contain_class('mailman3::core::install') }
+ it { is_expected.to contain_anchor('mailman3::core::end') }
+ end
+end
+
+# vim: ts=2 sw=2 sts=2 et :
describe 'mailman3', :type => :class do
context 'with defaults for all parameters' do
- 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') }
+ it do
+ expect {
+ should compile
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError,
+ /This module's base class cannot be called directly./)
+ end
end
end
+++ /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').that_requires('Yumrepo[fedorapeople-mailman3]')
- end
-
- end
-
-end
--- /dev/null
+require 'spec_helper'
+
+describe 'mailman3::repo', :type => :class do
+
+ it { is_expected.to contain_yumrepo('fedorapeople-mailman3') }
+
+end