2019-02-02 15:03:49 +00:00
|
|
|
# 1. INSTALL MongoDB PACKAGES OR BINARIES
|
|
|
|
|
2020-05-21 17:00:01 +00:00
|
|
|
- name: "Install packages: mongodb, mongodb-server (not raspbian)"
|
2018-07-12 00:49:03 +00:00
|
|
|
package:
|
2018-10-28 17:41:54 +00:00
|
|
|
name:
|
|
|
|
- mongodb-server
|
2019-01-31 16:07:12 +00:00
|
|
|
- mongodb # 2019-01-31: this package does not exist on (cannot be installed on) Debian 10, SEE #1437
|
2018-07-12 00:49:03 +00:00
|
|
|
state: present
|
2020-03-04 21:41:48 +00:00
|
|
|
when: internet_available and not is_raspbian
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2019-02-02 15:03:49 +00:00
|
|
|
# 2019-02-02: Sugarizer with Node.js 10.x requires MongoDB 2.6+ so
|
2020-05-21 17:00:01 +00:00
|
|
|
# https://andyfelong.com/2017/08/mongodb-3-0-14-for-raspbian-stretch/ is
|
|
|
|
# being used on Raspbian, all I found! (Raspbian's apt pkg is MongoDB 2.4.14)
|
2019-02-02 15:03:49 +00:00
|
|
|
#
|
|
|
|
# mongodb_stretch_3_0_14_core.zip (20M) & mongodb_stretch_3_0_14_tools.zip (15M)
|
|
|
|
# were backed up from andyfelong.com to http://download.iiab.io/packages/
|
|
|
|
#
|
|
|
|
# CLARIF: mongodb_stretch_3_0_14_core.zip IS IN FACT 3.0.14 (core) BUT...
|
|
|
|
# mongodb_stretch_3_0_14_tools.zip IS REALLY 3.0.15 (tools)
|
|
|
|
|
2020-05-21 17:00:01 +00:00
|
|
|
- name: Create dir /tmp/mongodb-3.0.1x (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
file:
|
|
|
|
path: /tmp/mongodb-3.0.1x
|
|
|
|
state: directory
|
2020-03-04 21:41:48 +00:00
|
|
|
when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
|
2020-05-21 17:00:01 +00:00
|
|
|
- name: Download & unzip 20MB http://download.iiab.io/packages/mongodb_stretch_3_0_14_core.zip to /tmp/mongodb-3.0.1x (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
unarchive:
|
|
|
|
remote_src: yes
|
|
|
|
src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_core.zip"
|
|
|
|
dest: /tmp/mongodb-3.0.1x
|
2020-03-04 21:41:48 +00:00
|
|
|
when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
|
2020-05-21 17:00:01 +00:00
|
|
|
- name: Install (move) its 3 CORE binaries from /tmp/mongodb-3.0.1x/core to /usr/bin (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
shell: mv /tmp/mongodb-3.0.1x/core/* /usr/bin
|
2020-03-04 21:41:48 +00:00
|
|
|
when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
|
2020-05-21 17:00:01 +00:00
|
|
|
- name: Download & unzip 15MB http://download.iiab.io/packages/mongodb_stretch_3_0_14_tools.zip [IN FACT THIS ONE'S 3.0.15] to /tmp/mongodb-3.0.1x (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
unarchive:
|
|
|
|
remote_src: yes
|
|
|
|
src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_tools.zip"
|
|
|
|
dest: /tmp/mongodb-3.0.1x
|
2020-03-04 21:41:48 +00:00
|
|
|
when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
|
2020-05-21 17:00:01 +00:00
|
|
|
- name: Install (move) its 9 TOOLS binaries from /opt/iiab/downloads/mongodb-3.0.1x/tools to /usr/bin (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
shell: mv /tmp/mongodb-3.0.1x/tools/* /usr/bin
|
2020-03-04 21:41:48 +00:00
|
|
|
when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
|
|
|
|
# OLD WAY / MUCH SLOWER: had put unnec duplicate copies in /opt/iiab/downloads/mongodb-3.0.1x
|
|
|
|
#
|
2020-05-21 17:00:01 +00:00
|
|
|
#- name: Create dir /opt/iiab/downloads/mongodb-3.0.1x (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
# file:
|
|
|
|
# path: "{{ downloads_dir }}/mongodb-3.0.1x"
|
|
|
|
# state: directory
|
2020-03-04 21:41:48 +00:00
|
|
|
# when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
#
|
2020-05-21 17:00:01 +00:00
|
|
|
#- name: Download & unzip MongoDB 3.0.14's 3 core binaries to /opt/iiab/downloads/mongodb-3.0.1x (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
# unarchive:
|
|
|
|
# remote_src: yes
|
|
|
|
# src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_core.zip"
|
|
|
|
# dest: "{{ downloads_dir }}/mongodb-3.0.1x"
|
2020-03-04 21:41:48 +00:00
|
|
|
# when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
#
|
2020-05-21 17:00:01 +00:00
|
|
|
#- name: Install (copy) 3 binaries from /opt/iiab/downloads/mongodb-3.0.1x/core to /usr/bin (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
# copy:
|
|
|
|
# src: "{{ item }}"
|
|
|
|
# dest: /usr/bin
|
|
|
|
# with_fileglob:
|
|
|
|
# - "{{ downloads_dir }}/mongodb-3.0.1x/core/*"
|
2020-03-04 21:41:48 +00:00
|
|
|
# when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
#
|
2020-05-21 17:00:01 +00:00
|
|
|
#- name: Download & unzip MongoDB 3.0.15's 9 tools binaries to /opt/iiab/downloads/mongodb-3.0.1x (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
# unarchive:
|
|
|
|
# remote_src: yes
|
|
|
|
# src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_tools.zip"
|
|
|
|
# dest: "{{ downloads_dir }}/mongodb-3.0.1x"
|
2020-03-04 21:41:48 +00:00
|
|
|
# when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
#
|
2020-05-21 17:00:01 +00:00
|
|
|
#- name: Install (copy) 9 binaries from /opt/iiab/downloads/mongodb-3.0.1x/tools to /usr/bin (raspbian)
|
2019-02-02 15:03:49 +00:00
|
|
|
# copy:
|
|
|
|
# src: "{{ item }}"
|
|
|
|
# dest: /usr/bin
|
|
|
|
# with_fileglob:
|
|
|
|
# - "{{ downloads_dir }}/mongodb-3.0.1x/tools/*"
|
2020-03-04 21:41:48 +00:00
|
|
|
# when: internet_available and is_raspbian
|
2019-02-02 15:03:49 +00:00
|
|
|
|
2020-05-21 17:00:01 +00:00
|
|
|
- name: Create Linux group mongodb (raspbian)
|
2019-02-02 19:38:52 +00:00
|
|
|
group:
|
|
|
|
name: mongodb
|
|
|
|
state: present
|
2020-03-04 21:41:48 +00:00
|
|
|
when: is_raspbian | bool
|
2019-02-02 19:38:52 +00:00
|
|
|
|
2020-05-21 17:00:01 +00:00
|
|
|
- name: Create Linux user mongodb (raspbian)
|
2019-02-02 18:48:50 +00:00
|
|
|
user:
|
|
|
|
name: mongodb
|
2019-02-02 19:38:52 +00:00
|
|
|
group: mongodb # primary group
|
|
|
|
groups: mongodb
|
2019-02-02 18:48:50 +00:00
|
|
|
home: /var/lib/mongodb
|
|
|
|
shell: /usr/sbin/nologin
|
2020-03-04 21:41:48 +00:00
|
|
|
when: is_raspbian | bool
|
2019-02-02 18:48:50 +00:00
|
|
|
|
|
|
|
|
2020-01-29 15:23:00 +00:00
|
|
|
# 2. CONFIGURE MongoDB FOR IIAB
|
2019-02-02 15:03:49 +00:00
|
|
|
|
2019-02-02 19:38:52 +00:00
|
|
|
- name: 'Create 3 dirs for MongoDB: /var/lib/mongodb, /var/log/mongodb, {{ mongodb_db_path }}'
|
2018-07-12 00:49:03 +00:00
|
|
|
file:
|
|
|
|
state: directory
|
2019-02-02 19:38:52 +00:00
|
|
|
path: "{{ item }}"
|
2018-07-12 00:49:03 +00:00
|
|
|
owner: mongodb
|
2019-02-02 19:38:52 +00:00
|
|
|
group: mongodb
|
2017-05-27 18:09:50 +00:00
|
|
|
with_items:
|
2019-02-02 19:38:52 +00:00
|
|
|
#- { path: '/var/run/mongodb' }
|
|
|
|
- /var/lib/mongodb
|
|
|
|
- /var/log/mongodb
|
|
|
|
- "{{ mongodb_db_path }}" # i.e. /library/dbdata/mongodb/
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2019-01-31 16:07:12 +00:00
|
|
|
- name: Install /etc/mongod.conf, mongodb.service, /usr/bin/iiab-mongodb-repair-if-no-lock from templates
|
2018-07-12 00:49:03 +00:00
|
|
|
template:
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
2018-07-23 14:01:21 +00:00
|
|
|
mode: "{{ item.mode }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
with_items:
|
2019-02-02 19:38:52 +00:00
|
|
|
- { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}", mode: '0644' } # i.e. /etc/mongod.conf
|
2018-07-23 14:01:21 +00:00
|
|
|
- { 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' }
|
2018-07-22 15:01:31 +00:00
|
|
|
|
2020-01-29 15:23:00 +00:00
|
|
|
|
2020-01-30 09:00:00 +00:00
|
|
|
# 3. RECORD MongoDB AS INSTALLED
|
2020-01-29 15:23:00 +00:00
|
|
|
|
2020-01-30 09:00:00 +00:00
|
|
|
- name: "Set 'mongodb_installed: True'"
|
|
|
|
set_fact:
|
2020-01-29 16:43:59 +00:00
|
|
|
mongodb_installed: True
|
|
|
|
|
2020-01-12 23:15:33 +00:00
|
|
|
- name: "Add 'mongodb_installed: True' to {{ iiab_state_file }}"
|
2019-10-14 17:18:16 +00:00
|
|
|
lineinfile:
|
2020-02-04 00:54:04 +00:00
|
|
|
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
2019-10-14 17:18:16 +00:00
|
|
|
regexp: '^mongodb_installed'
|
|
|
|
line: 'mongodb_installed: True'
|