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

75 lines
1.8 KiB
YAML
Raw Normal View History

2018-07-12 00:49:03 +00:00
- name: Install MongoDB required packages
package:
name: "{{ item }}"
state: present
2017-05-27 18:09:50 +00:00
with_items:
- mongodb-server
- mongodb
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
mode: 0644
2017-05-27 18:09:50 +00:00
with_items:
2018-07-17 17:12:37 +00:00
- { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}" }
- { src: 'mongodb.service.j2', dest: '/etc/systemd/system/mongodb.service' }
- name: Restart service if 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-12 00:49:03 +00:00
- name: Stop service if not 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
#- 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
2018-07-12 00:49:03 +00:00
- 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 }}"
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 }}"