summaryrefslogtreecommitdiff
path: root/puppet/modules/site_couchdb/manifests/init.pp
blob: 3614661d21b327832acea02c9ac7fb894c9d1ab4 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
class site_couchdb {
  tag 'leap_service'

  $couchdb_config          = hiera('couch')
  $couchdb_users           = $couchdb_config['users']

  $couchdb_admin           = $couchdb_users['admin']
  $couchdb_admin_user      = $couchdb_admin['username']
  $couchdb_admin_pw        = $couchdb_admin['password']
  $couchdb_admin_salt      = $couchdb_admin['salt']

  $couchdb_leap_mx         = $couchdb_users['leap_mx']
  $couchdb_leap_mx_user    = $couchdb_leap_mx['username']
  $couchdb_leap_mx_pw      = $couchdb_leap_mx['password']
  $couchdb_leap_mx_salt    = $couchdb_leap_mx['salt']

  $couchdb_nickserver      = $couchdb_users['nickserver']
  $couchdb_nickserver_user = $couchdb_nickserver['username']
  $couchdb_nickserver_pw   = $couchdb_nickserver['password']
  $couchdb_nickserver_salt = $couchdb_nickserver['salt']

  $couchdb_soledad         = $couchdb_users['soledad']
  $couchdb_soledad_user    = $couchdb_soledad['username']
  $couchdb_soledad_pw      = $couchdb_soledad['password']
  $couchdb_soledad_salt    = $couchdb_soledad['salt']

  $couchdb_tapicero        = $couchdb_users['tapicero']
  $couchdb_tapicero_user   = $couchdb_tapicero['username']
  $couchdb_tapicero_pw     = $couchdb_tapicero['password']
  $couchdb_tapicero_salt   = $couchdb_tapicero['salt']

  $couchdb_webapp          = $couchdb_users['webapp']
  $couchdb_webapp_user     = $couchdb_webapp['username']
  $couchdb_webapp_pw       = $couchdb_webapp['password']
  $couchdb_webapp_salt     = $couchdb_webapp['salt']

  $couchdb_backup          = $couchdb_config['backup']

  $bigcouch_config         = $couchdb_config['bigcouch']
  $bigcouch_cookie         = $bigcouch_config['cookie']

  $ednp_port               = $bigcouch_config['ednp_port']

  class { 'couchdb':
    bigcouch            => true,
    admin_pw            => $couchdb_admin_pw,
    admin_salt          => $couchdb_admin_salt,
    bigcouch_cookie     => $bigcouch_cookie,
    ednp_port           => $ednp_port,
    chttpd_bind_address => '127.0.0.1'
  }

  # ensure that we don't have leftovers from previous installations
  # where we installed the cloudant bigcouch package
  # https://leap.se/code/issues/4971
  class { 'couchdb::bigcouch::package::cloudant':
    ensure => absent
  }

  Class['site_config::default']
    -> Class['couchdb::bigcouch::package::cloudant']
    -> Service['shorewall']
    -> Class['site_couchdb::stunnel']
    -> Service['couchdb']
    -> File['/root/.netrc']
    -> Class['site_couchdb::bigcouch::add_nodes']
    -> Class['site_couchdb::bigcouch::settle_cluster']
    -> Class['site_couchdb::create_dbs']
    -> Class['site_couchdb::add_users']

  # /etc/couchdb/couchdb.netrc is deployed by couchdb::query::setup
  # we symlink this to /root/.netrc for couchdb_scripts (eg. backup)
  # and makes life easier for the admin (i.e. using curl/wget without
  # passing credentials)
  file {
    '/root/.netrc':
      ensure  => link,
      target  => '/etc/couchdb/couchdb.netrc';

    '/srv/leap/couchdb':
      ensure => directory
  }

  couchdb::query::setup { 'localhost':
    user  => $couchdb_admin_user,
    pw    => $couchdb_admin_pw,
  }

  vcsrepo { '/srv/leap/couchdb/scripts':
    ensure   => present,
    provider => git,
    source   => 'https://leap.se/git/couchdb_scripts',
    revision => 'origin/master',
    require  => File['/srv/leap/couchdb']
  }

  include site_couchdb::stunnel
  include site_couchdb::bigcouch::add_nodes
  include site_couchdb::bigcouch::settle_cluster
  include site_couchdb::create_dbs
  include site_couchdb::add_users
  include site_couchdb::designs
  include site_couchdb::logrotate
  include site_couchdb::bigcouch::compaction

  if $couchdb_backup { include site_couchdb::backup }

  include site_shorewall::couchdb
  include site_shorewall::couchdb::bigcouch

  include site_check_mk::agent::couchdb
  include site_check_mk::agent::tapicero

  file { '/var/log/bigcouch':
    ensure => directory
  }

}