inlcude user and storage setup

This commit is contained in:
Robert Kaussow 2018-07-07 00:05:37 +02:00
parent 52ee3143f2
commit 9a716d6625
2 changed files with 41 additions and 41 deletions

View File

@ -2,7 +2,7 @@
mongodb_version: 3.6
mongodb_system_user: mongod
mongodb_system_group: mongod
mongodb_storage_dbpath:
mongodb_storage_dbpath: /var/lib/mongo
# mongodb_system_gid: omit

View File

@ -1,46 +1,46 @@
---
- block:
- name: Add repository for major version '{{ mongodb_version }}'
yum_repository:
name: mongodb
description: MongoDB Repository
baseurl: "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/{{ mongodb_version }}/x86_64/"
gpgcheck: yes
enabled: yes
gpgkey: "https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc"
- name: Add repository for major version '{{ mongodb_version }}'
yum_repository:
name: mongodb
description: MongoDB Repository
baseurl: "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/{{ mongodb_version }}/x86_64/"
gpgcheck: yes
enabled: yes
gpgkey: "https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc"
- name: Install package
package:
name: mongodb-org
state: present
- name: Install package
package:
name: mongodb-org
state: present
# - 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 at '{{ mongodb_storage_dbpath }}'
# file:
# path: "{{ mongodb_storage_dbpath }}"
# owner: "{{ mongodb_system_user }}"
# group: "{{ mongodb_system_group }}"
# follow: yes
# recurse: yes
# state: directory
#
# - name: Make sure mongodb is running
# systemd:
# name: mongod
# state: started
# enabled: yes
# daemon_reload: yes
- 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 at '{{ mongodb_storage_dbpath }}'
file:
path: "{{ mongodb_storage_dbpath }}"
owner: "{{ mongodb_system_user }}"
group: "{{ mongodb_system_group }}"
follow: yes
recurse: yes
state: directory
# - name: Make sure mongodb is running
# systemd:
# name: mongod
# state: started
# enabled: yes
# daemon_reload: yes
become: True
become_user: root