Add possibility for User to install from Official Debian or Ubuntu Repo.

Support new variable and due to difference between Debian/Ubuntu repo and MongoDB, daemon and file convention naming are differents.
This commit is contained in:
Guillaume Dedrie 2015-01-05 14:37:28 +01:00
parent a4514cad64
commit 8769e8a411
5 changed files with 32 additions and 19 deletions

View File

@ -15,12 +15,14 @@ Ansible role which manage [MongoDB](http://www.mongodb.org/)
```yaml
mongodb_enabled: yes
mongodb_packages:
- python-selinux
- python-pymongo
- mongodb-org
mongodb_from_mongodb_repo: yes # If yes, install using MongoDB repo, else use system default repo
mongodb_additional_packages:
- python-selinux
- python-pymongo
mongodb_user: mongodb
mongodb_daemon_name: "{{ 'mongod' if (mongodb_from_mongodb_repo | bool) else 'mongodb' }}"
mongodb_conf_auth: no # Run with security
mongodb_conf_bind_ip: 127.0.0.1 # Comma separated list of ip addresses to listen on
@ -31,7 +33,7 @@ mongodb_conf_httpinterface: no # Enable http interface
mongodb_conf_ipv6: no # Enable IPv6 support (disabled by default)
mongodb_conf_journal: no # Enable journaling
mongodb_conf_logappend: yes # Append to logpath instead of over-writing
mongodb_conf_logpath: /var/log/mongodb/mongod.log # Log file to send write to instead of stdout
mongodb_conf_logpath: /var/log/mongodb/{{ mongodb_daemon_name }}.log # Log file to send write to instead of stdout
mongodb_conf_maxConns: 1000000 # Max number of simultaneous connections
mongodb_conf_noprealloc: no # Disable data file preallocation
mongodb_conf_noscripting: no # Disable scripting engine

View File

@ -1,12 +1,14 @@
---
mongodb_enabled: yes
mongodb_packages:
- python-selinux
- python-pymongo
- mongodb-org
mongodb_from_mongodb_repo: yes # If yes, install using MongoDB repo, else use system default repo
mongodb_additional_packages:
- python-selinux
- python-pymongo
mongodb_user: mongodb
mongodb_daemon_name: "{{ 'mongod' if (mongodb_from_mongodb_repo | bool) else 'mongodb' }}"
mongodb_conf_auth: no # Run with security
mongodb_conf_bind_ip: 127.0.0.1 # Comma separated list of ip addresses to listen on
@ -17,7 +19,7 @@ mongodb_conf_httpinterface: no # Enable http interface
mongodb_conf_ipv6: no # Enable IPv6 support (disabled by default)
mongodb_conf_journal: no # Enable journaling
mongodb_conf_logappend: yes # Append to logpath instead of over-writing
mongodb_conf_logpath: /var/log/mongodb/mongod.log # Log file to send write to instead of stdout
mongodb_conf_logpath: /var/log/mongodb/{{ mongodb_daemon_name }}.log # Log file to send write to instead of stdout
mongodb_conf_maxConns: 1000000 # Max number of simultaneous connections
mongodb_conf_noprealloc: no # Disable data file preallocation
mongodb_conf_noscripting: no # Disable scripting engine

View File

@ -1,10 +1,10 @@
---
- name: mongodb reload
service: name=mongod state=reloaded
service: name={{ mongodb_daemon_name }} state=reloaded
- name: mongodb restart
service: name=mongod state=restarted
service: name={{ mongodb_daemon_name }} state=restarted
- name: mongodb-mms-automation-agent restart
service: name=mongodb-mms-automation-agent state=restarted

View File

@ -2,15 +2,24 @@
- name: Add APT key
apt_key: url=http://docs.mongodb.org/10gen-gpg-key.asc id=7F0CEB10
when: mongodb_from_mongodb_repo | bool
- name: Add APT repository (Ubuntu)
apt_repository: repo='deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' update_cache=yes
when: ansible_distribution == 'Ubuntu'
when: ansible_distribution == 'Ubuntu' and (mongodb_from_mongodb_repo | bool)
- name: Add APT repository (Debian)
apt_repository: repo='deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen' update_cache=yes
when: ansible_distribution == 'Debian'
when: ansible_distribution == 'Debian' and (mongodb_from_mongodb_repo | bool)
- name: Install mongodb-org
- name: Install MongoDB package from MongoDB repo
apt: pkg=mongodb-org state=present
when: mongodb_from_mongodb_repo | bool
- name: Install MongoDB package from Ubuntu or Debian official repo
apt: pkg=mongodb state=present
when: not (mongodb_from_mongodb_repo | bool)
- name: Install additional packages
apt: pkg={{item}}
with_items: mongodb_packages
with_items: mongodb_additional_packages

View File

@ -6,7 +6,7 @@
- include: configure.yml
- name: Ensure mongodb is started
service: name=mongod state=started enabled=yes
service: name={{ mongodb_daemon_name }} state=started enabled=yes
changed_when: False
- include: mms-agent.yml