create dist tarball first and then run "make all check" from dist tarball
diff --git a/ansible/roles/ubuntu-worker/files/build-ci.sh b/ansible/roles/ubuntu-worker/files/build-ci.sh
index f6fe18a..db6993e 100755
--- a/ansible/roles/ubuntu-worker/files/build-ci.sh
+++ b/ansible/roles/ubuntu-worker/files/build-ci.sh
@@ -19,8 +19,18 @@
 
 set -e
 
-cd /usr/src/couchdb
+# create a distribution tarball from the current git master branch
+cd /usr/src/couchdb-checkout
 git reset --hard
 git pull
 ./configure --with-curl
-make all check dist
+make dist
+
+# use the created tarball to build CouchDB and run tests
+cp apache-couchdb-*.tar.gz /usr/src/couchdb
+
+cd /usr/src/couchdb
+tar -xf apache-couchdb-*.tar.gz
+cd apache-couchdb-*
+./configure --with-curl
+make all check
diff --git a/ansible/roles/ubuntu-worker/tasks/couchdb.yml b/ansible/roles/ubuntu-worker/tasks/couchdb.yml
index 047b5bc..c87ab5b 100644
--- a/ansible/roles/ubuntu-worker/tasks/couchdb.yml
+++ b/ansible/roles/ubuntu-worker/tasks/couchdb.yml
@@ -36,12 +36,31 @@
 - name: get CouchDB sources from git
   git:
     repo: git://git.apache.org/couchdb.git
-    dest: /usr/src/couchdb
+    dest: /usr/src/couchdb-checkout
     accept_hostkey: yes
     force: yes
     # which branch/tag do we actually want to build? I'd say master.
     # version: developer-preview-2.0
 
+- name: set permissions on couchdb build
+  file:
+    path: /usr/src/couchdb-checkout
+    state: directory
+    owner: couchdb
+    group: couchdb
+    recurse: yes
+
+# 1) `make dist` will be run in /usr/src/couchdb-checkout (this is directly
+#     pulled from git
+# 2) the resulting tarball will be extracted to /usr/src/couchdb, where
+#    `make all check` is run.
+- name: create directory for make check all
+  file:
+    path: /usr/src/couchdb
+    state: directory
+    owner: couchdb
+    group: couchdb
+
 - name: copy build script
   copy:
     src: build-ci.sh
@@ -49,11 +68,3 @@
     owner: couchdb
     group: couchdb
     mode: 0755
-
-- name: set permissions on couchdb build
-  file:
-    path: /usr/src/couchdb
-    state: directory
-    owner: couchdb
-    group: couchdb
-    recurse: yes