refactoring

This commit is contained in:
Robert Kaussow 2018-07-10 22:41:01 +02:00
parent f4391bc3d8
commit 4d0aad3e1f
3 changed files with 40 additions and 35 deletions

View File

@ -1,38 +1,5 @@
---
- 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 }}"
selevel: s0
serole : object_r
setype: mongod_var_lib_t
seuser: system_u
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'
- name: Deploy configuration file
template:
src: etc/mongod.conf.j2

View File

@ -1,10 +1,12 @@
---
- include_tasks: install.yml
- include_tasks: prepare.yml
- include_tasks: storage.yml
when: mongodb_lvm_enabled
- include_tasks: config.yml
- include_tasks: install.yml
- include_tasks: confi.yml
- name: Check where admin user already exists
command: |

36
tasks/prepare.yml Normal file
View File

@ -0,0 +1,36 @@
---
- block:
- name: Create group '{{ mongodb_system_group }}'
group:
name: "{{ mongodb_system_group }}"
gid: "{{ mongodb_system_gid | default(omit) }}"
state: present
- name: Create user '{{ mongodb_system_user }}'
user:
name: "{{ mongodb_system_user }}"
uid: "{{ mongodb_system_uid | default(omit) }}"
group: "{{ mongodb_system_group }}"
- name: Create db storage dir '{{ mongodb_storage_dbpath }}'
file:
path: "{{ mongodb_storage_dbpath }}"
owner: "{{ mongodb_system_user }}"
group: "{{ mongodb_system_group }}"
selevel: s0
serole : object_r
setype: mongod_var_lib_t
seuser: system_u
state: directory
notify: __mongod_restart
- 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'
notify: __mongod_restart
become: True