From a6d9c2dea3d67f7368fef373e96bfb0fda612851 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 16 Sep 2013 16:00:40 +0200 Subject: Revert "don't use couchdb::document for creating _security, cause this special doc doesn't have an _id (#3706)" This reverts commit dacaeb4d98be9468336923f5501822d389bda768. couch-doc-update and thus couchdb::document now also work for _security documents. We simply add the given _id when none is present in the existing doc. Using the normal saving of CouchRest::Document then works. --- manifests/create_db.pp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'manifests/create_db.pp') diff --git a/manifests/create_db.pp b/manifests/create_db.pp index 32bc974..690892c 100644 --- a/manifests/create_db.pp +++ b/manifests/create_db.pp @@ -4,6 +4,8 @@ define couchdb::create_db ( $readers="{\"names\": [], \"roles\": [] }" ) { + Couchdb::Query["create_db_${name}"] -> Couchdb::Document["${name}_security"] + couchdb::query { "create_db_${name}": cmd => 'PUT', host => $host, @@ -11,11 +13,10 @@ define couchdb::create_db ( unless => "/usr/bin/curl -s --netrc-file /etc/couchdb/couchdb.netrc ${host}/${name} | grep -q -v '{\"error\":\"not_found\"'" } - couchdb::query { "${name}_security": - cmd => 'PUT', - host => $host, - path => "${name}/_security", - data => "{ \"admins\": ${admins}, \"readers\": ${readers} }", - require => Couchdb::Query["create_db_${name}"] + couchdb::document { "${name}_security": + db => $name, + id => '_security', + host => $host, + data => "{ \"admins\": ${admins}, \"readers\": ${readers} }" } } -- cgit v1.2.3 From 1eff45c923e2ff196e3b52d1033185453358e047 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 20 Sep 2013 09:27:24 +0200 Subject: use require => rather than the -> syntax --- manifests/create_db.pp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'manifests/create_db.pp') diff --git a/manifests/create_db.pp b/manifests/create_db.pp index 690892c..9335e4b 100644 --- a/manifests/create_db.pp +++ b/manifests/create_db.pp @@ -4,8 +4,6 @@ define couchdb::create_db ( $readers="{\"names\": [], \"roles\": [] }" ) { - Couchdb::Query["create_db_${name}"] -> Couchdb::Document["${name}_security"] - couchdb::query { "create_db_${name}": cmd => 'PUT', host => $host, @@ -17,6 +15,7 @@ define couchdb::create_db ( db => $name, id => '_security', host => $host, - data => "{ \"admins\": ${admins}, \"readers\": ${readers} }" + data => "{ \"admins\": ${admins}, \"readers\": ${readers} }", + require => Couchdb::Query["create_db_${name}"] } } -- cgit v1.2.3