diff options
-rw-r--r-- | files/couch-doc-update | 2 | ||||
-rw-r--r-- | manifests/document.pp | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/files/couch-doc-update b/files/couch-doc-update index 3cdf6ce..f448046 100644 --- a/files/couch-doc-update +++ b/files/couch-doc-update @@ -51,7 +51,7 @@ def main end usage("Missing required option") unless @db_name && @doc_id && @new_data @new_data = JSON.parse(@new_data) - + # # update document # diff --git a/manifests/document.pp b/manifests/document.pp index afbd37a..77296dc 100644 --- a/manifests/document.pp +++ b/manifests/document.pp @@ -5,7 +5,12 @@ # ensure => {absent,present,*content*} # } # -define couchdb::document ( $host='127.0.0.1:5984', $db, $id, $data='{}', $ensure='content') { +define couchdb::document( + $db, + $id, + $host = '127.0.0.1:5984', + $data = '{}', + $ensure = 'content') { $url = "${host}/${db}/${id}" @@ -20,18 +25,18 @@ define couchdb::document ( $host='127.0.0.1:5984', $db, $id, $data='{}', $ensure present: { couchdb::query { "create_${db}_${id}": - cmd => 'PUT', - host => $host, - path => "${db}/${id}", + cmd => 'PUT', + host => $host, + path => "${db}/${id}", unless => "/usr/bin/curl --netrc-file /etc/couchdb/couchdb.netrc ${url}" } } absent: { couchdb::query { "destroy_${db}_${id}": - cmd => 'DELETE', - host => $host, - path => "${db}/${id}", + cmd => 'DELETE', + host => $host, + path => "${db}/${id}", onlyif => "/usr/bin/curl --netrc-file /etc/couchdb/couchdb.netrc ${url}" } } |