38 lines
1.1 KiB
YAML
38 lines
1.1 KiB
YAML
---
|
|
|
|
- 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
|
|
|
|
- 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: Configure logs
|
|
file: state=file path={{ mongodb_conf_logpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0644
|
|
|
|
- name: Configure mongodb
|
|
template: src=mongod.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0644
|
|
register: config_result
|
|
|
|
- name: mongodb restart
|
|
service: name={{ mongodb_daemon_name }} state=restarted
|
|
when: config_result|changed
|