2014-06-04 15:03:58 +00:00
|
|
|
---
|
|
|
|
|
2015-01-07 11:31:53 +00:00
|
|
|
- include_vars: "{{ansible_distribution}}.yml"
|
|
|
|
|
2015-03-04 10:05:08 +00:00
|
|
|
- name: Check if running on systemd
|
2016-09-21 14:33:05 +00:00
|
|
|
stat: path=/sbin/init
|
|
|
|
register: sbin_init
|
2015-06-16 08:19:58 +00:00
|
|
|
changed_when: false
|
2016-07-15 13:57:06 +00:00
|
|
|
always_run: yes # side-effect free, so it can be run in check-mode as well
|
2015-02-25 07:57:36 +00:00
|
|
|
|
|
|
|
- name: Add systemd configuration if present
|
|
|
|
copy: src=mongodb.service dest=/lib/systemd/system/mongodb.service owner=root group=root mode=0640
|
2016-09-21 14:33:05 +00:00
|
|
|
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
|
2015-02-25 07:57:36 +00:00
|
|
|
|
|
|
|
- name: Add symlink for systemd
|
|
|
|
file: src=/lib/systemd/system/mongodb.service dest=/etc/systemd/system/multi-user.target.wants/mongodb.service state=link
|
2016-09-21 14:33:05 +00:00
|
|
|
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
|
2015-02-25 07:57:36 +00:00
|
|
|
notify: reload systemd
|
|
|
|
|
|
|
|
- meta: flush_handlers
|
2016-09-21 14:33:05 +00:00
|
|
|
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
|
2015-02-25 07:57:36 +00:00
|
|
|
|
2014-06-04 15:03:58 +00:00
|
|
|
- name: Add APT key
|
2016-04-17 13:43:00 +00:00
|
|
|
apt_key:
|
|
|
|
keyserver: "{{mongodb_apt_keyserver}}"
|
|
|
|
id: "{{mongodb_apt_key_id}}"
|
|
|
|
when: mongodb_package == 'mongodb-org'
|
|
|
|
|
2016-03-03 19:20:08 +00:00
|
|
|
- name: Fail when used wrong mongodb_version variable
|
|
|
|
fail:
|
|
|
|
msg: "mongodb_version variable should be '2.6', '3.0' or '3.2'"
|
2016-04-17 13:43:00 +00:00
|
|
|
when: (mongodb_package == 'mongodb-org' and
|
|
|
|
(mongodb_version is not defined
|
|
|
|
or mongodb_repository[item] is not defined))
|
2016-03-03 19:20:08 +00:00
|
|
|
with_items: "{{ mongodb_version[0:3] }}"
|
|
|
|
|
2015-01-07 11:31:53 +00:00
|
|
|
- name: Add APT repository
|
2016-03-03 19:20:08 +00:00
|
|
|
apt_repository: repo="{{ mongodb_repository[item] }}" update_cache=yes
|
|
|
|
with_items: "{{ mongodb_version[0:3] }}"
|
2016-04-17 13:43:00 +00:00
|
|
|
when: mongodb_package == 'mongodb-org'
|
2015-01-05 13:37:28 +00:00
|
|
|
|
2015-01-07 11:31:53 +00:00
|
|
|
- name: Install MongoDB package
|
2015-06-26 16:56:32 +00:00
|
|
|
apt: name={{item}} state=present
|
|
|
|
with_items:
|
|
|
|
- "{{mongodb_package}}"
|
|
|
|
- numactl
|
2015-02-25 07:57:36 +00:00
|
|
|
|
2015-02-26 14:11:22 +00:00
|
|
|
- name: reload systemd
|
|
|
|
shell: systemctl daemon-reload
|
|
|
|
changed_when: false
|
2016-09-21 14:33:05 +00:00
|
|
|
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
|
2015-01-05 13:37:28 +00:00
|
|
|
|
2015-04-06 16:38:52 +00:00
|
|
|
- name: Install PyMongo package
|
|
|
|
apt: pkg=python-pymongo state=latest
|
|
|
|
when: not mongodb_pymongo_from_pip
|
|
|
|
|
2015-04-06 16:51:47 +00:00
|
|
|
- name: Install PIP
|
2015-04-06 16:38:52 +00:00
|
|
|
apt: pkg={{ item }}
|
|
|
|
with_items:
|
|
|
|
- python-dev
|
|
|
|
- python-pip
|
|
|
|
when: mongodb_pymongo_from_pip
|
|
|
|
|
|
|
|
- name: Install PyMongo from PIP
|
2016-04-17 13:43:00 +00:00
|
|
|
pip: name=pymongo state=latest
|
2015-04-06 16:38:52 +00:00
|
|
|
when: mongodb_pymongo_from_pip
|