summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 9e7d87a8a91ce6c70d2600a2248c8fa618d8cca9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#
# stunnel puppet module
#
# Copyright 2009, Riseup Networks <micah@riseup.net>
#
#
# This program is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License version 3 as published by
# the Free Software Foundation.
#
# 1. include stunnel: this will automatically include stunnel::debian,
#    which automatically includes stunnel::linux, which automatically
#    includes stunnel::base
# 2. stunnel::client allows you to configure different /etc/stunnel/*.conf files
#    to provide various stunnel configurations

# TODO: warn on cert/key issues, fail on false accept?

class stunnel (
  $ensure_version = 'present',
  $startboot      = '1',
  $default_extra  = '',
  $cluster        = '' )
{

  case $::operatingsystem {
    debian: { class { 'stunnel::debian': } }
    centos: { class {  'stunnel::centos': } }
    default: { class { 'stunnel::default': } }
  }

  $stunnel_staging = "${::puppet_vardir}/stunnel4"
  $stunnel_compdir = "${stunnel_staging}/configs"

  file {
    [ $stunnel_staging, "${stunnel_staging}/bin" ]:
      ensure => directory,
      owner  => 0,
      group  => 0,
      mode   => '0750';

    "${stunnel_staging}/configs":
      ensure  => directory,
      owner   => 0,
      group   => 0,
      mode    => '0750',
      recurse => true,
      purge   => true,
      force   => true,
      source  => undef;

    "${stunnel_staging}/bin/refresh_stunnel.sh":
      owner   => 0,
      group   => 0,
      mode    => '0755',
      content => template('stunnel/refresh_stunnel.sh.erb');
  }

  exec { 'refresh_stunnel':
    command => "${stunnel_staging}/bin/refresh_stunnel.sh",
    require => [ Package['stunnel4'], File['/etc/default/stunnel4'] ]
  }
}