aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/database/tasks/mongodb_config.yml
blob: 3e7fe5f7a7edd1fe0bc7e86b1d8c34329c7afa04 (plain)
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
43
44
45
46
47
---
- name: copy mongo js
  template:
    src: '{{ item.src }}'
    dest: '{{ item.dest }}'
  with_items:
    - src: replica.js
      dest: /opt/replica.js

- name: init replica servers
  shell: mongo compass /opt/replica.js

- name: wait replica servers are ready
  shell: mongo compass --eval 'printjson(rs.status())'|grep -E 'PRIMARY|SECONDARY'|wc -l
  register: servers
  until: servers.stdout|int == {{ haproxy_hosts|length }}
  retries: 60
  delay: 10

- debug: msg='{{ servers.stdout |int }}'

- name: wait replica servers are ready
  shell: mongo compass --eval 'printjson(rs.status())'|grep -E 'PRIMARY'|wc -l
  register: servers
  until: servers.stdout|int == 1
  retries: 60
  delay: 10

- debug: msg='{{ servers.stdout |int }}'

- name: create mongodb user and db
  mongodb_user:
    login_host: "{{ internal_vip.ip }}"
    database: ceilometer
    name: ceilometer
    password: "{{ CEILOMETER_DBPASS }}"
    roles: 'readWrite,dbAdmin'
    state: present

- name: grant user privilege
  mongodb_user:
    login_host: "{{ internal_vip.ip }}"
    database: ceilometer
    name: ceilometer
    password: "{{ CEILOMETER_DBPASS }}"
    roles: 'readWrite,dbAdmin'
    state: present