1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00

Merge pull request #1430 from holta/sugarizer-masters-on-node-10

sugarizer v1.1.0 + sugarizer-server dev branch on Node.js 10.x [FAILURE to reach MongoDB]
This commit is contained in:
A Holt 2019-02-02 20:36:24 -05:00 committed by GitHub
commit d1f59a05fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 342 additions and 120 deletions

View file

@ -80,6 +80,12 @@
path: /etc/apache2/sites-enabled/awstats.conf
state: absent
when: not awstats_enabled and is_debuntu
- name: Restart Apache service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
state: restarted
- name: Install /etc/awstats/awstats.schoolserver.conf
template:

View file

@ -1,4 +1,5 @@
- include_tasks: install.yml
- name: Install AWStats if awstats_install
include_tasks: install.yml
when: awstats_install
- name: Add 'awstats' variable values to {{ iiab_ini_file }}

View file

@ -5,7 +5,7 @@
path: "/usr/bin/calibre"
register: calib_executable
- name: Install latest packages calibre and calibre-bin, via OS's package installer (IF not rpi AND /usr/bin/calibre MISSING)
- name: "Install OS's latest packages: calibre, calibre-bin (IF not rpi AND /usr/bin/calibre MISSING)"
package:
name:
- calibre
@ -51,14 +51,14 @@
when: (not calib_executable.stat.exists)
#when: calibre_config.changed
# 2. STOP CALIBRE SERVICE IF IT EXISTS (REQUIRED FOR DB ACTIVITY...AND IF not calibre_enabled)
# 2. STOP CALIBRE SERVICE (REQUIRED FOR DB ACTIVITY...AND IF not calibre_enabled)
#- name: Check if Calibre systemd service exists
# stat:
# path: /etc/systemd/system/calibre-serve.service
# register: calibre_svc
- name: Stop Calibre service -- calibre-server by Kovid Goyal
- name: Stop service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal)
systemd:
name: calibre-serve
state: stopped
@ -116,7 +116,7 @@
state: absent
when: (not calibre_enabled) and is_debuntu
- name: Enable & Start Calibre service -- runs calibre-server by Kovid Goyal
- name: Enable & Start service 'calibre-serve' (/usr/bin/calibre-server by Kovid Goyal)
service:
name: calibre-serve
enabled: yes
@ -125,7 +125,7 @@
#async: 900
#poll: 5
- name: Reload Apache
- name: Reload Apache service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
state: reloaded

View file

@ -1,5 +1,5 @@
# administer this service by browsing to localhost:631
- name: Install cups package
- name: Install 'cups' package
package:
name: cups
state: present

View file

@ -91,7 +91,7 @@
when: not kolibri_enabled
# {{ apache_service }} is almost always apache2
- name: Restart {{ apache_service }}
- name: Restart Apache service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
state: restarted

View file

@ -1,3 +1,3 @@
- name: Run Lokole's install.yml if lokole_install
- name: Install Lokole {{ lokole_version }} if lokole_install
include_tasks: install.yml
when: lokole_install

View file

@ -78,8 +78,8 @@
state: absent
when: not mediawiki_enabled and is_debuntu
- name: Restart Apache to enable/disable http://box{{ mediawiki_url }}
service:
- name: Restart Apache service ({{ apache_service }}) to enable/disable http://box{{ mediawiki_url }}
systemd:
name: "{{ apache_service }}"
state: restarted

View file

@ -1,6 +1,10 @@
mongodb_install: False
mongodb_enabled: False
# mongodb_install: False
# mongodb_enabled: False
# mongodb_port: 27018
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
mongodb_conf: /etc/mongod.conf
mongodb_db_path: "{{ content_base }}/dbdata/mongodb" # == /library/dbdata/mongodb/
mongodb_db_path: "{{ content_base }}/dbdata/mongodb" # i.e. /library/dbdata/mongodb/
mongodb_db_lock_file: "{{ mongodb_db_path }}/mongod.lock"

View file

@ -1,24 +1,122 @@
- name: 'Install packages: mongodb, mongodb-server'
# 1. INSTALL MongoDB PACKAGES OR BINARIES
- name: "Install packages: mongodb, mongodb-server (not rpi)"
package:
name:
- mongodb-server
- mongodb
- mongodb # 2019-01-31: this package does not exist on (cannot be installed on) Debian 10, SEE #1437
state: present
when: internet_available
when: internet_available and not is_rpi
tags:
- download
- name: Create 3 dirs for MongoDB
# 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 RPi, all I found! (Raspbian's apt pkg is MongoDB 2.4.14)
#
# 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)
- name: Create dir /tmp/mongodb-3.0.1x (rpi)
file:
path: /tmp/mongodb-3.0.1x
state: directory
when: internet_available and is_rpi
- name: Download & unzip 20MB http://download.iiab.io/packages/mongodb_stretch_3_0_14_core.zip to /tmp/mongodb-3.0.1x (rpi)
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_rpi
- name: Install (move) its 3 CORE binaries from /tmp/mongodb-3.0.1x/core to /usr/bin (rpi)
shell: mv /tmp/mongodb-3.0.1x/core/* /usr/bin
when: internet_available and is_rpi
- 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 (rpi)
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_rpi
- name: Install (move) its 9 TOOLS binaries from /opt/iiab/downloads/mongodb-3.0.1x/tools to /usr/bin (rpi)
shell: mv /tmp/mongodb-3.0.1x/tools/* /usr/bin
when: internet_available and is_rpi
# OLD WAY / MUCH SLOWER: had put unnec duplicate copies in /opt/iiab/downloads/mongodb-3.0.1x
#
#- name: Create dir /opt/iiab/downloads/mongodb-3.0.1x (rpi)
# file:
# path: "{{ downloads_dir }}/mongodb-3.0.1x"
# state: directory
# when: internet_available and is_rpi
#
#- name: Download & unzip MongoDB 3.0.14's 3 core binaries to /opt/iiab/downloads/mongodb-3.0.1x (rpi)
# unarchive:
# remote_src: yes
# src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_core.zip"
# dest: "{{ downloads_dir }}/mongodb-3.0.1x"
# when: internet_available and is_rpi
#
#- name: Install (copy) 3 binaries from /opt/iiab/downloads/mongodb-3.0.1x/core to /usr/bin (rpi)
# copy:
# src: "{{ item }}"
# dest: /usr/bin
# with_fileglob:
# - "{{ downloads_dir }}/mongodb-3.0.1x/core/*"
# when: internet_available and is_rpi
#
#- name: Download & unzip MongoDB 3.0.15's 9 tools binaries to /opt/iiab/downloads/mongodb-3.0.1x (rpi)
# unarchive:
# remote_src: yes
# src: "{{ iiab_download_url }}/mongodb_stretch_3_0_14_tools.zip"
# dest: "{{ downloads_dir }}/mongodb-3.0.1x"
# when: internet_available and is_rpi
#
#- name: Install (copy) 9 binaries from /opt/iiab/downloads/mongodb-3.0.1x/tools to /usr/bin (rpi)
# copy:
# src: "{{ item }}"
# dest: /usr/bin
# with_fileglob:
# - "{{ downloads_dir }}/mongodb-3.0.1x/tools/*"
# when: internet_available and is_rpi
- name: Create Linux group mongodb (rpi)
group:
name: mongodb
state: present
when: is_rpi
- name: Create Linux user mongodb (rpi)
user:
name: mongodb
group: mongodb # primary group
groups: mongodb
home: /var/lib/mongodb
shell: /usr/sbin/nologin
when: is_rpi
# 2. CONFIGURE FOR IIAB
- name: 'Create 3 dirs for MongoDB: /var/lib/mongodb, /var/log/mongodb, {{ mongodb_db_path }}'
file:
state: directory
path: "{{ item.path }}"
path: "{{ item }}"
owner: mongodb
group: mongodb
with_items:
- { path: '/var/run/mongodb' }
- { path: "{{ mongodb_db_path }}" } # == /library/dbdata/mongodb/
- { path: '/var/log/mongodb' }
#- { path: '/var/run/mongodb' }
- /var/lib/mongodb
- /var/log/mongodb
- "{{ mongodb_db_path }}" # i.e. /library/dbdata/mongodb/
- name: Populate & position /etc/mongod.conf, mongodb.service, /usr/bin/iiab-mongodb-repair-if-no-lock
- name: Install /etc/mongod.conf, mongodb.service, /usr/bin/iiab-mongodb-repair-if-no-lock from templates
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
@ -26,25 +124,32 @@
group: root
mode: "{{ item.mode }}"
with_items:
- { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}", mode: '0644' }
- { src: 'mongod.conf.j2', dest: "{{ mongodb_conf }}", mode: '0644' } # i.e. /etc/mongod.conf
- { 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' }
# 3. ENABLE/DISABLE
- name: Enable & Restart 'mongodb' systemd service if mongodb_enabled, incl daemon-reload (in case mongodb.service changed?)
systemd:
name: mongodb
daemon_reload: yes
enabled: yes
state: restarted
daemon_reload: yes
when: mongodb_enabled
- name: Disable 'mongodb' service, if not mongodb_enabled
systemd:
name: mongodb
daemon_reload: yes
enabled: no
state: stopped
when: not mongodb_enabled
# 4. DOCUMENT IN /etc/iiab/iiab.ini
- name: Add 'mongodb' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"

View file

@ -5,8 +5,8 @@
# Comma separated list of ip addresses to listen on (all local ips by default)
bind_ip = 127.0.0.1
# Specify port number (27017 by default)
port = 27018
# Specify port number (27017 by default...but typically 27018 for IIAB)
port = {{ mongodb_port }}
# Fork server process (false by default)
# fork = true

View file

@ -1,4 +1,4 @@
- name: Install Monit package
- name: Install 'monit' package
package:
name: monit
state: present

View file

@ -1,4 +1,4 @@
- name: Install packages python-psycopg2 and php-pgsql (OS's other than debuntu)
- name: "Install packages: python-psycopg2, php-pgsql (OS's other than debuntu)"
package:
name:
- python-psycopg2
@ -20,12 +20,12 @@
state: present
when: is_debuntu
- name: php-zip name (debian-9 or ubuntu)
- name: "Install package: php{{ php_version }}-zip (ubuntu or debian-9+)"
package:
name: "php{{ php_version }}-zip"
when: is_debian_9 or is_ubuntu
when: is_ubuntu or (is_debian and not is_debian_8)
- name: php-zip name for (debian-8)
- name: "Install package: php-pclzip (debian-8)"
package:
name: php-pclzip
when: is_debian_8
@ -133,7 +133,7 @@
enabled: yes
when: moodle_enabled
- name: Restart Apache ({{ apache_service }})
- name: Restart Apache service ({{ apache_service }})
service:
name: "{{ apache_service }}"
state: restarted

View file

@ -1,4 +1,4 @@
- name: Install mosquitto & mosquitto-clients
- name: "Install packages: mosquitto, mosquitto-clients"
package:
name: "{{ item }}"
state: present
@ -8,7 +8,7 @@
when: mosquitto_install
tags: download
- name: Disable & Stop mosquitto service
- name: Disable & Stop 'mosquitto' service
systemd:
name: mosquitto
enabled: no
@ -36,7 +36,7 @@
mode: 0755
when: mosquitto_install
- name: Enable & Start mosquitto service
- name: Enable & Start 'mosquitto' service
systemd:
daemon_reload: yes
name: mosquitto

View file

@ -1,6 +1,7 @@
# 2019-01-16: duplicate Node.js code unified thanks to @jvonau. It's used by:
# roles/sugarizer/tasks/main.yml with roles/sugarizer/meta/main.yml
# 2019-01-16/29: duplicate Node.js code unified thanks to @jvonau. It's used by:
# roles/pbx/tasks/main.yml with roles/pbx/meta/main.yml (for Asterisk with FreePBX, forthcoming early in 2019, see PR #1405)
# roles/nodered/tasks/main.yml with roles/nodered/meta/main.yml
# roles/sugarizer/tasks/main.yml with roles/sugarizer/meta/main.yml
# 2019-01-16: fyi Node.js 10.x became "LTS" on 2018-10-30 but distros are
# holding back for now: certainly Ubuntu 18.04 and even Debian 10/Buster
@ -8,23 +9,34 @@
# more bleeding-edge Debian Sid ("unstable" branch) does install Node.js 10.x
#
# This May Change: thanks all for running "apt -a list nodejs" on Buster's
# daily builds @ www.debian.org/devel/debian-installer/ to keep us informed!
# daily builds @ www.debian.org/devel/debian-installer/ and Disco Dingo (Ubuntu
# 19.04) https://launchpad.net/ubuntu/+source/nodejs to keep us informed!
- name: Set up Node.js 8.x apt sources (debuntu distros UP TO 2017)
shell: curl -sL https://deb.nodesource.com/setup_8.x | bash -
#- name: Set up Node.js {{ nodejs_version }} apt sources (debuntu distros UP TO 2017)
- name: Set up Node.js {{ nodejs_version }} apt sources (debuntu)
shell: curl -sL https://deb.nodesource.com/setup_{{ nodejs_version }} | bash -
args:
warn: no
when: internet_available and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17)
when: internet_available and is_debuntu
#when: internet_available and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17)
# NOT NEC TO TEST FOR is_raspbian_8 OR is_raspbian_9 AS /opt/iiab/iiab/vars/<OS>.yml
# DEFINES THESE AS SUBSETS OF is_debian_8 OR is_debian_9 (FOR NOW!)
- name: Install latest Node.js which includes /usr/bin/npm (debuntu distros UP TO 2017)
#- name: Install Node.js {{ nodejs_version }} which includes /usr/bin/npm (debuntu distros UP TO 2017)
- name: Install Node.js {{ nodejs_version }} which includes /usr/bin/npm (debuntu)
package:
name: nodejs
# name: nodejs=8.x
state: latest
# state: present
when: internet_available and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17)
# name: nodejs={{ nodejs_version }}
name: nodejs
state: latest
# state: present
when: internet_available and is_debuntu
#when: internet_available and (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17)
- name: Set up & install Node.js {{ nodejs_version }} which includes /usr/bin/npm (redhat)
shell: curl -sL https://rpm.nodesource.com/setup_{{ nodejs_version }} | bash -
args:
warn: no
when: internet_available and is_redhat
# 2018-07-14: BOTH STEPS ABOVE TAKE TIME, but Raspbian (apt offers npm
# 1.4.21) & Debian 9 (apt offers no npm!) STILL NEED the above
@ -45,10 +57,10 @@
# where it upgrades /usr/bin/npm in place:
# https://askubuntu.com/questions/1036278/npm-is-incorrect-version-on-latest-ubuntu-18-04-installation
- name: Install latest packages nodejs and npm (debuntu distros AFTER 2017, or other distros)
package:
name:
- nodejs
- npm
state: latest
when: internet_available and not (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17)
# - name: Install packages nodejs {{ nodejs_version }} and npm (debuntu distros AFTER 2017, or other distros)
# package:
# name:
# - nodejs={{ nodejs_version }} # Nec to change above from 'package:' to 'apt:' ?
# - npm
# state: latest
# when: internet_available and not (is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17)

View file

@ -5,13 +5,13 @@
shell: npm install -g --unsafe-perm node-red node-red-admin node-red-dashboard
when: nodered_install
- name: Ensure Linux group "nodered" exists
- name: Ensure Linux group 'nodered' exists
group:
name: nodered
state: present
when: nodered_install
- name: Ensure Linux user "nodered" exists and is added to group "nodered"
- name: Ensure Linux user 'nodered' exists and is added to group 'nodered'
user:
name: nodered
group: nodered

View file

@ -3,11 +3,12 @@ Description=Node-RED
After=syslog.target network.target
[Service]
{% if is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17 %}
# Ansible template HAD: if is_debian_8 or is_debian_9 or is_ubuntu_16 or is_ubuntu_17
# Ansible template HAD: if is_debuntu
ExecStart=/usr/bin/node-red-pi --max-old-space-size=128 -v
{% else %}
ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v
{% endif %}
# Ansible template HAD: else
# ExecStart=/usr/local/bin/node-red-pi --max-old-space-size=128 -v
# Ansible template HAD: endif
Restart=on-failure
KillSignal=SIGINT
@ -22,4 +23,3 @@ Group=nodered
[Install]
WantedBy=multi-user.target

View file

@ -1,4 +1,4 @@
- name: Install ssh daemon
- name: "Install ssh daemon using package: {{ sshd_package }}"
package:
name: "{{ sshd_package }}"
state: present

View file

@ -1,15 +1,20 @@
sugarizer_install: True
sugarizer_enabled: False
# Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879
# Sugarizer 1.0.1+ strategies to solve? github.com/iiab/iiab/pull/957
sugarizer_location: "{{ iiab_base }}" # /opt/iiab
# sugarizer_install: False
# sugarizer_enabled: False
# sugarizer_port: 8089
sugarizer_version: sugarizer-1.0
sugarizer_git_version: v1.1.0
# All above are set in: github.com/iiab/iiab/blob/master/vars/default_vars.yml
# If nec, change them by editing /etc/iiab/local_vars.yml prior to installing!
sugarizer_dir_version: sugarizer-1.1.0 # WAS: sugarizer-1.0, sugarizer-master
sugarizer_git_version: v1.1.0 # WAS: v1.0.1, master
# PLEASE HELP MONITOR https://github.com/llaske/sugarizer/releases
sugarizer_server_version: sugarizer-server-1.0
sugarizer_server_git_version: v1.0.1 # "master" worked over July 11-14, 2018
sugarizer_server_dir_version: sugarizer-server-dev # WAS: sugarizer-server-1.0, sugarizer-server-master
sugarizer_server_git_version: 46c4822bc7801ff8d621c22988aa4418359e7e19 # WAS: v1.0.1, master, dev
# Above commit (githash 46c4822... for iiab/iiab PR #1430 from 'dev' branch of
# https://github.com/llaske/sugarizer-server) well tested Jan 29 - Feb 2 2019.
#
# PLEASE HELP MONITOR https://github.com/llaske/sugarizer-server/releases
# Unused as of 2018-07-14
# node_modules_exists: False

View file

@ -1,27 +1,32 @@
- name: FAIL (STOP INSTALLING) IF nodejs_version is not set to 10.x
fail:
msg: "Sugarizer install cannot proceeed, as it currently requires Node.js 10.x, and your nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml and possibly also /etc/iiab/local_vars.yml"
when: sugarizer_install and (nodejs_version != "10.x")
# 0. CLEAN UP PRIOR VERSIONS OF SUGARIZER (NEEDS WORK!)
- name: Wipe /library/www/html/sugarizer* if installing sugarizer-1.0
shell: "rm -rf {{ doc_root }}/sugarizer*"
args:
warn: no
when: sugarizer_version == "sugarizer-1.0"
# - name: Wipe /library/www/html/sugarizer* if installing sugarizer-1.0
# shell: "rm -rf {{ doc_root }}/sugarizer*"
# args:
# warn: no
# when: sugarizer_dir_version == "sugarizer-1.0"
# 1. DOWNLOAD+LINK /opt/iiab/sugarizer
- name: Clone llaske/sugarizer ({{ sugarizer_git_version }}) from GitHub to /opt/iiab (MAY DOWNLOAD 600+ MB)
- name: Clone llaske/sugarizer ({{ sugarizer_git_version }} branch/version) from GitHub to /opt/iiab/{{ sugarizer_dir_version }} (MAY DOWNLOAD 600+ MB)
git:
repo: https://github.com/llaske/sugarizer
dest: "{{ sugarizer_location }}/{{ sugarizer_version }}"
dest: "{{ iiab_base }}/{{ sugarizer_dir_version }}"
version: "{{ sugarizer_git_version }}"
force: yes
depth: 1
when: internet_available
- name: Create symlink /opt/iiab/sugarizer -> /opt/iiab/{{ sugarizer_version }}
- name: Create symlink /opt/iiab/sugarizer -> /opt/iiab/{{ sugarizer_dir_version }}
file:
src: "{{ sugarizer_location }}/{{ sugarizer_version }}"
dest: "{{ sugarizer_location }}/sugarizer"
src: "{{ iiab_base }}/{{ sugarizer_dir_version }}"
dest: "{{ iiab_base }}/sugarizer"
state: link
@ -42,25 +47,25 @@
# CLARIF: during repeat runs of "./runrole sugarizer", this git sync shows
# "changed" (whereas above git sync shows "ok"). Reason: "npm install"
# (below) modifies /opt/iiab/sugarizer-server/node_modules
- name: Clone llaske/sugarizer-server ({{ sugarizer_server_git_version }}) from GitHub to /opt/iiab
- name: Clone llaske/sugarizer-server ({{ sugarizer_server_git_version }} branch/version) from GitHub to /opt/iiab/{{ sugarizer_server_dir_version }}
git:
repo: https://github.com/llaske/sugarizer-server
dest: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
dest: "{{ iiab_base }}/{{ sugarizer_server_dir_version }}"
version: "{{ sugarizer_server_git_version }}"
force: yes
depth: 1
when: internet_available
- name: Create symbolic link /opt/iiab/sugarizer-server -> /opt/iiab/{{ sugarizer_server_version }}
- name: Create symlink /opt/iiab/sugarizer-server -> /opt/iiab/{{ sugarizer_server_dir_version }}
file:
src: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
dest: "{{ sugarizer_location }}/sugarizer-server"
src: "{{ iiab_base }}/{{ sugarizer_server_dir_version }}"
dest: "{{ iiab_base }}/sugarizer-server"
state: link
# 3. INSTALL A GOOD VERSION OF Node.js AND npm
# 2019-01-16: @jvonau's PR #1403 moved installation of Node.js (8.x for now) &
# 2019-01-16/29: @jvonau's PR #1403 moved install of Node.js (10.x for now) &
# npm to roles/nodejs/tasks/main.yml, triggered by roles/sugarizer/meta/main.yml
@ -72,9 +77,9 @@
# OLD WAY 2: "creates: ..." checks for non-existence of /opt/iiab/sugarizer-server-1.0/node_modules
# OLD WAY 3: set "register: git_sug_server_output" above, then as nec delete /opt/iiab/sugarizer-server-1.0/node_modules "when: git_sug_server_output.changed" and as nec run "npm install"
#- name: Check for /opt/iiab/{{ sugarizer_server_version }}/node_modules
#- name: Check for /opt/iiab/sugarizer-server/node_modules
# stat:
# path: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules"
# path: "{{ iiab_base }}/sugarizer-server/node_modules"
# register: nmtest
# ignore_errors: true
#
@ -114,11 +119,11 @@
# gets the job done, for now!)
#- name: Create the express framework for Node.js (OS's other than Fedora 18)
- name: Run 'npm install --allow-root --unsafe-perm=true' to create /opt/iiab/{{ sugarizer_server_version }}/node_modules (CAN TAKE ~3 MINUTES)
- name: Run 'npm install --allow-root --unsafe-perm=true' to create /opt/iiab/sugarizer-server/node_modules (CAN TAKE ~5 MINUTES)
command: npm install --allow-root --unsafe-perm=true # "command:" a bit safer than "shell:"
args:
chdir: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
#creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules" # OLD WAY 2
chdir: "{{ iiab_base }}/sugarizer-server"
#creates: "{{ iiab_base }}/sugarizer-server/node_modules" # OLD WAY 2
when: internet_available # "npm install" generally requires Internet access
# when: internet_available and git_sug_server_output.changed # OLD WAY 3
# when: internet_available and not is_F18 and not node_modules_exists # OLD WAY 1
@ -126,31 +131,100 @@
#- name: Create the express framework for Node.js (Fedora 18)
# shell: npm install
# args:
# chdir: "{{ sugarizer_location }}/sugarizer/server"
# chdir: "{{ iiab_base }}/sugarizer/server"
# when: internet_available and is_F18 and not node_modules_exists
# Add a nodejs express function that appends a prefix to urls
- name: Install path prefix proxy
command: npm install --allow-root --unsafe-perm=true path-prefix-proxy
# Add a Node.js Express function that appends a prefix to URLs.
# SEE "AUTO-INSERTED BY IIAB" ~61 LINES BELOW: as those two "pathPrefix" lines
# MUST be added to /opt/iiab/sugarizer-server/sugarizer.js
- name: For http://box/sugarizer -- run 'npm install --allow-root --unsafe-perm=true path-prefix-proxy' to create /opt/iiab/sugarizer-server/node_modules/path-prefix-proxy
command: npm install --allow-root --unsafe-perm=true path-prefix-proxy
args:
chdir: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
chdir: "{{ iiab_base }}/sugarizer-server"
when: internet_available
# 5. PLACE CONFIG FILES
# 5. CONFIG FILES
- name: "Install from templates: sugarizer.service (systemd), sugarizer.conf (Apache), sugarizer.ini and sugarizer-server"
- name: "Install from templates: sugarizer.service (systemd), sugarizer.conf (Apache)"
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
mode: 0644
owner: root
group: root
with_items:
- { src: 'sugarizer.ini', dest: '{{ sugarizer_location }}/{{ sugarizer_server_version }}/env/sugarizer.ini', mode: '0644' }
- { src: 'sugarizer.conf', dest: '/etc/apache2/sites-available', mode: '0644' }
- { src: 'sugarizer.service.j2', dest: '/etc/systemd/system/sugarizer.service', mode: '0644' }
- { src: 'sugarizer.js', dest: '/opt/iiab/sugarizer-server', mode: '0644' }
- { src: 'sugarizer.service', dest: '/etc/systemd/system/sugarizer.service' }
- { src: 'sugarizer.conf.j2', dest: '/etc/apache2/sites-available/sugarizer.conf' }
#- { src: 'sugarizer.ini.j2', dest: '{{ iiab_base }}/sugarizer-server/env/sugarizer.ini' }
#- { src: 'sugarizer.js', dest: '{{ iiab_base }}/sugarizer-server' }
# 3 [WAS 4] STANZAS ADDED BELOW JAN/FEB 2019, HOPING THIS MIGHT "JUST WORK" WITH
# FUTURE UPGRADES BEYOND SUGARIZER 1.1? SEE github.com/iiab/iiab/pull/1430/files
# sugarizer_port is set to 8089 in /opt/iiab/iiab/vars/default_vars.yml
# If you need to change this, edit /etc/iiab/local_vars.yml prior to installing
- name: Set Sugarizer port to {{ sugarizer_port }} in /opt/iiab/sugarizer-server/env/sugarizer.ini
lineinfile:
path: "{{ iiab_base }}/sugarizer-server/env/sugarizer.ini"
regexp: "^port = 8080$"
line: "port = {{ sugarizer_port }}"
# 2019-02-02 No Longer Required thanks to @llaske's upstream fix:
# https://github.com/llaske/sugarizer-server/commit/46c4822bc7801ff8d621c22988aa4418359e7e19
## 2019-02-02: HACK WAS REQUIRED ON UBUNTU 18.04 so Sugarizer finds MongoDB
## after 1st reboot. Otherwise "Waiting for DB..." appears every second as
## shown by "systemctl status sugarizer" and "journalctl -eu sugarizer".
## This does NOT affect Ubuntu 16.04 or Raspbian. @jvonau wonders if U18.04's
## "nameserver 127.0.0.53" in /etc/resolv.conf is to blame? @m-anish wondered
## if "bind_ip: 127.0.0.1" in /etc/mongod.conf was to blame as suggested by
## https://stackoverflow.com/questions/8904991/mongodb-cant-connect-to-localhost-but-can-connect-to-localhosts-ip-address
## But changing to "bind_ip: localhost" does not work with Sugarizer, and
## "bind_ip: 127.0.0.1,localhost" is not allowed. BACKGROUND: PR #1430
#- name: Set MongoDB "server" from localhost to 127.0.0.1 in /opt/iiab/sugarizer-server/env/sugarizer.ini
# lineinfile:
# path: "{{ iiab_base }}/sugarizer-server/env/sugarizer.ini"
# regexp: "^server = localhost$"
# line: "server = 127.0.0.1"
# mongodb_port is set to 27018 in /opt/iiab/iiab/vars/default_vars.yml
# If you need to change this, edit /etc/iiab/local_vars.yml prior to installing
- name: Set MongoDB port to {{ mongodb_port }} in /opt/iiab/sugarizer-server/env/sugarizer.ini
lineinfile:
path: "{{ iiab_base }}/sugarizer-server/env/sugarizer.ini"
regexp: "^port = 27017$"
line: "port = {{ mongodb_port }}"
# 2-LINE FIX FOR sugarizer.js BY @georgejhunt FOR http://box/sugarizer
# SEE ~61 LINES ABOVE, as this is REQUIRED: 'npm install --allow-root --unsafe-perm=true path-prefix-proxy'
# OR YOU GET ERRORS: "status=255" within "systemctl status sugarizer"
# "Cannot find module 'path-prefix-proxy'" within "journalctl -eu sugarizer"
- name: For http://box/sugarizer -- add pathPrefix lines in /opt/iiab/sugarizer-server/sugarizer.js
lineinfile:
path: "{{ iiab_base }}/sugarizer-server/sugarizer.js"
regexp: "AUTO-INSERTED BY IIAB" # avoids inserting it twice!
insertbefore: "// Start listening$"
line: | # SEE https://yaml-multiline.info (use |+ to 'keep' newlines at end...though |8 and |+4 "indentation indicators" don't work with Ansible)
// AUTO-INSERTED BY IIAB FOR http://box/sugarizer
var pathPrefix = '/sugarizer';
app.use(pathPrefix, require('path-prefix-proxy')(pathPrefix));
# Use this instead, if tabs are truly nec:
# line: "\t// AUTO-INSERTED BY IIAB FOR http://box/sugarizer\n\tvar pathPrefix = '/sugarizer';\n\tapp.use(pathPrefix, require('path-prefix-proxy')(pathPrefix));\n"
# Ansible's blockinfile module:
# - inserts a mandatory marker line at beginning AND end of the block...ok fine
# - doesn't support adding a newline after the block...ugly :(
# - doesn't include above lineinfile's "regexp" parameter...and so risks inserting the block repeatedly, on each run :(
#
# blockinfile:
# path: /opt/iiab/sugarizer-server/sugarizer.js
# insertbefore: "// Start listening$"
# marker: "// {mark} AUTO-INSERTED BY IIAB FOR http://box/sugarizer"
# block: |
# var pathPrefix = '/sugarizer';
# app.use(pathPrefix, require('path-prefix-proxy')(pathPrefix));
# # Use this instead, if tabs are truly nec:
# # block: "\tvar pathPrefix = '/sugarizer';\n\tapp.use(pathPrefix, require('path-prefix-proxy')(pathPrefix));"
- name: Create symlink sugarizer.conf from sites-enabled to sites-available, for short URL http://box/sugarizer (debuntu)
file:
@ -171,9 +245,9 @@
- name: Enable & Restart systemd service if sugarizer_enabled, with "systemctl daemon-reload" (in case mongodb.service changed?)
systemd:
name: sugarizer
daemon_reload: yes
enabled: yes
state: restarted
daemon_reload: yes
when: sugarizer_enabled
- name: "Disable systemd service, if sugarizer_enabled: False"
@ -183,7 +257,7 @@
state: stopped
when: not sugarizer_enabled
- name: Restart Apache ({{ apache_service }}) to enable/disable http://box/sugarizer (not just http://box:8089)
- name: Restart Apache service ({{ apache_service }}) to enable/disable http://box/sugarizer (not just http://box:{{ sugarizer_port }})
systemd:
name: "{{ apache_service }}" # httpd or apache2
state: restarted

View file

@ -1,2 +0,0 @@
ProxyPass /sugarizer http://localhost:8089/sugarizer
ProxyPassReverse /sugarizer http://localhost:8089/sugarizer

View file

@ -0,0 +1,5 @@
# sugarizer_port is set to 8089 in /opt/iiab/iiab/vars/default_vars.yml
# If you need to change this, edit /etc/iiab/local_vars.yml prior to installing
ProxyPass /sugarizer http://localhost:{{ sugarizer_port }}/sugarizer
ProxyPassReverse /sugarizer http://localhost:{{ sugarizer_port }}/sugarizer

View file

@ -1,4 +1,4 @@
- name: 'Install packages: transmission-daemon, transmission-cli'
- name: "Install BitTorrent packages: transmission-daemon, transmission-cli"
package:
name:
- transmission-daemon

View file

@ -1,4 +1,4 @@
- name: Install vnstat package
- name: Install 'vnstat' package
package:
name: vnstat
state: present

View file

@ -130,7 +130,7 @@
state: absent
when: not wordpress_enabled and is_debuntu
- name: Restart Apache to enable/disable http://box{{ wp_url }}
- name: Restart Apache service ({{ apache_service }}) to enable/disable http://box{{ wp_url }}
systemd:
name: "{{ apache_service }}"
state: restarted

View file

@ -1,16 +1,13 @@
# WARNING: DO NOT MODIFY THIS FILE.
# CHANGES WILL BE LOST IF YOU DO A GIT PULL OR FETCH.
# Instead put changes in your own /etc/iiab/local_vars.yml
# PLZ READ http://wiki.laptop.org/go/IIAB/local_vars.yml AND http://FAQ.IIAB.IO
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN "git pull" IS RUN!
# PUT YOUR CUSTOMIZATIONS HERE: /etc/iiab/local_vars.yml
# READ "What is local_vars.yml and how do I customize it?" IN http://FAQ.IIAB.IO
# By convention we use True/False to indicate boolean constants.
# By convention we use True/False to indicate boolean values.
# Configuration Files
iiab_local_vars_file: /etc/iiab/local_vars.yml
iiab_env_file: /etc/iiab/iiab.env
iiab_ini_file: /etc/iiab/iiab.ini
#iiab_config_file: "{{ iiab_ini_file }}" # Legacy support / let's phase this out eventually
#service_filelist: "{{ iiab_ini_file }}" # Legacy support / let's phase this out eventually
iiab_base: /opt/iiab
iiab_dir: "{{ iiab_base }}/iiab"
@ -287,6 +284,10 @@ mosquitto_install: False
mosquitto_enabled: False
mosquitto_port: 1883
# Node.js version used by roles/nodejs/tasks/main.yml for 3 roles:
# nodered (Node-RED), pbx (Asterix, FreePBX) & sugarizer (Sugarizer)
nodejs_version: 10.x # was 8.x until 2019-01-31
# Flow-based visual programming for wiring together IoT hardware devices etc
nodered_install: False
nodered_enabled: False
@ -325,6 +326,14 @@ moodle_install: False
moodle_enabled: False
# If using Moodle intensively, set apache_high_php_limits in 3-BASE-SERVER
# MongoDB (/library/dbdata/mongodb) is used by Sugarizer:
# Its 2 settings below are auto-set to True (in roles/0-init/tasks/main.yml) when: sugarizer_enabled
# The mongodb playbook itself is later invoked by roles/sugarizer/meta/main.yml
mongodb_install: False
mongodb_enabled: False
mongodb_port: 27018
# roles/sugarizer/meta/main.yml auto-invokes 2 above prereqs: mongodb & nodejs
# Might stall MongoDB on Power Failure: github.com/xsce/xsce/issues/879
# Sugarizer 1.0.1+ strategies to solve? github.com/iiab/iiab/pull/957
sugarizer_install: False

View file

@ -199,6 +199,7 @@ nextcloud_enabled: True
wordpress_install: True
wordpress_enabled: True
# 7-EDU-APPS
# KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS

View file

@ -199,6 +199,7 @@ nextcloud_enabled: True
wordpress_install: True
wordpress_enabled: True
# 7-EDU-APPS
# KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS

View file

@ -199,6 +199,7 @@ nextcloud_enabled: False
wordpress_install: False
wordpress_enabled: False
# 7-EDU-APPS
# KA Lite - SEE THE "Transmission" BITTORRENT DOWNLOADER FURTHER BELOW, TO INSTALL THOUSANDS OF VIDEOS