summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifests/add_user.pp4
-rw-r--r--manifests/create_db.pp1
-rw-r--r--manifests/query.pp5
-rw-r--r--manifests/update.pp5
4 files changed, 10 insertions, 5 deletions
diff --git a/manifests/add_user.pp b/manifests/add_user.pp
index 9c8e5d4..b3297eb 100644
--- a/manifests/add_user.pp
+++ b/manifests/add_user.pp
@@ -23,10 +23,12 @@ define couchdb::add_user ( $roles, $pw, $salt = '' ) {
$data = "{\"type\": \"user\", \"name\": \"${name}\", \"roles\": ${roles}, \"password_sha\": \"${sha}\", \"salt\": \"${salt}\"}"
}
+ # update the user with the given password unless they already work
couchdb::update { "update_user_${name}":
port => $port,
db => '_users',
id => "org.couchdb.user:${name}",
- data => $data
+ data => $data,
+ unless => "/usr/bin/curl -f ${name}:${pw}@127.0.0.1:${port}/"
}
}
diff --git a/manifests/create_db.pp b/manifests/create_db.pp
index 6a6d18f..91c4a1d 100644
--- a/manifests/create_db.pp
+++ b/manifests/create_db.pp
@@ -9,6 +9,7 @@ define couchdb::create_db ( $host='127.0.0.1:5984',
cmd => 'PUT',
host => $host,
url => $name,
+ unless => "/usr/bin/curl --netrc-file /etc/couchdb/couchdb.netrc ${host}/${name}"
}
couchdb::query { "db_security_${name}":
diff --git a/manifests/query.pp b/manifests/query.pp
index a02d068..6d13c2b 100644
--- a/manifests/query.pp
+++ b/manifests/query.pp
@@ -1,7 +1,8 @@
define couchdb::query (
- $cmd, $url, $host='127.0.0.1:5984', $data = '{}' ) {
+ $cmd, $url, $host='127.0.0.1:5984', $data = '{}', $unless = undef) {
exec { "/usr/bin/curl --netrc-file /etc/couchdb/couchdb.netrc -X ${cmd} ${host}/${url} --data \'${data}\'":
- require => [ Package['curl'], Exec['wait_for_couchdb'] ]
+ require => [ Package['curl'], Exec['wait_for_couchdb'] ],
+ unless => $unless
}
}
diff --git a/manifests/update.pp b/manifests/update.pp
index b7e6fc1..579659b 100644
--- a/manifests/update.pp
+++ b/manifests/update.pp
@@ -1,6 +1,7 @@
-define couchdb::update ($db, $id, $data, $port='5984') {
+define couchdb::update ($db, $id, $data, $port='5984', $unless=undef) {
exec { "couch-doc-update --port ${port} --db ${db} --id ${id} --data \'${data}\'":
- require => Exec['wait_for_couchdb']
+ require => Exec['wait_for_couchdb'],
+ unless => $unless
}
}