59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
---
|
|
- 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: Install packages
|
|
package:
|
|
name: "{{ item }}"
|
|
state: present
|
|
loop: "{{ __mongodb_packages + mongodb_packages_extra }}"
|
|
|
|
- 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
|
|
become_user: root
|
|
|
|
- name: Install pymongo as ansible dependency
|
|
pip:
|
|
name: pymongo
|
|
state: present
|
|
extra_args: --user
|