|
1 | 1 | ---
|
| 2 | +- name: Register default MongoDB listen interface |
| 3 | + set_fact: mongodb_listen_iface=127.0.0.1 |
| 4 | + when: ansible_local.mongodb.mongodb.mongodb_listen_iface is undefined |
| 5 | + |
| 6 | +- name: Register MongoDB listen interface |
| 7 | + set_fact: mongodb_listen_iface={{ ansible_local.mongodb.mongodb.mongodb_listen_iface }} |
| 8 | + when: ansible_local.mongodb.mongodb.mongodb_listen_iface is defined |
| 9 | + |
2 | 10 |
|
3 | 11 | - name: Create keyFile
|
4 | 12 | copy:
|
|
17 | 25 | service: name={{ mongodb_daemon_name }} state=started enabled=yes
|
18 | 26 |
|
19 | 27 | - name: wait MongoDB port is listening
|
20 |
| - wait_for: host="{{ mongodb_conf_bind_ip }}"port="{{ mongodb_conf_port }}" delay=10 timeout=60 state=started |
21 |
| - when: "'systemd' in systemd.stdout" |
| 28 | + wait_for: host="{{ mongodb_listen_iface }}" port="{{ mongodb_conf_port }}" delay=5 timeout=60 state=started |
| 29 | + #when: "'systemd' in systemd.stdout" #TODO Why only with systemd? |
22 | 30 |
|
23 | 31 | - include: auth_initialization.yml
|
24 | 32 | when: mongodb_conf_auth
|
|
29 | 37 | - name: Configure database directory
|
30 | 38 | file: state=directory path={{ mongodb_conf_dbpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0755
|
31 | 39 |
|
32 |
| -- name: Configure logs |
33 |
| - file: state=file path={{ mongodb_conf_logpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0644 |
| 40 | +- name: Create log dir if missing |
| 41 | + file: state=directory recurse=yes dest={{ mongodb_conf_logpath|dirname }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755 |
| 42 | + |
| 43 | +- name: Create log if missing |
| 44 | + file: state=touch dest={{ mongodb_conf_logpath }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755 |
| 45 | + |
| 46 | +- name: Configure log file |
| 47 | + file: state=file path={{ mongodb_conf_logpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0755 |
34 | 48 |
|
35 | 49 | - name: Configure mongodb
|
36 |
| - template: src=mongod.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0644 |
| 50 | + template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644 |
37 | 51 | register: config_result
|
38 | 52 |
|
39 | 53 | - name: mongodb restart
|
|
0 commit comments