mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
MongoDB / Sugarizer cleanup for Debian 11 etc
This commit is contained in:
parent
8d2baf0bfe
commit
cb1a57bdab
11 changed files with 76 additions and 88 deletions
13
roles/mongodb/tasks/enable-or-disable.yml
Normal file
13
roles/mongodb/tasks/enable-or-disable.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
- name: Enable & (Re)Start 'mongodb.service' if mongodb_enabled
|
||||
systemd:
|
||||
name: mongodb
|
||||
enabled: yes
|
||||
state: restarted
|
||||
when: mongodb_enabled
|
||||
|
||||
- name: Disable & Stop 'mongodb.service' if not mongodb_enabled
|
||||
systemd:
|
||||
name: mongodb
|
||||
enabled: no
|
||||
state: stopped
|
||||
when: not mongodb_enabled
|
|
@ -114,7 +114,7 @@
|
|||
- mongodb-org-server
|
||||
state: present
|
||||
|
||||
- name: Change {{ mongodb_conf }} port to {{ mongodb_port }}
|
||||
- name: Change {{ mongodb_conf }} port to {{ mongodb_port }} -- takes effect on next (re)start of the service -- via enable-or-disable.yml or via Sugarizer starting MongoDB on demand
|
||||
lineinfile:
|
||||
path: "{{ mongodb_conf }}"
|
||||
regexp: "port: 27017"
|
||||
|
@ -137,7 +137,7 @@
|
|||
#- { path: '/var/run/mongodb' }
|
||||
- /var/lib/mongodb
|
||||
- /var/log/mongodb
|
||||
- "{{ mongodb_db_path }}" # i.e. /library/dbdata/mongodb/
|
||||
- "{{ mongodb_db_path }}" # /library/dbdata/mongodb
|
||||
|
||||
- name: Install mongodb.service, /usr/bin/iiab-mongodb-repair-if-no-lock from templates
|
||||
template:
|
||||
|
@ -150,14 +150,9 @@
|
|||
- { src: 'mongodb.service.j2', dest: '/etc/systemd/system/mongodb.service', mode: '0644' }
|
||||
- { src: 'iiab-mongodb-repair-if-no-lock.j2', dest: '/usr/bin/iiab-mongodb-repair-if-no-lock', mode: '0755' }
|
||||
|
||||
# daemon_reload is used to force systemd to recognize a newly installed .service file
|
||||
# restarted here to ensure the port has been changed
|
||||
- name: Disable 'mongodb' systemd service - started on demand by Sugarizer
|
||||
- name: systemctl daemon_reload, so systemd (re)reads mongodb.service
|
||||
systemd:
|
||||
name: mongodb
|
||||
daemon_reload: yes
|
||||
enabled: no
|
||||
state: restarted
|
||||
|
||||
|
||||
# 3. RECORD MongoDB AS INSTALLED
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
var: mongodb_installed
|
||||
|
||||
|
||||
- debug:
|
||||
var: rpi_model # 0-init sets it from ansible_local.local_facts.rpi_model
|
||||
- debug:
|
||||
var: ansible_local.local_facts.os_ver # Like OS_VER in /etc/iiab/iiab.env
|
||||
- debug:
|
||||
var: is_debian
|
||||
- debug:
|
||||
|
@ -39,19 +43,16 @@
|
|||
ignore_errors: yes
|
||||
|
||||
# ELSE...
|
||||
|
||||
- name: Install MongoDB if 'mongodb_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
|
||||
include_tasks: install.yml
|
||||
when: mongodb_installed is undefined and not (ansible_architecture == "aarch64" and is_debian_10 and not is_raspbian)
|
||||
|
||||
- name: Disable & Stop 'mongodb' service, if not mongodb_enabled
|
||||
systemd:
|
||||
name: mongodb
|
||||
enabled: no
|
||||
state: stopped
|
||||
when: not mongodb_enabled and mongodb_installed is defined
|
||||
|
||||
#'mongodb' systemd service - started on demand by sugarizer
|
||||
# Just recording that mongodb should be running
|
||||
- name: Enable or Disable MongoDB, if mongodb_installed is defined (Sugarizer starts MongoDB on demand, so doesn't need this or care what happens here!)
|
||||
include_tasks: enable-or-disable.yml
|
||||
when: mongodb_installed is defined
|
||||
|
||||
|
||||
- name: Add 'mongodb' variable values to {{ iiab_ini_file }}
|
||||
ini_file:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue