From 8a0f585cbdb8f54d495f636e36b812a3d5b8b804 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 15 Aug 2013 12:52:45 +0200 Subject: use couchdb::document to create bigcouch node config (feature #3485) fixes the use of couch-doc-update with non standart hosts replaces couchdb::bigcouch::query with couchdb::bigcouch::document --- files/couch-doc-update | 6 ++++-- manifests/bigcouch/add_node.pp | 7 ++++--- manifests/bigcouch/document.pp | 9 +++++++++ manifests/bigcouch/query.pp | 10 ---------- manifests/document.pp | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 manifests/bigcouch/document.pp delete mode 100644 manifests/bigcouch/query.pp diff --git a/files/couch-doc-update b/files/couch-doc-update index e4adfbe..3cdf6ce 100644 --- a/files/couch-doc-update +++ b/files/couch-doc-update @@ -35,7 +35,7 @@ def main # # parse options # - @host = "127.0.0.1:5984" + @host = nil @db_name = nil @doc_id = nil @new_data = nil @@ -102,12 +102,14 @@ def connection_string(database, host) netrc.scan(/\w+ [\w\.]+/).each do |key_value| key, value = key_value.split ' ' case key - when "machine" then host = value + ':' + port + when "machine" then host ||= value + ':' + port when "login" then username = value when "password" then password = value end end + host ||= '127.0.0.1:5984' + "%s://%s:%s@%s/%s" % [protocol, username, password, host, database] end diff --git a/manifests/bigcouch/add_node.pp b/manifests/bigcouch/add_node.pp index 66ac9b6..ed9db94 100644 --- a/manifests/bigcouch/add_node.pp +++ b/manifests/bigcouch/add_node.pp @@ -1,7 +1,8 @@ define couchdb::bigcouch::add_node { - couchdb::bigcouch::query { "add_${name}": - cmd => 'PUT', - path => "nodes/bigcouch@${name}" + couchdb::bigcouch::document { "add_${name}": + db => 'nodes', + id => "bigcouch@${name}", + ensure => 'present' } } diff --git a/manifests/bigcouch/document.pp b/manifests/bigcouch/document.pp new file mode 100644 index 0000000..f72f205 --- /dev/null +++ b/manifests/bigcouch/document.pp @@ -0,0 +1,9 @@ +define couchdb::bigcouch::document ( $host='127.0.0.1:5986', $db, $id, $data='{}', $ensure='content') { + couchdb::document { "${name}": + host => $host, + db => $db, + id => $id, + data => $data, + ensure => $ensure + } +} diff --git a/manifests/bigcouch/query.pp b/manifests/bigcouch/query.pp deleted file mode 100644 index 8228e82..0000000 --- a/manifests/bigcouch/query.pp +++ /dev/null @@ -1,10 +0,0 @@ -define couchdb::bigcouch::query ( - $cmd, $path, $host='127.0.0.1:5986', $data = '{}' ) { - - couchdb::query { "${name}": - cmd => $cmd, - host => $host, - path => $path, - data => $data - } -} diff --git a/manifests/document.pp b/manifests/document.pp index 1b27d44..afbd37a 100644 --- a/manifests/document.pp +++ b/manifests/document.pp @@ -5,7 +5,7 @@ # ensure => {absent,present,*content*} # } # -define couchdb::document ( $host='127.0.0.1:5984', $db, $id, $data, $ensure='content') { +define couchdb::document ( $host='127.0.0.1:5984', $db, $id, $data='{}', $ensure='content') { $url = "${host}/${db}/${id}" -- cgit v1.2.3