move lvm handler to own task file

This commit is contained in:
Robert Kaussow 2018-07-07 23:29:34 +02:00
parent 7358350e39
commit eff3961ab8
3 changed files with 36 additions and 34 deletions

View File

@ -30,40 +30,6 @@
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
- block:
- name: Deploy configuration file
template:
src: etc/mongod.conf.j2

View File

@ -1,5 +1,9 @@
---
- include_tasks: install.yml
- include_tasks: storage.yml
when: mongodb_lvm_enabled
- include_tasks: config.yml
- name: Check where admin user already exists

32
tasks/storage.yml Normal file
View File

@ -0,0 +1,32 @@
---
- 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