2015-11-23 20:16:04 +01:00
|
|
|
---
|
|
|
|
- name: Install the mongodb apt key
|
|
|
|
#apt_key: id=7F0CEB10 state=present
|
|
|
|
raw: apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
|
|
|
|
when: mongodb_install_from_external_repo
|
|
|
|
tags: mongodb
|
|
|
|
|
|
|
|
- name: Install the mongodb repository
|
2016-03-25 18:04:45 +01:00
|
|
|
ansible_repository: repo="deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" state=present update_cache=yes
|
2015-11-23 20:16:04 +01:00
|
|
|
when: mongodb_install_from_external_repo
|
|
|
|
register: external_repo
|
|
|
|
tags: mongodb
|
|
|
|
|
|
|
|
- name: Install the latest version of mongodb server
|
2016-03-25 18:04:45 +01:00
|
|
|
apt: pkg={{ item }} state={{ mongodb_pkg_state }}
|
2015-11-23 20:16:04 +01:00
|
|
|
with_items:
|
|
|
|
- mongodb-org
|
|
|
|
when:
|
|
|
|
- mongodb_install_from_external_repo
|
|
|
|
- mongodb_install_packages
|
|
|
|
tags: mongodb
|
|
|
|
|
|
|
|
- name: Install the mongodb defaults file
|
2016-03-24 15:41:14 +01:00
|
|
|
template: src=mongod-default.j2 dest=/etc/default/mongod owner=root group=root mode=0444
|
2015-11-23 20:16:04 +01:00
|
|
|
when: mongodb_install_conf
|
2016-03-24 19:35:34 +01:00
|
|
|
notify: Restart mongodb
|
2015-11-23 20:16:04 +01:00
|
|
|
tags: mongodb
|
|
|
|
|
|
|
|
- name: Create the mongodb db directory
|
|
|
|
file: dest={{ mongodb_dbpath }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
|
|
|
|
when: mongodb_install_conf
|
|
|
|
tags: mongodb
|
|
|
|
|
|
|
|
- name: Create the mongodb log directory
|
|
|
|
file: dest={{ mongodb_logdir }} state=directory owner={{ mongodb_user }} group={{ mongodb_group }} mode=0755
|
|
|
|
when: mongodb_install_conf
|
|
|
|
tags: mongodb
|
|
|
|
|
|
|
|
- name: Install the mongodb 2.6 configuration
|
|
|
|
template: src=mongod-2.6.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0444
|
|
|
|
when: mongodb_install_conf
|
2016-03-24 15:41:14 +01:00
|
|
|
notify: Restart mongodb
|
2015-11-23 20:16:04 +01:00
|
|
|
tags: mongodb
|
|
|
|
|
|
|
|
- name: Install the cron job that manages log files rotation
|
|
|
|
template: src=mongo_log_rotate.sh.j2 dest=/etc/cron.daily/mongo_log_rotate owner=root group=root mode=0555
|
|
|
|
tags: [ 'mongodb', 'mongo_logrotate' ]
|
|
|
|
|
|
|
|
- name: Ensure mongodb is started
|
|
|
|
service: name=mongod state=started enabled=yes
|
|
|
|
when: ( mongodb_start_server is defined ) and ( mongodb_start_server == 'yes' ) and ( mongodb_install_conf )
|
|
|
|
tags: mongodb
|
|
|
|
|
|
|
|
- name: Ensure mongod is stopped and disabled
|
|
|
|
service: name=mongod state=stopped enabled=no
|
|
|
|
when: ( mongodb_start_server is defined ) and ( mongodb_start_server == 'no' ) and ( mongodb_install_conf )
|
|
|
|
tags: mongodb
|