summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2013-03-12 16:02:56 +0100
committervarac <varacanero@zeromail.org>2013-03-12 16:02:56 +0100
commit7c9462a0fab1c6e499b62caa2093dedfa9c8adc8 (patch)
tree88d78a236361b4ac596efcc91aa2f387d6c2dd48
parent546350d6f6e83e9ea22db79d07bdc38c694fbcdb (diff)
Added Exec[wait_for_couchdb]
So Couchdb::Query and Couchdb::Update doesn't try to connect to couchdb before it is up and running. That fixes a nasty race condition, see Fix doc update error on puppetrun (Feature #1964).
-rw-r--r--manifests/base.pp10
-rw-r--r--manifests/query.pp2
-rw-r--r--manifests/update.pp4
3 files changed, 13 insertions, 3 deletions
diff --git a/manifests/base.pp b/manifests/base.pp
index 45d991b..7afe1a0 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -16,10 +16,18 @@ class couchdb::base {
ensure => running,
hasstatus => true,
enable => true,
- require => Package['couchdb'],
+ require => Package['couchdb']
+ }
+
+ # todo: make host/port configurable
+ exec {'wait_for_couchdb':
+ command => 'wget --retry-connrefused --tries 10 --quiet "http://127.0.0.1:5984" -O /dev/null',
+ require => Service['couchdb']
}
# required for couch-doc-update script
+
+
package { 'couchrest':
ensure => installed,
provider => 'gem'
diff --git a/manifests/query.pp b/manifests/query.pp
index 2870984..d912278 100644
--- a/manifests/query.pp
+++ b/manifests/query.pp
@@ -1,5 +1,5 @@
define couchdb::query ( $cmd, $url, $host='127.0.0.1:5984', $data = '' ) {
exec { "/usr/bin/curl --netrc-file /etc/couchdb/couchdb.netrc -X $cmd $host/$url --data \'$data\'":
- require => Package['curl']
+ require => [ Package['curl'], Exec['wait_for_couchdb'] ]
}
}
diff --git a/manifests/update.pp b/manifests/update.pp
index 3cb6ece..7e7be66 100644
--- a/manifests/update.pp
+++ b/manifests/update.pp
@@ -1,3 +1,5 @@
define couchdb::update ($db, $id, $data, $port='5984') {
- exec { "couch-doc-update --port $port --db $db --id $id --data \'$data\'": }
+ exec { "couch-doc-update --port $port --db $db --id $id --data \'$data\'":
+ require => Exec['wait_for_couchdb']
+ }
}