2017-07-14 21:05:30 +00:00
|
|
|
---
|
2017-12-22 11:59:12 +00:00
|
|
|
- block:
|
2019-01-12 13:40:16 +00:00
|
|
|
- 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"
|
2017-07-14 21:05:30 +00:00
|
|
|
|
2019-01-12 13:40:16 +00:00
|
|
|
- name: Install packages
|
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items:
|
|
|
|
- mongodb-org
|
|
|
|
- python2-pip
|
2018-07-10 20:51:02 +00:00
|
|
|
|
2019-01-12 13:40:16 +00:00
|
|
|
- name: Create group '{{ mongodb_system_group }}'
|
|
|
|
group:
|
|
|
|
name: "{{ mongodb_system_group }}"
|
|
|
|
gid: "{{ mongodb_system_gid | default(omit) }}"
|
|
|
|
state: present
|
2018-07-10 20:51:02 +00:00
|
|
|
|
2019-01-12 13:40:16 +00:00
|
|
|
- name: Create user '{{ mongodb_system_user }}'
|
|
|
|
user:
|
|
|
|
name: "{{ mongodb_system_user }}"
|
|
|
|
uid: "{{ mongodb_system_uid | default(omit) }}"
|
|
|
|
group: "{{ mongodb_system_group }}"
|
2018-07-10 20:51:02 +00:00
|
|
|
|
2019-01-12 13:40:16 +00:00
|
|
|
- name: Create db storage dir '{{ mongodb_storage_dbpath }}'
|
|
|
|
file:
|
|
|
|
path: "{{ mongodb_storage_dbpath }}"
|
|
|
|
owner: "{{ mongodb_system_user }}"
|
|
|
|
group: "{{ mongodb_system_group }}"
|
|
|
|
selevel: s0
|
2019-01-12 13:48:21 +00:00
|
|
|
serole: object_r
|
2019-01-12 13:40:16 +00:00
|
|
|
setype: mongod_var_lib_t
|
|
|
|
seuser: system_u
|
|
|
|
state: directory
|
|
|
|
notify: __mongod_restart
|
2018-07-10 20:51:02 +00:00
|
|
|
|
2019-01-12 13:40:16 +00:00
|
|
|
- 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
|
2018-07-07 17:12:50 +00:00
|
|
|
become: True
|
2019-01-12 13:40:16 +00:00
|
|
|
become_user: root
|
2017-12-22 12:34:38 +00:00
|
|
|
|
2018-07-07 17:12:50 +00:00
|
|
|
- name: Install pymongo as ansible dependency
|
|
|
|
pip:
|
|
|
|
name: pymongo
|
2018-07-07 17:20:29 +00:00
|
|
|
state: present
|
2018-07-07 17:12:50 +00:00
|
|
|
extra_args: --user
|