mirror of
https://github.com/status-im/ansible-role-mongodb.git
synced 2025-01-09 21:15:44 +00:00
e28b94aebf
Configuration and authentication with custom settings fix
57 lines
2.0 KiB
YAML
57 lines
2.0 KiB
YAML
---
|
|
- name: Register default MongoDB listen IP
|
|
set_fact: mongodb_listen_ip=127.0.0.1
|
|
when: ansible_local.mongodb.mongodb.mongodb_listen_ip is undefined
|
|
|
|
- name: Register MongoDB listen IP
|
|
set_fact: mongodb_listen_ip={{ ansible_local.mongodb.mongodb.mongodb_listen_ip }}
|
|
when: ansible_local.mongodb.mongodb.mongodb_listen_ip is defined
|
|
|
|
|
|
- name: Create keyFile
|
|
copy:
|
|
dest: "{{ mongodb_conf_keyFile }}"
|
|
content: "{{ mongodb_keyfile_content }}"
|
|
owner: "{{ mongodb_user }}"
|
|
group: "root"
|
|
mode: 0600
|
|
when: mongodb_conf_replSet != ''
|
|
|
|
- name: Configure log rotation
|
|
template: src=logrotate.conf.j2 dest=/etc/logrotate.d/mongodb.conf
|
|
when: mongodb_logrotate
|
|
|
|
- name: ensure mongodb started and enabled
|
|
service: name={{ mongodb_daemon_name }} state=started enabled=yes
|
|
when: mongodb_manager_service
|
|
|
|
- name: wait MongoDB port is listening
|
|
wait_for: host="{{ mongodb_listen_ip }}" port="{{ mongodb_conf_port }}" delay=10 timeout=60 state=started
|
|
when: mongodb_force_wait_for_port or "'systemd' in systemd.stdout"
|
|
|
|
- include: auth_initialization.yml
|
|
when: mongodb_conf_auth
|
|
|
|
- name: Create mongodb user
|
|
user: name={{mongodb_user}} group={{mongodb_user}}
|
|
|
|
- name: Configure database directory
|
|
file: state=directory path={{ mongodb_conf_dbpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0755
|
|
|
|
- name: Create log dir if missing
|
|
file: state=directory recurse=yes dest={{ mongodb_conf_logpath|dirname }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
|
|
|
|
- name: Create log if missing
|
|
file: state=touch dest={{ mongodb_conf_logpath }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
|
|
|
|
- name: Configure log file
|
|
file: state=file path={{ mongodb_conf_logpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0755
|
|
|
|
- name: Configure mongodb
|
|
template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644
|
|
register: config_result
|
|
|
|
- name: mongodb restart
|
|
service: name={{ mongodb_daemon_name }} state=restarted
|
|
when: config_result|changed and mongodb_manager_service
|