From 9c0df22906c3459fcea23786623f289726318e4a Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 25 Aug 2020 16:41:14 -0500 Subject: [PATCH] use mongodb.org repo --- roles/mongodb/tasks/install.yml | 101 ++++++++++++++++++-------------- roles/mongodb/tasks/main.yml | 14 ++--- 2 files changed, 64 insertions(+), 51 deletions(-) diff --git a/roles/mongodb/tasks/install.yml b/roles/mongodb/tasks/install.yml index d0e17d32a..c8d5d9a96 100644 --- a/roles/mongodb/tasks/install.yml +++ b/roles/mongodb/tasks/install.yml @@ -1,13 +1,5 @@ # 1. INSTALL MongoDB PACKAGES OR BINARIES -- name: "Install packages: mongodb, mongodb-server (not raspbian)" - package: - name: - - mongodb-server - - mongodb # 2019-01-31: this package does not exist on (cannot be installed on) Debian 10, SEE #1437 - state: present - when: internet_available and not is_raspbian - # 2019-02-02: Sugarizer with Node.js 10.x requires MongoDB 2.6+ so # 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) @@ -18,33 +10,43 @@ # 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) -- name: Create dir /tmp/mongodb-3.0.1x (raspbian) - file: - path: /tmp/mongodb-3.0.1x - state: directory - when: internet_available and is_raspbian +- block: + - name: Create dir /tmp/mongodb-3.0.1x (raspbian) + file: + path: /tmp/mongodb-3.0.1x + state: directory -- name: Download & unzip 20MB http://download.iiab.io/packages/mongodb_stretch_3_0_14_core.zip to /tmp/mongodb-3.0.1x (raspbian) - unarchive: - remote_src: yes - src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_core.zip" - dest: /tmp/mongodb-3.0.1x - when: internet_available and is_raspbian + - name: Download & unzip 20MB http://download.iiab.io/packages/mongodb_stretch_3_0_14_core.zip to /tmp/mongodb-3.0.1x (raspbian) + unarchive: + remote_src: yes + src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_core.zip" + dest: /tmp/mongodb-3.0.1x -- name: Install (move) its 3 CORE binaries from /tmp/mongodb-3.0.1x/core to /usr/bin (raspbian) - shell: mv /tmp/mongodb-3.0.1x/core/* /usr/bin - when: internet_available and is_raspbian + - name: Install (move) its 3 CORE binaries from /tmp/mongodb-3.0.1x/core to /usr/bin (raspbian) + shell: mv /tmp/mongodb-3.0.1x/core/* /usr/bin -- 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) - unarchive: - remote_src: yes - src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_tools.zip" - dest: /tmp/mongodb-3.0.1x - when: internet_available and is_raspbian + - 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) + unarchive: + remote_src: yes + src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_tools.zip" + dest: /tmp/mongodb-3.0.1x -- name: Install (move) its 9 TOOLS binaries from /opt/iiab/downloads/mongodb-3.0.1x/tools to /usr/bin (raspbian) - shell: mv /tmp/mongodb-3.0.1x/tools/* /usr/bin - when: internet_available and is_raspbian + - name: Install (move) its 9 TOOLS binaries from /opt/iiab/downloads/mongodb-3.0.1x/tools to /usr/bin (raspbian) + shell: mv /tmp/mongodb-3.0.1x/tools/* /usr/bin + + - name: Create Linux group mongodb (raspbian) + group: + name: mongodb + state: present + + - name: Create Linux user mongodb (raspbian) + user: + name: mongodb + group: mongodb # primary group + groups: mongodb + home: /var/lib/mongodb + shell: /usr/sbin/nologin + when: is_raspbian and not (ansible_architecture == aarch64) # OLD WAY / MUCH SLOWER: had put unnec duplicate copies in /opt/iiab/downloads/mongodb-3.0.1x # @@ -84,20 +86,31 @@ # - "{{ downloads_dir }}/mongodb-3.0.1x/tools/*" # when: internet_available and is_raspbian -- name: Create Linux group mongodb (raspbian) - group: - name: mongodb - state: present - when: is_raspbian | bool +- block: + - name: Add mongodb.org signing key + shell: wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - -- name: Create Linux user mongodb (raspbian) - user: - name: mongodb - group: mongodb # primary group - groups: mongodb - home: /var/lib/mongodb - shell: /usr/sbin/nologin - when: is_raspbian | bool + - name: Add mongodb repo for Debian amd64 + apt_repository: + repo: deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main + state: present + filename: mongodb-org + when: is_debian_10 and (ansible_architecture == "amd64") + + - name: Add mongodb repo for Ubuntu + apt_repository: + repo: deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse + state: present + filename: mongodb-org + when: (ansible_architecture == "aarch64") + + - name: "Install packages: mongodb-org, mongodb-org-server" + package: + name: + - mongodb-org + - mongodb-org-server + state: present + when: (ansible_architecture == "aarch64") or ansible_architecture == "amd64") # 2. CONFIGURE MongoDB FOR IIAB diff --git a/roles/mongodb/tasks/main.yml b/roles/mongodb/tasks/main.yml index 0354e808c..eb7623137 100644 --- a/roles/mongodb/tasks/main.yml +++ b/roles/mongodb/tasks/main.yml @@ -31,18 +31,18 @@ - debug: var: is_raspbian -- name: EXIT 'mongodb' ROLE & CONTINUE, IF 'is_debian and not is_raspbian' i.e. TRUE DEBIAN (where MongoDB no longer exists) - fail: # FORCE IT RED THIS ONCE! - msg: ATTEMPTED MongoDB INSTALLATION WITH (TRUE) DEBIAN, which is no longer supported. Nevertheless IIAB will continue (consider this a warning!) - when: is_debian and not is_raspbian - #when: (is_debian and not is_raspbian) and (not is_debian_8) and (not is_debian_9) # Test for Debian 10+ - ignore_errors: yes +#- name: EXIT 'mongodb' ROLE & CONTINUE, IF 'is_debian and not is_raspbian' i.e. TRUE DEBIAN (where MongoDB no longer exists) +# fail: # FORCE IT RED THIS ONCE! +# msg: ATTEMPTED MongoDB INSTALLATION WITH (TRUE) DEBIAN, which is no longer supported. Nevertheless IIAB will continue (consider this a warning!) +# when: is_debian_10 and (ansible_architecture == "aarch64") +# #when: (is_debian and not is_raspbian) and (not is_debian_8) and (not is_debian_9) # Test for Debian 10+ +# ignore_errors: yes # ELSE... - name: Install/Enable/Disable/Record MongoDB (main2.yml) if is_raspbian or not is_debian, i.e. not True Debian include_tasks: main2.yml - when: is_raspbian or not is_debian +# when: is_raspbian or not is_debian # THE block: APPROACH BELOW WORKS JUST LIKE main2.yml ABOVE. # BUT IT VISUALLY POLLUTES: MANY BLUE "skipping:" MESSAGES IN ANSIBLE'S OUTPUT.