prepare base installation

This commit is contained in:
Robert Kaussow 2018-07-05 23:16:57 +02:00
parent 683ded1821
commit be9b221358
3 changed files with 45 additions and 19 deletions

9
defaults/main.yml Normal file
View File

@ -0,0 +1,9 @@
---
mongodb_version: 3.6
mongodb_system_user: mongod
mongodb_system_group: mongod
mongodb_storage_dbpath:
# mongodb_system_gid: omit
# mongodb_system_uid: omit

View File

@ -1,9 +1,8 @@
---
- name: Restart mongodb
- name: Restart mongod service
systemd:
name: mongod
state: restarted
enabled: yes
daemon_reload: yes
listen:
- "mongod_restart"
listen: __mongod_restart

View File

@ -1,28 +1,46 @@
---
- block:
- name: Add mongodb repo
- name: Add repository for major version '{{ mongodb_version }}'
yum_repository:
name: mongodb-org-3.4
name: mongodb
description: MongoDB Repository
baseurl: https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
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-3.4.asc
notify:
- mongod_restart
gpgkey: "https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc"
- name: Install mongodb package
- name: Install package
package:
name: mongodb-org
state: latest
notify:
- mongod_restart
state: present
- 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