ansible-role-mongodb/tasks/configure.yml

69 lines
2.0 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: set mongodb gid
group: name=mongodb gid={{ mongodb_gid }} state=present
when: mongodb_gid
- name: set mongodb uid
user: name=mongodb uid={{ mongodb_uid }} group=mongodb state=present
when: mongodb_uid
- 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
- 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: Check than logfile exists
stat: path={{ mongodb_conf_logpath }}
register: logfile_stat
- name: Create log if missing
file: state=touch dest={{ mongodb_conf_logpath }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
when: logfile_stat is defined and not logfile_stat.stat.exists
- name: Configure mongodb
template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644
register: config_result
- name: Install sysfsutils package
apt: name=sysfsutils state=present
when: ansible_os_family == 'Debian' and mongodb_disable_thp
- 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
- name: Create sysfs config
copy:
src: hugepages.conf
dest: /etc/sysfs.d/hugepages.conf
owner: root
group: root
mode: 0644
when: ansible_os_family == 'Debian' and mongodb_disable_thp
notify: restart sysfsutils
- name: mongodb restart
service: name={{ mongodb_daemon_name }} state=restarted
when: config_result|changed and mongodb_manage_service