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
1.8 KiB
YAML
Raw Normal View History

2018-10-28 17:41:54 +00:00
- name: Install packages mongodb-server and mongodb
2018-07-12 00:49:03 +00:00
package:
2018-10-28 17:41:54 +00:00
name:
- mongodb-server
- mongodb
2018-07-12 00:49:03 +00:00
state: present
when: internet_available
2017-05-27 18:09:50 +00:00
tags:
- download
2018-07-12 00:49:03 +00:00
- name: Create the data directory for MongoDB
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
- name: Populate & position /etc/mongod.conf, mongodb.service
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:
2018-07-23 14:01:21 +00:00
- { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}", mode: '0644' }
- { 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-07-22 15:30:31 +00:00
- name: Enable+restart systemd service if mongodb_enabled, with "systemctl daemon-reload" (in case mongodb.service changed?)
systemd:
name: mongodb
2018-07-12 00:49:03 +00:00
enabled: yes
state: restarted
daemon_reload: yes
2017-05-27 18:09:50 +00:00
when: mongodb_enabled
2018-07-22 15:35:43 +00:00
- name: 'Disable+stop systemd service if mongodb_enabled: False'
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
- name: Add 'mongodb' to list of services at {{ iiab_ini_file }}
2018-07-12 00:49:03 +00:00
ini_file:
2018-10-15 10:13:57 +00:00
dest: "{{ 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 }}"