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

105 lines
3.2 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:
2019-09-10 12:24:56 +02:00
msg: "mongodb_version variable should be '3.6' or '4.0' or '4.2' for Debian Stretch"
when:
- mongodb_package == 'mongodb-org'
2019-09-10 12:24:56 +02:00
- (mongodb_major_version != '3.6' and mongodb_major_version != '4.0' and mongodb_major_version != '4.2')
- 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:
2019-09-10 12:24:56 +02:00
msg: "mongodb_version variable should be '4.0' or '4.2', or else mongodb_package should be 'mongodb' for Ubuntu 18.04"
2019-05-21 09:43:56 +02:00
when:
- mongodb_package == 'mongodb-org'
2019-09-10 12:24:56 +02:00
- (mongodb_major_version != '4.0' and mongodb_major_version != '4.2')
2019-05-21 09:43:56 +02:00
- ansible_distribution_release == "bionic"
- name: Fail when used wrong mongodb_version variable
fail:
2019-09-10 12:24:56 +02:00
msg: "mongodb_version variable should be '3.4', '3.6' or '4.0' or '4.2'"
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
copy:
src: mongodb.service
dest: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
owner: root
group: root
mode: '0644'
when: ansible_service_mgr == "systemd" and mongodb_manage_systemd_unit | bool
2019-05-28 13:39:54 -04:00
notify:
- reload systemd
2018-02-23 19:35:03 +07:00
- name: Add symlink for systemd
file:
src: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
dest: "/etc/systemd/system/multi-user.target.wants/{{mongodb_daemon_name}}.service"
state: link
when: ansible_service_mgr == "systemd" and mongodb_manage_systemd_unit | bool
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
2019-09-27 16:47:58 +02:00
- name: Install setuptools (required for ansible 2.7+)
apt:
pkg:
- python-setuptools
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