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

89 lines
2.8 KiB
YAML
Raw Normal View History

2014-06-04 19:03:58 +04: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:
2019-05-25 22:52:10 -04:00
- mongodb_disable_transparent_hugepages | bool
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'
- (mongodb_major_version != '3.6' and mongodb_major_version != '4.0')
- ansible_distribution_release == 'stretch'
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_major_version != '4.0'
2019-05-21 09:43:56 +02:00
- 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
2019-05-23 00:37:39 -04:00
apt_repository:
repo: "{{ mongodb_repository[version_item] }}"
update_cache: true
with_items: "{{ mongodb_major_version }}"
2019-05-23 00:37:39 -04:00
loop_control:
loop_var: version_item
2016-04-17 19:43:00 +06:00
when: mongodb_package == 'mongodb-org'
- name: Install MongoDB package
2019-05-21 15:42:02 -04:00
apt:
name: "{{ mongodb_package }}{% if (mongodb_version | length > 3) %}={{ mongodb_version }}{% endif %}"
2019-05-21 16:39:59 -04:00
state: "{{ mongodb_package_state }}"
2019-05-21 15:42:02 -04:00
update_cache: true
2015-02-25 08:57:36 +01:00
- name: Install numactl package
apt:
name: numactl
state: present
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"
2019-05-23 00:37:39 -04:00
notify:
- reload 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
2019-05-25 22:52:10 -04:00
when: mongodb_pymongo_from_pip | bool
2015-04-06 19:38:52 +03:00
- 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) }}"
2019-05-25 22:52:10 -04:00
when: mongodb_pymongo_from_pip | bool