summaryrefslogtreecommitdiff
path: root/puppet/modules/couchdb/manifests/create_db.pp
blob: 8a8d1144a3ca0c1607eeb2d6a61a1546deac984e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
define couchdb::create_db (
  $host='127.0.0.1:5984',
  $admins="{\"names\": [], \"roles\": [] }",
  $members="{\"names\": [], \"roles\": [] }" )
{

  couchdb::query { "create_db_${name}":
    cmd    => 'PUT',
    host   => $host,
    path   => $name,
    unless => "/usr/bin/curl -s -f --netrc-file /etc/couchdb/couchdb.netrc ${host}/${name}"
  }

  couchdb::document { "${name}_security":
    db   => $name,
    id   => '_security',
    host => $host,
    data => "{ \"admins\": ${admins}, \"members\": ${members} }",
    require => Couchdb::Query["create_db_${name}"]
  }
}