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
2019-01-31 11:07:12 -05:00

60 lines
2 KiB
YAML

- name: 'Install packages: mongodb, mongodb-server'
package:
name:
- mongodb-server
- mongodb # 2019-01-31: this package does not exist on (cannot be installed on) Debian 10, SEE #1437
state: present
when: internet_available
tags:
- download
- name: 'Create 3 dirs for MongoDB: /var/run/mongodb, {{ mongodb_db_path }}, /var/log/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: Install /etc/mongod.conf, mongodb.service, /usr/bin/iiab-mongodb-repair-if-no-lock from templates
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
mode: "{{ item.mode }}"
with_items:
- { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}", mode: '0644' } # /etc/mongod.conf
- { src: 'mongodb.service.j2', dest: '/etc/systemd/system/mongodb.service', mode: '0644' }
- { src: 'iiab-mongodb-repair-if-no-lock.j2', dest: '/usr/bin/iiab-mongodb-repair-if-no-lock', mode: '0755' }
- name: Enable & Restart 'mongodb' systemd service if mongodb_enabled, incl daemon-reload (in case mongodb.service changed?)
systemd:
name: mongodb
daemon_reload: yes
enabled: yes
state: restarted
when: mongodb_enabled
- name: Disable 'mongodb' service, if not mongodb_enabled
systemd:
name: mongodb
enabled: no
state: stopped
when: not mongodb_enabled
- name: Add 'mongodb' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
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 }}"