summaryrefslogtreecommitdiff
path: root/puppet/modules/site_couchdb/manifests/stunnel.pp
blob: 484a0c00b1899c91917b8bc2396af64bd3876d4d (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
class site_couchdb::stunnel {

  $stunnel              = hiera('stunnel')
  $couchdb_config       = hiera('couch')
  $couchdb_bigcouch     = $couchdb_config['mode'] == "multimaster"

  $couch_server         = $stunnel['couch_server']
  $couch_server_accept  = $couch_server['accept']
  $couch_server_connect = $couch_server['connect']

  include site_config::x509::cert
  include site_config::x509::key
  include site_config::x509::ca

  if $couchdb_bigcouch {
    include site_couchdb::bigcouch::stunnel
  }

  include x509::variables
  $ca_path   = "${x509::variables::local_CAs}/${site_config::params::ca_name}.crt"
  $cert_path = "${x509::variables::certs}/${site_config::params::cert_name}.crt"
  $key_path  = "${x509::variables::keys}/${site_config::params::cert_name}.key"

  # setup a stunnel server for the webapp to connect to couchdb
  stunnel::service { 'couch_server':
    accept     => $couch_server_accept,
    connect    => $couch_server_connect,
    client     => false,
    cafile     => $ca_path,
    key        => $key_path,
    cert       => $cert_path,
    verify     => '2',
    pid        => '/var/run/stunnel4/couchserver.pid',
    rndfile    => '/var/lib/stunnel4/.rnd',
    debuglevel => '4',
    require    => [
      Class['Site_config::X509::Key'],
      Class['Site_config::X509::Cert'],
      Class['Site_config::X509::Ca'] ];
  }

  include site_check_mk::agent::stunnel
}