forked from ISTI-ansible-roles/ansible-roles
60 lines
2.2 KiB
YAML
60 lines
2.2 KiB
YAML
|
---
|
||
|
- name: Check if Service mongod Exists
|
||
|
stat: path=/etc/init.d/mongod
|
||
|
register: service_mongod_status
|
||
|
|
||
|
- name: Ensure mongod is stopped and disabled
|
||
|
service: name=mongod state=stopped enabled=no
|
||
|
when: ( service_mongod_status.stat.exists ) and ( mongodb_start_server is defined ) and ( mongodb_start_server == 'no' ) and ( mongodb_install_conf )
|
||
|
tags: mongodb
|
||
|
|
||
|
- name: Install the mongodb apt key
|
||
|
#apt_key: id=7F0CEB10 state=present
|
||
|
raw: apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
|
||
|
when: mongodb_install_from_external_repo
|
||
|
tags: mongodb
|
||
|
|
||
|
- name: Install the mongodb repository
|
||
|
copy: content="deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse" dest=/etc/apt/sources.list.d/mongodb-org-3.2.list owner=root group=root mode=044
|
||
|
when: mongodb_install_from_external_repo
|
||
|
register: external_repo
|
||
|
tags: mongodb
|
||
|
|
||
|
- name: Install the latest version of mongodb server
|
||
|
apt: pkg={{ item }} state={{ mongodb_pkg_state }} update_cache=yes
|
||
|
with_items:
|
||
|
- mongodb-org
|
||
|
- mongodb-org-mongos
|
||
|
- mongodb-org-server
|
||
|
- mongodb-org-shell
|
||
|
- mongodb-org-tools
|
||
|
when:
|
||
|
- mongodb_install_from_external_repo
|
||
|
- mongodb_install_packages
|
||
|
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: 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: Install the mongodb 3.2 configuration
|
||
|
template: src=mongod-3.2.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0444
|
||
|
when: mongodb_install_conf
|
||
|
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
|
||
|
|