forked from evolix/ansible-roles
Adapt mongodb role for Stretch
Everything changes : * package source * service name * version
This commit is contained in:
parent
7fee69ca22
commit
0c8389baf9
|
@ -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
|
## Tasks
|
||||||
|
|
||||||
|
@ -8,8 +10,6 @@ Everything is in the `tasks/main.yml` file.
|
||||||
|
|
||||||
## Available variables
|
## 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_port`: port to listen to (default: `27017`)
|
||||||
* `mongodb_bind`: IP to bind to (default: `127.0.0.1`)
|
* `mongodb_bind`: IP to bind to (default: `127.0.0.1`)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
mongodb_pidfile_path: /var/lib/mongodb/mongod.lock
|
|
||||||
mongodb_logfile_path: /var/log/mongodb/mongod.log
|
|
||||||
mongodb_port: 27017
|
mongodb_port: 27017
|
||||||
mongodb_bind: 127.0.0.1
|
mongodb_bind: 127.0.0.1
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
---
|
---
|
||||||
# handlers file for mongodb
|
# handlers file for mongodb
|
||||||
- name: restart mongodb
|
- name: restart mongod
|
||||||
service:
|
service:
|
||||||
name: mongod
|
name: mongod
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: restart mongodb
|
||||||
|
service:
|
||||||
|
name: mongodb
|
||||||
|
state: restarted
|
||||||
|
|
|
@ -1,44 +1,12 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- fail:
|
# - fail:
|
||||||
msg: only compatible with Debian 8
|
# msg: only compatible with Debian 8
|
||||||
when:
|
# when:
|
||||||
- ansible_distribution != "Debian" or ansible_distribution_release != "jessie"
|
# - ansible_distribution != "Debian" or ansible_distribution_release != "jessie"
|
||||||
|
|
||||||
# Attention à bien indiquer le protocole et le port, sinon le firewall ne laisse pas passer
|
- include: main_jessie.yml
|
||||||
- name: MongoDB public GPG Key
|
when: ansible_distribution_release == "jessie"
|
||||||
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
|
- include: main_stretch.yml
|
||||||
apt_repository:
|
when: ansible_distribution_major_version | version_compare('9', '>=')
|
||||||
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
|
|
||||||
|
|
33
mongodb/tasks/main_jessie.yml
Normal file
33
mongodb/tasks/main_jessie.yml
Normal 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
|
29
mongodb/tasks/main_stretch.yml
Normal file
29
mongodb/tasks/main_stretch.yml
Normal 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
|
|
@ -1,6 +1,6 @@
|
||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
{{ mongodb_logfile_path }} {
|
/var/log/mongodb/mongod.log {
|
||||||
daily
|
daily
|
||||||
missingok
|
missingok
|
||||||
rotate 365
|
rotate 365
|
||||||
|
@ -10,6 +10,6 @@
|
||||||
notifempty
|
notifempty
|
||||||
sharedscripts
|
sharedscripts
|
||||||
postrotate
|
postrotate
|
||||||
kill -0 $(cat {{ mongodb_pidfile_path }}) && kill -USR1 $(cat {{ mongodb_pidfile_path }})
|
pidof mongod | xargs kill -USR1
|
||||||
endscript
|
endscript
|
||||||
}
|
}
|
15
mongodb/templates/logrotate_stretch.j2
Normal file
15
mongodb/templates/logrotate_stretch.j2
Normal 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
|
||||||
|
}
|
39
mongodb/templates/mongodb_stretch.conf.j2
Normal file
39
mongodb/templates/mongodb_stretch.conf.j2
Normal 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:
|
Loading…
Reference in a new issue