ansible-role-mongodb/tasks/install.debian.yml

97 lines
3.1 KiB
YAML
Raw Normal View History

2014-06-04 19:03:58 +04:00
---
- name: Check if running on systemd
stat: path=/sbin/init
register: sbin_init
2015-06-16 14:19:58 +06:00
changed_when: false
2018-02-15 13:14:31 +07:00
check_mode: no
2015-02-25 08:57:36 +01:00
- name: Establish some role-related facts
set_fact:
mongodb_major_version: "{{ mongodb_version[0:3] }}"
2015-02-25 08:57:36 +01:00
- name: Disable transparent huge pages on systemd systems
include_tasks: disable_transparent_hugepages.yml
when:
- mongodb_disable_transparent_hugepages
2019-05-21 15:42:02 -04:00
- ansible_service_mgr == "systemd"
2014-06-04 19:03:58 +04:00
- name: Add APT key
2016-04-17 19:43:00 +06:00
apt_key:
2017-06-16 13:58:39 +02:00
keyserver: "{{ mongodb_apt_keyserver }}"
id: "{{ mongodb_apt_key_id[mongodb_major_version] }}"
2016-04-17 19:43:00 +06:00
when: mongodb_package == 'mongodb-org'
- name: Fail when used wrong mongodb_version variable with Debian Stretch
fail:
msg: "mongodb_version variable should be '3.6' or '4.0' for Debian Stretch"
when: (mongodb_package == 'mongodb-org' and
(mongodb_version is not defined
or mongodb_repository[mongodb_major_version] is not defined
2019-05-21 09:43:56 +02:00
or (mongodb_version != '3.6' and mongodb_version != '4.0'))
2018-10-03 12:41:39 +02:00
and (ansible_distribution_release == 'stretch' and ansible_distribution_release == 'jessie'))
2018-07-13 18:50:23 -04:00
2018-07-13 18:59:35 -04:00
- name: Fail when used wrong mongodb_version variable with Ubuntu 18.04
2018-07-13 18:50:23 -04:00
fail:
msg: "mongodb_version variable should be '4.0' or else mongodb_package should be 'mongodb' for Ubuntu 18.04"
2019-05-21 09:43:56 +02:00
when:
- mongodb_package == 'mongodb-org'
- mongodb_version != '4.0'
- ansible_distribution_release == "bionic"
- name: Fail when used wrong mongodb_version variable
fail:
msg: "mongodb_version variable should be '3.4', '3.6' or '4.0'"
2016-04-17 19:43:00 +06:00
when: (mongodb_package == 'mongodb-org' and
(mongodb_version is not defined
or mongodb_repository[mongodb_major_version] is not defined))
2015-01-07 14:31:53 +03:00
- name: Add APT repository
apt_repository: repo="{{ mongodb_repository[item] }}" update_cache=yes
with_items: "{{ mongodb_major_version }}"
2016-04-17 19:43:00 +06:00
when: mongodb_package == 'mongodb-org'
2015-01-07 14:31:53 +03:00
- name: Install MongoDB package
2019-05-21 15:42:02 -04:00
apt:
name: "{{ mongodb_package }}"
state: "{{ mongodb_package_version is defined | ternary('present', 'latest') }}"
version: "{{ mongodb_package_version | default(omit) }}"
update_cache: true
- name: Install numactl package
apt:
name: numactl
state: present
update_cache: true
2015-02-25 08:57:36 +01:00
2018-02-23 19:35:03 +07:00
- name: Add systemd configuration if present
2019-05-15 17:09:06 +02:00
copy: src=mongodb.service dest=/lib/systemd/system/mongodb.service owner=root group=root mode=0644
2019-05-21 15:42:02 -04:00
when: ansible_service_mgr == "systemd"
2018-02-23 19:35:03 +07: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
2019-05-21 15:42:02 -04:00
when: ansible_service_mgr == "systemd"
2018-02-23 19:35:03 +07:00
2019-04-09 10:40:48 +02:00
- block:
2019-05-21 15:42:02 -04:00
- meta: flush_handlers
when: ansible_service_mgr == "systemd"
2015-04-06 19:38:52 +03:00
- name: Install PyMongo package
2019-05-21 15:42:02 -04:00
apt:
name: python-pymongo
2015-04-06 19:38:52 +03:00
when: not mongodb_pymongo_from_pip
2015-04-06 19:51:47 +03:00
- name: Install PIP
2019-04-09 10:00:17 +02:00
apt:
pkg:
- python-dev
- python-pip
2015-04-06 19:38:52 +03:00
when: mongodb_pymongo_from_pip
- name: Install PyMongo from PIP
pip:
name: pymongo
state: "{{ mongodb_pymongo_pip_version is defined | ternary('present', 'latest') }}"
version: "{{ mongodb_pymongo_pip_version | default(omit) }}"
2015-04-06 19:38:52 +03:00
when: mongodb_pymongo_from_pip