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

61 lines
2 KiB
YAML
Raw Normal View History

2018-10-31 06:51:34 +00:00
- name: 'Install packages: mongodb, mongodb-server'
2018-07-12 00:49:03 +00:00
package:
2018-10-28 17:41:54 +00:00
name:
- mongodb-server
2019-01-31 16:07:12 +00:00
- mongodb # 2019-01-31: this package does not exist on (cannot be installed on) Debian 10, SEE #1437
2018-07-12 00:49:03 +00:00
state: present
when: internet_available
2017-05-27 18:09:50 +00:00
tags:
- download
2019-01-31 16:07:12 +00:00
- name: 'Create 3 dirs for MongoDB: /var/run/mongodb, {{ mongodb_db_path }}, /var/log/mongodb'
2018-07-12 00:49:03 +00:00
file:
state: directory
path: "{{ item.path }}"
owner: mongodb
2017-05-27 18:09:50 +00:00
with_items:
2018-07-12 00:49:03 +00:00
- { path: '/var/run/mongodb' }
- { path: "{{ mongodb_db_path }}" } # == /library/dbdata/mongodb/
2018-07-12 00:49:03 +00:00
- { path: '/var/log/mongodb' }
2017-05-27 18:09:50 +00:00
2019-01-31 16:07:12 +00:00
- name: Install /etc/mongod.conf, mongodb.service, /usr/bin/iiab-mongodb-repair-if-no-lock from templates
2018-07-12 00:49:03 +00:00
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
2018-07-23 14:01:21 +00:00
mode: "{{ item.mode }}"
2017-05-27 18:09:50 +00:00
with_items:
2019-01-31 16:07:12 +00:00
- { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}", mode: '0644' } # /etc/mongod.conf
2018-07-23 14:01:21 +00:00
- { 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' }
2018-10-31 06:51:34 +00:00
- name: Enable & Restart 'mongodb' systemd service if mongodb_enabled, incl daemon-reload (in case mongodb.service changed?)
systemd:
name: mongodb
2019-01-31 16:07:12 +00:00
daemon_reload: yes
2018-07-12 00:49:03 +00:00
enabled: yes
state: restarted
2017-05-27 18:09:50 +00:00
when: mongodb_enabled
2018-10-31 06:51:34 +00:00
- name: Disable 'mongodb' service, if not mongodb_enabled
systemd:
name: mongodb
2018-07-12 00:49:03 +00:00
enabled: no
state: stopped
2017-05-27 18:09:50 +00:00
when: not mongodb_enabled
2018-10-31 06:51:34 +00:00
- name: Add 'mongodb' variable values to {{ iiab_ini_file }}
2018-07-12 00:49:03 +00:00
ini_file:
2018-10-31 06:51:34 +00:00
path: "{{ iiab_ini_file }}"
2018-07-12 00:49:03 +00:00
section: mongodb
option: "{{ item.option }}"
value: "{{ item.value }}"
2017-05-27 18:09:50 +00:00
with_items:
2018-07-12 00:49:03 +00:00
- 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 }}"