mongodb: prepare Debian 12
This commit is contained in:
parent
f8f5bec8b5
commit
a0986f034d
|
@ -12,3 +12,5 @@
|
||||||
- ansible.builtin.import_tasks: main_bullseye.yml
|
- ansible.builtin.import_tasks: main_bullseye.yml
|
||||||
when: ansible_distribution_release == "bullseye"
|
when: ansible_distribution_release == "bullseye"
|
||||||
|
|
||||||
|
- ansible.builtin.import_tasks: main_bookworm.yml
|
||||||
|
when: ansible_distribution_release == "bookworm"
|
||||||
|
|
103
mongodb/tasks/main_bookworm.yml
Normal file
103
mongodb/tasks/main_bookworm.yml
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- fail:
|
||||||
|
msg: MongoDB is not compatible with Debian 12 (Bookworm)
|
||||||
|
when:
|
||||||
|
- ansible_distribution_release == "bookworm"
|
||||||
|
|
||||||
|
# - fail:
|
||||||
|
# msg: MongoDB version <5 are not compatible with Debian 12 (Bookworm)
|
||||||
|
# when:
|
||||||
|
# - ansible_distribution_release == "bookworm"
|
||||||
|
# - mongodb_version is version('5.0', '<')
|
||||||
|
|
||||||
|
- name: Add MongoDB repository
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: mongodb.sources.j2
|
||||||
|
dest: /etc/apt/sources.list.d/mongodb.sources
|
||||||
|
state: present
|
||||||
|
register: mongodb_sources
|
||||||
|
|
||||||
|
- name: Update APT cache
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: yes
|
||||||
|
when: mongodb_sources is changed
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: mongodb-org
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: install dependency for monitoring
|
||||||
|
apt:
|
||||||
|
name: python3-pymongo
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Custom configuration
|
||||||
|
template:
|
||||||
|
src: mongodb_bullseye.conf.j2
|
||||||
|
dest: "/etc/mongod.conf"
|
||||||
|
force: "{{ mongodb_force_config | bool | ternary('yes', 'no') }}"
|
||||||
|
notify: restart mongod
|
||||||
|
|
||||||
|
- name: Configure logrotate
|
||||||
|
template:
|
||||||
|
src: logrotate_bullseye.j2
|
||||||
|
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"
|
||||||
|
|
||||||
|
- name: Munin plugins are present
|
||||||
|
copy:
|
||||||
|
src: "munin/{{ item }}"
|
||||||
|
dest: '/usr/local/share/munin/plugins/{{ item }}'
|
||||||
|
force: yes
|
||||||
|
loop:
|
||||||
|
- 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:
|
||||||
|
- mongo_btree
|
||||||
|
- mongo_collections
|
||||||
|
- mongo_conn
|
||||||
|
- mongo_docs
|
||||||
|
- mongo_lock
|
||||||
|
- mongo_mem
|
||||||
|
- mongo_ops
|
||||||
|
- mongo_page_faults
|
||||||
|
notify: restart munin-node
|
8
mongodb/templates/mongodb.sources.j2
Normal file
8
mongodb/templates/mongodb.sources.j2
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# {{ansible_managed }}
|
||||||
|
|
||||||
|
Types: deb
|
||||||
|
URIs: http://repo.mongodb.org/apt/debian
|
||||||
|
Suites: bookworm/mongodb-org/{{ mongodb_version }}
|
||||||
|
Components: main
|
||||||
|
Signed-by: {{ apt_keyring_dir }}/mongodb-server-{{ mongodb_version }}.asc
|
||||||
|
Enabled: yes
|
Loading…
Reference in a new issue