ansible-role-mongodb/tasks/configure.yml

23 lines
760 B
YAML

---
- name: Configure mongodb
template: src=mongod.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0644
notify: mongodb restart
- name: Configure log rotation
template: src=logrotate.conf.j2 dest=/etc/logrotate.d/mongodb.conf
when: mongodb_logrotate
- 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: Run mongoshell commands
command: mongo {{ item.key }} --eval "{{ item.value|join('\n') }}"
with_dict: mongodb_shell