Merge branch 'mongodb-stretch' into unstable

This commit is contained in:
Jérémy Lecour 2017-11-24 12:14:15 +01:00 committed by Jérémy Lecour
commit ab0b867a8c
10 changed files with 136 additions and 49 deletions

View file

@ -1,6 +1,8 @@
# mongodb-org
# mongodb
Install latest MongoDB from 10Gen repository.
Install MongoDB
We use packages from 10Gen for Jessie and packages from Debian for Stretch.
## Tasks
@ -8,8 +10,6 @@ Everything is in the `tasks/main.yml` file.
## Available variables
* `mongodb_pidfile_path`: PID file path (default: `/var/lib/mongodb/mongod.lock`)
* `mongodb_logfile_path`: log file path (default: `/var/log/mongodb/mongod.log`)
* `mongodb_port`: port to listen to (default: `27017`)
* `mongodb_bind`: IP to bind to (default: `127.0.0.1`)

View file

@ -1,5 +1,4 @@
---
mongodb_pidfile_path: /var/lib/mongodb/mongod.lock
mongodb_logfile_path: /var/log/mongodb/mongod.log
mongodb_port: 27017
mongodb_bind: 127.0.0.1

View file

@ -1,7 +1,11 @@
---
# handlers file for mongodb
- name: restart mongodb
- name: restart mongod
service:
name: mongod
state: restarted
- name: restart mongodb
service:
name: mongodb
state: restarted

View file

@ -1,44 +1,12 @@
---
- fail:
msg: only compatible with Debian 8
when:
- ansible_distribution != "Debian" or ansible_distribution_release != "jessie"
# - fail:
# msg: only compatible with Debian 8
# when:
# - ansible_distribution != "Debian" or ansible_distribution_release != "jessie"
# Attention à bien indiquer le protocole et le port, sinon le firewall ne laisse pas passer
- name: MongoDB public GPG Key
apt_key:
# url: https://www.mongodb.org/static/pgp/server-3.4.asc
data: "{{ lookup('file', 'server-3.4.asc') }}"
- include: main_jessie.yml
when: ansible_distribution_release == "jessie"
- name: enable APT sources list
apt_repository:
repo: deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main
state: present
filename: mongodb
update_cache: yes
- name: Install packages
apt:
name: mongodb-org
state: installed
- name: Custom configuration
template:
src: mongod.conf.j2
dest: /etc/mongod.conf
force: yes
backup: no
notify: restart mongodb
- name: Configure logrotate
template:
src: logrotate.j2
dest: /etc/logrotate.d/mongodb
force: yes
backup: no
- name: enable mongod service
service:
name: mongod
enabled: yes
- include: main_stretch.yml
when: ansible_distribution_major_version | version_compare('9', '>=')

View file

@ -0,0 +1,33 @@
---
- name: MongoDB public GPG Key
apt_key:
# url: https://www.mongodb.org/static/pgp/server-3.4.asc
data: "{{ lookup('file', 'server-3.4.asc') }}"
- name: enable APT sources list
apt_repository:
repo: deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.4 main
state: present
filename: mongodb
update_cache: yes
- name: Install packages
apt:
name: mongodb-org
state: installed
- name: Custom configuration
template:
src: mongod_jessie.conf.j2
dest: "/etc/mongod.conf"
force: yes
backup: no
notify: restart mongod
- name: Configure logrotate
template:
src: logrotate_jessie.j2
dest: /etc/logrotate.d/mongodb
force: yes
backup: no

View file

@ -0,0 +1,29 @@
---
- name: Install packages
apt:
name: "{{ item }}"
state: installed
with_items:
- mongodb
- mongo-tools
- name: Custom configuration
template:
src: mongodb_stretch.conf.j2
dest: "/etc/mongodb.conf"
force: yes
backup: no
notify: restart mongodb
- name: enable service
service:
name: mongodb
enabled: yes
- name: Configure logrotate
template:
src: logrotate_stretch.j2
dest: /etc/logrotate.d/mongodb
force: yes
backup: no

View file

@ -1,6 +1,6 @@
# {{ ansible_managed }}
{{ mongodb_logfile_path }} {
/var/log/mongodb/mongod.log {
daily
missingok
rotate 365
@ -10,6 +10,6 @@
notifempty
sharedscripts
postrotate
kill -0 $(cat {{ mongodb_pidfile_path }}) && kill -USR1 $(cat {{ mongodb_pidfile_path }})
pidof mongod | xargs kill -USR1
endscript
}

View file

@ -0,0 +1,15 @@
# {{ ansible_managed }}
/var/log/mongodb/mongodb.log {
daily
missingok
rotate 365
dateext
compress
delaycompress
notifempty
sharedscripts
postrotate
pidof mongod | xargs kill -USR1
endscript
}

View file

@ -0,0 +1,39 @@
# mongodb.conf - {{ ansible_managed }}
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logRotate: reopen
logAppend: true
path: /var/log/mongodb/mongodb.log
# network interfaces
net:
port: {{ mongodb_port }}
bindIp: {{ mongodb_bind }}
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp: