Commit aa4e7898 authored by mh's avatar mh
Browse files

make it possible to tune options + tests

parent f63438a5
*.lock
spec/fixtures
.librarian
source 'https://rubygems.org'
if ENV.key?('PUPPET_VERSION')
puppetversion = "~> #{ENV['PUPPET_VERSION']}"
else
puppetversion = ['~> 3.7.5']
end
if RUBY_VERSION == '1.8.7'
gem 'i18n', '~> 0.6.11'
gem 'activesupport', '~> 3.2'
gem 'librarian-puppet', '~> 1.0.0'
else
gem 'librarian-puppet', '>=0.9.10'
end
gem 'puppet', puppetversion
gem 'puppet-lint', '>=0.3.2'
gem 'puppetlabs_spec_helper', '>=0.2.0'
gem 'rake', '>=0.9.2.2'
# We take the dependencies directly from github
mod 'stdlib', :git => 'https://github.com/puppetlabs/puppetlabs-stdlib'
require 'bundler'
Bundler.require(:rake)
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"]
PuppetLint.configuration.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}'
PuppetLint.configuration.send("disable_class_inherits_from_params_class")
# use librarian-puppet to manage fixtures instead of .fixtures.yml
# offers more possibilities like explicit version management, forge downloads,...
task :librarian_spec_prep do
sh "librarian-puppet install --path=spec/fixtures/modules/"
pwd = `pwd`.strip
unless File.directory?("#{pwd}/spec/fixtures/modules/imapproxy")
sh "ln -s #{pwd} #{pwd}/spec/fixtures/modules/imapproxy"
end
end
task :spec_prep => :librarian_spec_prep
task :default => [:spec, :lint]
## imapproxy.conf
##
## This is the global configuration file for imapproxy.
## Lines beginning with a '#' sign are treated as comments and will be
## ignored. Each line to be processed must be a space delimited
## keyword/value pair.
##
#
## server_hostname
##
## This setting controls which imap server we proxy our connections to.
#
server_hostname your.imap.server.com
#
## cache_size
##
## This setting determines how many in-core imap connection structures
## will be allocated. As such, it determines not only how many cached
## connections will be allowed, but really the total number of simultaneous
## connections, cached and active.
#
cache_size 3072
#
## listen_port
##
## This setting specifies which port the proxy server will bind to and
## accept incoming connections from.
#
listen_port 143
#
## listen_address
##
## This setting specifies which address the proxy server will bind to and
## accept incoming connections to. If undefined, bind to all.
## Must be a dotted decimal IP address.
#
#listen_address 127.0.0.1
#
## server_port
##
## This setting specifies the port that server_hostname is listening on.
## This is the tcp port that we proxy inbound connections to.
#
server_port 143
#
## cache_expiration_time
##
## This setting controls how many seconds an inactive connection will be
## cached.
#
cache_expiration_time 300
#
## proc_username
##
## This setting controls which username the imap proxy process will run as.
## It is not allowed to run as "root".
#
proc_username nobody
#
## proc_groupname
##
## This setting controls which groupname the imap proxy process will run as.
#
proc_groupname nobody
#
## stat_filename
##
## This is the path to the filename that the proxy server mmap()s to
## write statistical data to. This is the file that pimpstat needs to
## look at to be able to provide his useful stats.
#
stat_filename /var/run/pimpstats
#
## protocol_log_filename
##
## protocol logging may only be turned on for one user at a time. All
## protocol logging data is written to the file specified by this path.
#
protocol_log_filename /var/log/imapproxy_protocol.log
#
## syslog_facility
##
## The logging facility to be used for all syslog calls. If nothing is
## specified here, it will default to LOG_MAIL. Any of the possible
## facilities listed in the syslog(3C) manpage may be used here except
## LOG_KERN.
#
syslog_facility LOG_MAIL
#
## syslog_prioritymask
##
## This configuration option is provided as a way to limit the verbosity
## of imapproxy. If no value is specified, it will default to no priority
## mask and you'll see all possible log messages. Any of the possible
## priority values listed in the syslog(3C) manpage may be used here.
## By default, I've left this commented out so you will see all possible
## log messages.
#
#syslog_prioritymask LOG_WARNING
#
## send_tcp_keepalives
##
## This determines whether the SO_KEEPALIVE option will be set on all
## sockets.
#
send_tcp_keepalives no
#
## enable_select_cache
##
## This configuration option allows you to turn select caching on or off.
## When select caching is enabled, up-imapproxy will cache SELECT responses
## from an imap server.
#
enable_select_cache no
#
## foreground_mode
##
## This will prevent imapproxy from detaching from his parent process and
## controlling terminal on startup.
#
foreground_mode no
#
## force_tls
##
## Force imapproxy to use STARTTLS even if LOGIN is not disabled.
#
force_tls no
#
## chroot_directory
##
## This allows imapproxy to run in a chroot jail if desired.
## If commented out, imapproxy will not run chroot()ed. If
## a directory is specified here, imapproxy will chroot() to that
## directory.
#
#chroot_directory /var/empty
#
## enable_admin_commands
##
## Used to enable or disable the internal imapproxy administrative commands.
#
enable_admin_commands no
#
## Various path options for SSL CA certificates/directories
#
#tls_ca_file /usr/share/ssl/certs/ca-bundle.crt
#tls_ca_path /usr/share/ssl/certs/
#tls_cert_file /usr/share/ssl/certs/mycert.crt
#tls_key_file /usr/share/ssl/certs/mycert.key
\ No newline at end of file
......@@ -3,14 +3,12 @@ class imapproxy::base {
package {'up-imapproxy':
ensure => present,
} -> file{'/etc/imapproxy.conf':
source => [ "puppet:///modules/site_imapproxy/${::fqdn}/imapproxy.conf",
'puppet:///modules/site_imapproxy/imapproxy.conf',
'puppet:///modules/imapproxy/imapproxy.conf' ],
owner => root,
group => 0,
mode => '0644';
} ~> service {'imapproxy':
}
$options = keys($imapproxy::real_options)
imapproxy::config_options{
$options:;
}
service {'imapproxy':
ensure => running,
enable => true,
}
......
# manage a config_option
define imapproxy::config_option(
$value,
){
file_line{
"imapproxy_${name}":
line => "${name} ${value}",
path => '/etc/imapproxy.conf',
match => "^(#)?${name} ",
require => Package['up-imapproxy'],
notify => Service['imapproxy'],
}
}
# manage the options
define imapproxy::config_options() {
include ::imapproxy
imapproxy::config_option{
$name:
value => $imapproxy::real_options[$name],
}
}
......@@ -2,12 +2,23 @@
# Copyright (C) 2007 admin@immerda.ch
# GPLv3
#
# install and manage imapproxy
class imapproxy (
$merged_options = hiera_hash('imapproxy::options',{}),
$manage_shorewall = false,
$manage_monit = false,
) {
$default_options = {
'server_hostname' => "imap.${::domain}",
'listen_address' => '127.0.0.1',
'enable_select_cache' => 'yes',
'force_tls' => 'yes',
'chroot_directory' => '/var/empty',
'tls_ca_path' => '/etc/ssl/certs/',
}
$real_options = merge($default_options,$merged_options)
case $::operatingsystem {
gentoo: { include imapproxy::gentoo }
default: { include imapproxy::base }
......
require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
describe 'imapproxy', :type => 'class' do
context 'with default params' do
it { should compile.with_all_deps }
end
end
require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper'))
describe 'imapproxy::config_option', :type => 'define' do
let(:title){'server_hostname'}
let(:params){
{
:value => 'imap.example.com',
}
}
context 'with default params' do
it { should contain_file_line('imapproxy_server_hostname').with(
:path => '/etc/imapproxy.conf',
:line => 'server_hostname imap.example.com',
:match => '^(#)?server_hostname ',
:require => 'Package[up-imapproxy]',
:notify => 'Service[imapproxy]',
)}
end
end
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rake'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
puts c.pattern
c.pattern = FileList[c.pattern].exclude(/^spec\/fixtures/)
puts c.pattern
end
Puppet::Util::Log.level = :warning
Puppet::Util::Log.newdestination(:console)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment