1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/mongodb/tasks/main.yml
2018-07-22 11:01:31 -04:00

64 lines
1.6 KiB
YAML

- name: Install MongoDB required packages
package:
name: "{{ item }}"
state: present
with_items:
- mongodb-server
- mongodb
when: internet_available
tags:
- download
- name: Create the data directory for MongoDB
file:
state: directory
path: "{{ item.path }}"
owner: mongodb
with_items:
- { path: '/var/run/mongodb' }
- { path: "{{ mongodb_db_path }}" } # == /library/dbdata/mongodb/
- { path: '/var/log/mongodb' }
- name: Populate & position /etc/mongod.conf, mongodb.service
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: 0644
with_items:
- { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}" }
- { src: 'mongodb.service.j2', dest: '/etc/systemd/system/mongodb.service' }
- name: "systemctl daemon-reload" in case mongodb.service changed
systemd:
state: restarted
daemon_reload: yes
- name: Restart service if enabled
service:
name: mongodb
enabled: yes
state: restarted
when: mongodb_enabled
- name: Stop service if not enabled
service:
name: mongodb
enabled: no
state: stopped
when: not mongodb_enabled
- name: Add 'mongodb' to list of services at /etc/iiab/iiab.ini
ini_file:
dest: "{{ service_filelist }}"
section: mongodb
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- option: name
value: MongoDB
- option: description
value: '"MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling."'
- option: enabled
value: "{{ mongodb_enabled }}"