diff --git a/tasks/main.yml b/tasks/main.yml
index 2fa8b5ee714c149d9399b16a5aaa43bd733aa7aa..97844b6b6fae92780cd91d8f5582bdc52a02097f 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,16 +1,10 @@
-- name: install mongodb
-  apt:
-    pkg:
-      - mongodb-org
-
-- name: enable replication sets
+- name: copy mongodb config
   notify:
   - restart mongodb
   - start mongodb replication
-  lineinfile:
-    path: /etc/mongod.conf
-    regexp: "^#replication:"
-    line: "replication:\n  replSetName: rs01"
+  template:
+    dest: /etc/mongod.conf
+    src: mongod.conf.j2
 
 - name: start and enable mongodb
   systemd:
diff --git a/templates/mongod.conf.j2 b/templates/mongod.conf.j2
new file mode 100644
index 0000000000000000000000000000000000000000..64038b060deff4a3ef01d89dc37e591f24f08517
--- /dev/null
+++ b/templates/mongod.conf.j2
@@ -0,0 +1,44 @@
+# mongod.conf
+
+# for documentation of all options, see:
+#   http://docs.mongodb.org/manual/reference/configuration-options/
+
+# Where and how to store data.
+storage:
+  dbPath: /var/lib/mongodb
+  journal:
+    enabled: true
+#  engine:
+#  mmapv1:
+#  wiredTiger:
+
+# where to write logging data.
+systemLog:
+  destination: file
+  logAppend: true
+  path: /var/log/mongodb/mongod.log
+
+# network interfaces
+net:
+  port: 27017
+  bindIp: 127.0.0.1
+
+
+# how the process runs
+processManagement:
+  timeZoneInfo: /usr/share/zoneinfo
+
+#security:
+
+#operationProfiling:
+
+replication:
+  replSetName: rs01
+
+#sharding:
+
+## Enterprise-Only Options:
+
+#auditLog:
+
+#snmp:
diff --git a/vars/main.yml b/vars/main.yml
index 2256e1a5d1df576f5f7587483e3fe5daecbaa582..8b05881711371677421a75a3913169ab5d2e789b 100644
--- a/vars/main.yml
+++ b/vars/main.yml
@@ -1,4 +1,6 @@
 packages:
+  pkgs:
+    "mongodb-org": {}
   repos:
     mongodb:
       url: "deb http://repo.mongodb.org/apt/debian {{ ansible_distribution_release|lower }}/mongodb-org/{{ mongodb.version }} main"