2018-07-07 21:20:00 +00:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
- name: Create system group '{{ mongodb_system_group }}'
|
|
|
|
group:
|
|
|
|
name: "{{ mongodb_system_group }}"
|
|
|
|
gid: "{{ mongodb_system_gid | default(omit) }}"
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create system user '{{ mongodb_system_user }}'
|
|
|
|
user:
|
|
|
|
name: "{{ mongodb_system_user }}"
|
|
|
|
uid: "{{ mongodb_system_uid | default(omit) }}"
|
|
|
|
group: "{{ mongodb_system_group }}"
|
|
|
|
notify: __mongod_restart
|
|
|
|
|
|
|
|
- name: Create db storage dir '{{ mongodb_storage_dbpath }}'
|
|
|
|
file:
|
|
|
|
path: "{{ mongodb_storage_dbpath }}"
|
|
|
|
owner: "{{ mongodb_system_user }}"
|
|
|
|
group: "{{ mongodb_system_group }}"
|
|
|
|
recurse: yes
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Create log dir '{{ mongodb_systemlog_path | dirname }}'
|
|
|
|
file:
|
|
|
|
path: "{{ mongodb_systemlog_path | dirname }}"
|
|
|
|
owner: "{{ mongodb_system_user }}"
|
|
|
|
group: "{{ mongodb_system_group }}"
|
|
|
|
recurse: yes
|
|
|
|
state: directory
|
|
|
|
when: mongodb_systemlog_destination == 'file'
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Create volume group 'mongodb_lvm_vg'
|
|
|
|
lvg:
|
|
|
|
vg: "{{ mongodb_lvm_vg }}"
|
|
|
|
pvs: "{{ mongodb_lvm_pvs|join(',') }}"
|
|
|
|
|
|
|
|
- name: Create logical volume 'mongodb_lvm_lv'
|
|
|
|
lvol:
|
|
|
|
vg: "{{ mongodb_lvm_vg }}"
|
|
|
|
lv: "{{ mongodb_lvm_lv }}"
|
|
|
|
size: "{{ mongodb_lvm_size }}"
|
|
|
|
|
|
|
|
- name: Create filesystem for '/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}'
|
|
|
|
filesystem:
|
|
|
|
fstype: "{{ mongodb_lvm_fstype }}"
|
|
|
|
dev: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}"
|
|
|
|
|
|
|
|
- name: Mount volume to 'mongodb_storage_dbpath'
|
|
|
|
mount:
|
|
|
|
path: "{{ mongodb_storage_dbpath }}"
|
|
|
|
src: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}"
|
|
|
|
fstype: "{{ mongodb_lvm_fstype }}"
|
|
|
|
state: mounted
|
|
|
|
|
|
|
|
- name: Change permissions for mountpoint
|
|
|
|
file:
|
|
|
|
path: "{{ mongodb_storage_dbpath }}"
|
|
|
|
owner: "{{ mongodb_user }}"
|
|
|
|
group: "{{ mongodb_group }}"
|
|
|
|
mode: 0750
|
|
|
|
become: True
|
|
|
|
when: mongodb_lvm_enabled
|
|
|
|
|
2018-07-07 21:22:24 +00:00
|
|
|
- block:
|
2018-07-07 21:20:00 +00:00
|
|
|
- name: Deploy configuration file
|
|
|
|
template:
|
|
|
|
src: etc/mongod.conf.j2
|
|
|
|
dest: /etc/mongod.conf
|
|
|
|
mode: 0644
|
|
|
|
notify: __mongod_restart
|
|
|
|
|
|
|
|
- name: Make sure mongodb is up and running
|
|
|
|
systemd:
|
|
|
|
name: mongod
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
become: True
|
|
|
|
become_user: root
|