summaryrefslogtreecommitdiff
path: root/roles/elevate/liquidtruth/tasks/mongodb.yml
blob: 77355f0f434dd2265f55fefd808dc5c56e884260 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
- name: create mongodb data directory
  file:
    name: /srv/mongodb
    state: directory

- name: create bind mount for mongodb
  mount:
    src: /srv/mongodb
    path: /var/lib/mongodb
    fstype: none
    opts: bind,defaults
    state: mounted

- name: install mongodb server
  apt:
    name:
      - mongodb
      - mongo-tools
      - python-pymongo
    state: present

# - name: check if admin user already exists
#   command: >
#     mongo --quiet -u root -p {{ liquidtruth_root_password }} --eval 'db.version()' admin
#   register: mongodb_root_user_check
#   changed_when: false
#   check_mode: no
#   ignore_errors: true
#   no_log: true

##
## $ mongo
## > use admin
## > db.createUser({ user: "root", pwd: "<secret>", roles: [ { role: "root", db: "admin" } ] })
## > db.createUser({ user: "backup", pwd: "<secret>", roles: [ { role: "backup", db: "admin" }, { role: "clusterMonitor", db: "admin" } ] })
## > db.createUser({ user: "lt", pwd: "<secret>", roles: [ { role: "dbOwner", db: "lt" } ] })
## > exit
##
## edit /etc/mongodb.conf: uncomment 'auth = true'
## Restart mongodb
##