ansible-roles/mongodb/tasks/main_bullseye.yml

103 lines
2.3 KiB
YAML
Raw Normal View History

2021-05-01 17:51:50 +02:00
---
- fail:
2023-03-19 11:44:53 +01:00
msg: MongoDB versions <4.2 are not compatible with Debian 11 (Bullseye)
when:
2023-01-06 09:54:51 +01:00
- ansible_distribution_release == "bullseye"
2023-03-19 11:44:53 +01:00
- mongodb_version is version('5.2', '<')
- name: Add MongoDB GPG key
2021-05-01 17:51:50 +02:00
copy:
2022-12-28 09:03:37 +01:00
src: "server-{{ mongodb_version }}.asc"
dest: "{{ apt_keyring_dir }}/mongodb-server-{{ mongodb_version }}.asc"
2021-05-01 17:51:50 +02:00
force: yes
2021-05-02 00:33:26 +02:00
mode: "0644"
owner: root
group: root
2021-05-01 17:51:50 +02:00
2023-03-19 11:44:53 +01:00
- name: Add MongoDB repository
2021-05-01 17:51:50 +02:00
apt_repository:
2022-12-28 09:03:37 +01:00
repo: "deb [signed-by={{ apt_keyring_dir }}/mongodb-server-{{ mongodb_version }}.asc] http://repo.mongodb.org/apt/debian bullseye/mongodb-org/{{ mongodb_version }} main"
2021-05-01 17:51:50 +02:00
state: present
2022-12-28 09:03:37 +01:00
filename: "mongodb-org-{{ mongodb_version }}"
2021-05-01 17:51:50 +02:00
- name: Install packages
apt:
name: mongodb-org
update_cache: yes
state: present
register: _mongodb_install_package
- name: MongoDB service in enabled and started
systemd:
name: mongod
enabled: yes
state: started
when: _mongodb_install_package is changed
2021-05-01 17:51:50 +02:00
- name: install dependency for monitoring
apt:
name: python3-pymongo
2021-05-01 17:51:50 +02:00
state: present
- name: Custom configuration
template:
src: mongodb_bullseye.conf.j2
2021-05-01 17:51:50 +02:00
dest: "/etc/mongod.conf"
force: "{{ mongodb_force_config | bool | ternary('yes', 'no') }}"
notify: restart mongod
- name: Configure logrotate
template:
src: logrotate_bullseye.j2
2021-05-01 17:51:50 +02:00
dest: /etc/logrotate.d/mongodb
force: yes
backup: no
- include_role:
name: evolix/remount-usr
- name: Create plugin directory
file:
name: /usr/local/share/munin/
state: directory
mode: "0755"
- name: Create plugin directory
file:
name: /usr/local/share/munin/plugins/
state: directory
mode: "0755"
2021-05-01 17:51:50 +02:00
- name: Munin plugins are present
copy:
src: "munin/{{ item }}"
dest: '/usr/local/share/munin/plugins/{{ item }}'
force: yes
loop:
2021-05-01 17:51:50 +02:00
- mongo_btree
- mongo_collections
- mongo_conn
- mongo_docs
- mongo_lock
- mongo_mem
- mongo_ops
- mongo_page_faults
notify: restart munin-node
- name: Enable core Munin plugins
file:
src: '/usr/local/share/munin/plugins/{{ item }}'
dest: /etc/munin/plugins/{{ item }}
state: link
loop:
2021-05-01 17:51:50 +02:00
- mongo_btree
- mongo_collections
- mongo_conn
- mongo_docs
- mongo_lock
- mongo_mem
- mongo_ops
- mongo_page_faults
notify: restart munin-node