67 lines
2.0 KiB
YAML
67 lines
2.0 KiB
YAML
---
|
|
|
|
- include_vars: "{{ansible_distribution}}.yml"
|
|
|
|
- name: Check if running on systemd
|
|
stat: path=/sbin/init
|
|
register: sbin_init
|
|
changed_when: false
|
|
always_run: yes # side-effect free, so it can be run in check-mode as well
|
|
|
|
- name: Add systemd configuration if present
|
|
copy: src=mongodb.service dest=/lib/systemd/system/mongodb.service owner=root group=root mode=0640
|
|
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
|
|
|
|
- name: Add symlink for systemd
|
|
file: src=/lib/systemd/system/mongodb.service dest=/etc/systemd/system/multi-user.target.wants/mongodb.service state=link
|
|
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
|
|
notify: reload systemd
|
|
|
|
- meta: flush_handlers
|
|
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
|
|
|
|
- name: Add APT key
|
|
apt_key:
|
|
keyserver: "{{mongodb_apt_keyserver}}"
|
|
id: "{{mongodb_apt_key_id}}"
|
|
when: mongodb_package == 'mongodb-org'
|
|
|
|
- name: Fail when used wrong mongodb_version variable
|
|
fail:
|
|
msg: "mongodb_version variable should be '2.6', '3.0' or '3.2'"
|
|
when: (mongodb_package == 'mongodb-org' and
|
|
(mongodb_version is not defined
|
|
or mongodb_repository[item] is not defined))
|
|
with_items: "{{ mongodb_version[0:3] }}"
|
|
|
|
- name: Add APT repository
|
|
apt_repository: repo="{{ mongodb_repository[item] }}" update_cache=yes
|
|
with_items: "{{ mongodb_version[0:3] }}"
|
|
when: mongodb_package == 'mongodb-org'
|
|
|
|
- name: Install MongoDB package
|
|
apt: name={{item}} state=present
|
|
with_items:
|
|
- "{{mongodb_package}}"
|
|
- numactl
|
|
|
|
- name: reload systemd
|
|
shell: systemctl daemon-reload
|
|
changed_when: false
|
|
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
|
|
|
|
- name: Install PyMongo package
|
|
apt: pkg=python-pymongo state=latest
|
|
when: not mongodb_pymongo_from_pip
|
|
|
|
- name: Install PIP
|
|
apt: pkg={{ item }}
|
|
with_items:
|
|
- python-dev
|
|
- python-pip
|
|
when: mongodb_pymongo_from_pip
|
|
|
|
- name: Install PyMongo from PIP
|
|
pip: name=pymongo state=latest
|
|
when: mongodb_pymongo_from_pip
|