summaryrefslogtreecommitdiff
path: root/puppet/modules/site_couchdb/manifests/create_dbs.pp
blob: a2d1c655072158d3fff9cce1a465967990efa66f (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
# creates neccesary databases
class site_couchdb::create_dbs {

  Class['site_couchdb::setup']
    -> Class['site_couchdb::create_dbs']

  ### customer database
  ### r/w: webapp,
  couchdb::create_db { 'customers':
    members => "{ \"names\": [\"${site_couchdb::couchdb_webapp_user}\"], \"roles\": [\"replication\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## identities database
  ## r: nickserver, leap_mx - needs to be restrict with design document
  ## r/w: webapp
  couchdb::create_db { 'identities':
    members => "{ \"names\": [], \"roles\": [\"replication\", \"identities\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## keycache database
  ## r/w: nickserver
  couchdb::create_db { 'keycache':
    members => "{ \"names\": [], \"roles\": [\"replication\", \"keycache\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## sessions database
  ## r/w: webapp
  $sessions_db = rotated_db_name('sessions', 'monthly')
  couchdb::create_db { $sessions_db:
    members => "{ \"names\": [\"${site_couchdb::couchdb_webapp_user}\"], \"roles\": [\"replication\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  $sessions_next_db = rotated_db_name('sessions', 'monthly', 'next')
  couchdb::create_db { $sessions_next_db:
    members => "{ \"names\": [\"${site_couchdb::couchdb_webapp_user}\"], \"roles\": [\"replication\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## shared database
  ## r/w: soledad
  couchdb::create_db { 'shared':
    members => "{ \"names\": [\"${site_couchdb::couchdb_soledad_user}\"], \"roles\": [\"replication\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## tickets database
  ## r/w: webapp
  couchdb::create_db { 'tickets':
    members => "{ \"names\": [\"${site_couchdb::couchdb_webapp_user}\"], \"roles\": [\"replication\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## tokens database
  ## r: soledad - needs to be restricted with a design document
  ## r/w: webapp
  $tokens_db = rotated_db_name('tokens', 'monthly')
  couchdb::create_db { $tokens_db:
    members => "{ \"names\": [], \"roles\": [\"replication\", \"tokens\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  $tokens_next_db = rotated_db_name('tokens', 'monthly', 'next')
  couchdb::create_db { $tokens_next_db:
    members => "{ \"names\": [], \"roles\": [\"replication\", \"tokens\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## users database
  ## r/w: webapp
  couchdb::create_db { 'users':
    members => "{ \"names\": [], \"roles\": [\"replication\", \"users\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## tmp_users database
  ## r/w: webapp
  couchdb::create_db { 'tmp_users':
    members => "{ \"names\": [], \"roles\": [\"replication\", \"users\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## messages db
  ## store messages to the clients such as payment reminders
  ## r/w: webapp
  couchdb::create_db { 'messages':
    members => "{ \"names\": [\"${site_couchdb::couchdb_webapp_user}\"], \"roles\": [\"replication\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

  ## invite_codes db
  ## store invite codes for new signups
  ## r/w: webapp
  couchdb::create_db { 'invite_codes':
    members => "{ \"names\": [\"${site_couchdb::couchdb_webapp_user}\"], \"roles\": [\"replication\"] }",
    require => Couchdb::Query::Setup['localhost']
  }

}