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

  $x509                       = hiera('x509')
  $key                        = $x509['key']
  $cert                       = $x509['cert']
  $adminpw                    = hiera('couchdb_adminpw')
  $couchdb_leap_web_user      = hiera('couchdb_leap_web_user')
  $couchdb_leap_web_username  = $couchdb_leap_web_user['user']
  $couchdb_leap_web_pw        = $couchdb_leap_web_user['pw']
  $couchdb_leap_ca_user       = hiera('couchdb_leap_ca_user')
  $couchdb_leap_ca_username   = $couchdb_leap_ca_user['user']
  $couchdb_leap_ca_pw         = $couchdb_leap_ca_user['pw']
  $couchdb_host               = "admin:$adminpw@127.0.0.1:5984"

  Class['site_couchdb::package']
    -> Package ['couchdb']
    -> File['/etc/init.d/couchdb']
    -> File['/etc/couchdb/local.ini']
    -> File['/etc/couchdb/local.d/admin.ini']
    -> Couchdb::Create_db[leap_web]
    -> Couchdb::Create_db[leap_ca]
    -> Couchdb::Add_user[leap_web]
    -> Couchdb::Add_user[leap_ca]
    -> Site_couchdb::Apache_ssl_proxy['apache_ssl_proxy']

  include site_couchdb::package
  include site_couchdb::configure
  include couchdb::deploy_config

  site_couchdb::apache_ssl_proxy { 'apache_ssl_proxy':
    key   => $key,
    cert  => $cert
  }

  couchdb::add_user { $couchdb_leap_web_username:
    host  => $couchdb_host,
    roles => '["certs"]',
    pw    => $couchdb_leap_web_pw
  }

  couchdb::add_user { $couchdb_leap_ca_username:
    host  => $couchdb_host,
    roles => '["certs"]',
    pw    => $couchdb_leap_ca_pw
  }

  couchdb::create_db { 'leap_web':
    host    => $couchdb_host,
    readers => "{ \"names\": [\"leap_web\"], \"roles\": [] }"
  }

  couchdb::create_db { 'leap_ca':
    host    => $couchdb_host,
    readers => "{ \"names\": [], \"roles\": [\"certs\"] }"
  }
}