2014-06-04 19:03:58 +04:00
|
|
|
---
|
2015-04-06 23:37:34 +02:00
|
|
|
|
2015-02-13 18:27:38 +06:00
|
|
|
- name: Create keyFile
|
|
|
|
copy:
|
|
|
|
dest: "{{ mongodb_conf_keyFile }}"
|
|
|
|
content: "{{ mongodb_keyfile_content }}"
|
|
|
|
owner: "{{ mongodb_user }}"
|
|
|
|
group: "root"
|
|
|
|
mode: 0600
|
|
|
|
when: mongodb_conf_replSet != ''
|
|
|
|
|
2014-07-10 20:07:35 +04:00
|
|
|
- name: Configure log rotation
|
|
|
|
template: src=logrotate.conf.j2 dest=/etc/logrotate.d/mongodb.conf
|
|
|
|
when: mongodb_logrotate
|
2014-12-11 22:09:31 +03:00
|
|
|
|
2015-06-22 14:59:25 +06:00
|
|
|
- name: set mongodb gid
|
|
|
|
group: name=mongodb gid={{ mongodb_gid }} state=present
|
|
|
|
when: mongodb_gid
|
2015-02-17 19:17:50 +06:00
|
|
|
|
2015-06-22 14:59:25 +06:00
|
|
|
- name: set mongodb uid
|
|
|
|
user: name=mongodb uid={{ mongodb_uid }} group=mongodb state=present
|
|
|
|
when: mongodb_uid
|
2014-12-11 22:09:31 +03:00
|
|
|
|
2015-06-22 14:59:25 +06:00
|
|
|
- name: reset mongodb folder and subfolders with new uid
|
|
|
|
file: path={{ mongodb_conf_dbpath }} owner=mongodb group=mongodb follow=yes recurse=yes state=directory
|
|
|
|
when: mongodb_uid
|
2014-12-11 22:09:31 +03:00
|
|
|
|
2015-04-04 14:26:31 +03:00
|
|
|
- name: Create log dir if missing
|
|
|
|
file: state=directory recurse=yes dest={{ mongodb_conf_logpath|dirname }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
|
|
|
|
|
2015-06-16 17:32:39 +06:00
|
|
|
- name: Check than logfile exists
|
|
|
|
stat: path={{ mongodb_conf_logpath }}
|
|
|
|
register: logfile_stat
|
|
|
|
|
2015-04-04 14:26:31 +03:00
|
|
|
- name: Create log if missing
|
|
|
|
file: state=touch dest={{ mongodb_conf_logpath }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
|
2015-06-16 17:32:39 +06:00
|
|
|
when: logfile_stat is defined and not logfile_stat.stat.exists
|
2014-12-26 18:32:50 +03:00
|
|
|
|
2015-02-17 13:28:24 +06:00
|
|
|
- name: Configure mongodb
|
2015-04-04 14:26:31 +03:00
|
|
|
template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644
|
2015-02-17 13:28:24 +06:00
|
|
|
register: config_result
|
|
|
|
|
2015-06-16 17:33:22 +06:00
|
|
|
- name: Install sysfsutils package
|
|
|
|
apt: name=sysfsutils state=present
|
2015-04-08 20:18:19 +03:00
|
|
|
when: ansible_os_family == 'Debian' and mongodb_disable_thp
|
|
|
|
|
2015-07-24 11:52:21 +06:00
|
|
|
- name: Create /etc/sysfs.d direcroty
|
|
|
|
file:
|
|
|
|
path: /etc/sysfs.d
|
|
|
|
group: root
|
|
|
|
state: directory
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
when: ansible_os_family == 'Debian' and mongodb_disable_thp
|
|
|
|
|
2015-06-16 17:33:22 +06:00
|
|
|
- name: Create sysfs config
|
|
|
|
copy:
|
|
|
|
src: hugepages.conf
|
|
|
|
dest: /etc/sysfs.d/hugepages.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2015-04-08 20:18:19 +03:00
|
|
|
when: ansible_os_family == 'Debian' and mongodb_disable_thp
|
2015-06-16 17:33:22 +06:00
|
|
|
notify: restart sysfsutils
|
2015-04-08 20:18:19 +03:00
|
|
|
|
2015-02-17 13:28:24 +06:00
|
|
|
- name: mongodb restart
|
|
|
|
service: name={{ mongodb_daemon_name }} state=restarted
|
2015-04-06 23:37:34 +02:00
|
|
|
when: config_result|changed and mongodb_manage_service
|