summaryrefslogtreecommitdiff
path: root/test/integration/targets/mongodb_replicaset/tasks/mongod_replicaset.yml
blob: f33d93f4ac250832239fcffd7ad85374b1b95064 (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
- name: Set mongodb_user user for redhat
  set_fact:
    mongodb_user: "mongod"
  when: ansible_os_family == "RedHat"

- name: Create directories for mongod processes
  file:
    path: "{{ remote_tmp_dir }}/mongod{{ item }}"
    state: directory
    owner: "{{ mongodb_user }}"
    group: "{{ mongodb_user }}"
    mode: 0755
    recurse: yes
  with_items: "{{ mongodb_nodes }}"

- name: Create keyfile
  copy:
    dest: "{{ remote_tmp_dir }}/my.key"
    content: |
      fd2CUrbXBJpB4rt74A6F
    owner: "{{ mongodb_user }}"
    group: "{{ mongodb_user }}"
    mode: 0600
  when: mongod_auth == True

- name: Spawn mongod process without auth
  command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --replSet {{ current_replicaset }} --logpath mongod{{ item }}/log.log --fork
  args:
    chdir: "{{ remote_tmp_dir }}"
  with_items: "{{ mongodb_nodes | sort }}"
  when: mongod_auth == False

- name: Spawn mongod process with auth
  command: mongod --shardsvr --smallfiles {{ mongod_storage_engine_opts }} --dbpath mongod{{ item }} --port {{ item }} --replSet {{ current_replicaset }} --logpath mongod{{ item }}/log.log --fork --auth --keyFile my.key
  args:
    chdir: "{{ remote_tmp_dir }}"
  with_items: "{{ mongodb_nodes | sort }}"
  when: mongod_auth == True

- name: Wait for mongod to start responding
  wait_for:
    port: "{{ item }}"
  with_items: "{{ mongodb_nodes }}"