1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00

Merge pull request #2238 from holta/cleaner-deps

Cleaner Dependencies for Sugarizer, Moodle, Node-RED, PBX, Internet Archive, Elgg
This commit is contained in:
A Holt 2020-02-06 08:12:33 -07:00 committed by GitHub
commit 3576bf0565
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 1405 additions and 1036 deletions

View file

@ -3,7 +3,7 @@
postgresql_install: True
postgresql_enabled: True
- name: POSTGRESQL - run the 'postgresql' role
- name: POSTGRESQL - run 'postgresql' role
include_role:
name: postgresql

View file

@ -6,7 +6,7 @@
command: a2dissite awstats.conf
when: not awstats_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -6,7 +6,7 @@
command: a2dissite calibre-web.conf
when: not calibreweb_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -0,0 +1,12 @@
- name: Enable http://box{{ elgg_url }} via Apache # http://box/elgg
command: a2ensite elgg.conf
when: elgg_enabled | bool
- name: Disable http://box{{ elgg_url }} via Apache # http://box/elgg
command: a2dissite elgg.conf
when: not elgg_enabled
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -1,52 +0,0 @@
# Apache
- name: Enable http://box{{ elgg_url }} via Apache # http://box/elgg
command: a2ensite elgg.conf
when: apache_install and elgg_enabled
- name: Disable http://box{{ elgg_url }} via Apache # http://box/elgg
command: a2dissite elgg.conf
when: apache_install and not elgg_enabled
- name: Restart Apache systemd service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
state: restarted
when: apache_enabled | bool
# NGINX
- name: "SHIM: Enable http://box{{ elgg_url }} via NGINX, by installing {{ nginx_conf_dir }}/elgg-nginx.conf from template" # http://box/elgg
template:
src: elgg-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/elgg-nginx.conf"
when: nginx_install and elgg_enabled
- name: "SHIM: Disable http://box{{ elgg_url }} via NGINX, by removing {{ nginx_conf_dir }}/elgg-nginx.conf" # http://box/elgg
file:
path: "{{ nginx_conf_dir }}/elgg-nginx.conf"
state: absent
when: nginx_install and not elgg_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted
when: nginx_enabled | bool
- name: Add 'elgg' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: elgg
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Elgg
- option: description
value: '"Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications."'
- option: path
value: /opt/elgg
- option: elgg_enabled
value: "{{ elgg_enabled }}"

View file

@ -1,5 +1,15 @@
# Assume we only get here if elgg_install: True
# Assume MySQL is running
# Assume (enforce!) we only get here if elgg_install: True
# Assume (enforce?) MySQL is running
# - name: "Set 'mysql_install: True' and 'mysql_enabled: True'"
# set_fact:
# mysql_install: True
# mysql_enabled: True
#
# - name: MYSQL - run 'mysql' role (attempt to install & enable MySQL)
# include_role:
# name: mysql
- name: Download {{ iiab_download_url }}/elgg-{{ elgg_version }}.zip to {{ downloads_dir }}
#shell: wget {{ iiab_download_url }}/elgg-{{ elgg_version }}.zip -c -P {{ downloads_dir }}
@ -88,6 +98,10 @@
dest: "/etc/{{ apache_conf_dir }}/elgg.conf"
- name: Set up Elgg's MySQL database
include_tasks: setup.yml
# RECORD Elgg AS INSTALLED
- name: "Set 'elgg_installed: True'"

View file

@ -1,11 +1,51 @@
- name: Install Elgg
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Assert that "elgg_install is sameas true" (boolean not string etc)
assert:
that: elgg_install is sameas true
fail_msg: "PLEASE SET 'elgg_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Assert that "elgg_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: elgg_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'elgg_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Install Elgg if 'elgg_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: elgg_install and not elgg_installed is defined
when: elgg_installed is undefined
- name: Provision DB
include_tasks: setup.yml
when: elgg_install and not installing
- name: Enable Elgg
include_tasks: enable.yml
when: elgg_install or elgg_installed is defined
#- name: Enable/Disable/Restart Apache if primary
- name: SHIM FOR NOW SO ALWAYS DO THE...Enable/Disable/Restart Apache
include_tasks: apache.yml
#when: not nginx_enabled
- name: Enable/Disable/Restart NGINX if primary
include_tasks: nginx.yml
when: nginx_enabled | bool
- name: Add 'elgg' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: elgg
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Elgg
- option: description
value: '"Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications."'
- option: path
value: /opt/elgg
- option: elgg_enabled
value: "{{ elgg_enabled }}"

View file

@ -0,0 +1,16 @@
- name: Enable http://box{{ elgg_url }} via NGINX, by installing {{ nginx_conf_dir }}/elgg-nginx.conf from template # http://box/elgg
template:
src: elgg-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/elgg-nginx.conf" # /etc/nginx/conf.d
when: elgg_enabled | bool
- name: Disable http://box{{ elgg_url }} via NGINX, by removing {{ nginx_conf_dir }}/elgg-nginx.conf # http://box/elgg
file:
path: "{{ nginx_conf_dir }}/elgg-nginx.conf" # /etc/nginx/conf.d
state: absent
when: not elgg_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted

View file

@ -6,7 +6,7 @@
command: a2dissite gitea.conf
when: not gitea_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -6,5 +6,6 @@
# 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!
internetarchive_dir: '{{ iiab_base }}/internetarchive'
internetarchive_upgrade: False
internetarchive_dir: "{{ iiab_base }}/internetarchive" # /opt/iiab
# internetarchive_upgrade: False # 2020-02-04: No longer needed!?

View file

@ -0,0 +1,12 @@
- name: Enable internetarchive.conf via Apache (for short URL http://box/archive eventually?) if internetarchive_enabled
command: a2ensite internetarchive.conf
when: internetarchive_enabled | bool
- name: Disable internetarchive.conf via Apache, if not internetarchive_enabled
command: a2dissite internetarchive.conf
when: not internetarchive_enabled
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -1,47 +0,0 @@
- name: Create symlink internetarchive.conf from sites-enabled to sites-available, for short URL http://box/archive (if debuntu and internetarchive_enabled)
file:
src: /etc/apache2/sites-available/internetarchive.conf
path: /etc/apache2/sites-enabled/internetarchive.conf
state: link
when: is_debuntu and internetarchive_enabled
- name: Remove symlink /etc/apache2/sites-enabled/internetarchive.conf (if debuntu and not internetarchive_enabled)
file:
path: /etc/apache2/sites-enabled/internetarchive.conf
state: absent
when: is_debuntu and not internetarchive_enabled
# RESTART/ENABLE SYSTEMD SERVICE
- name: Disable 'internetarchive' systemd service (if not internetarchive_enabled)
systemd:
name: internetarchive
enabled: no
when: not internetarchive_enabled
- name: Enable & Restart 'internetarchive' systemd service (if internetarchive_enabled)
systemd:
name: internetarchive
daemon_reload: yes
enabled: yes
state: restarted
when: internetarchive_enabled | bool
- name: Restart Apache service ({{ apache_service }}) to enable/disable http://box/archive (not just http://box:{{ internetarchive_port }})
systemd:
name: "{{ apache_service }}" # httpd or apache2
state: restarted
when: internetarchive_enabled | bool
- name: Add 'internetarchive' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: internetarchive
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Internet Archive
- option: description
value: '"Take the Internet Archive experience and materials offline, in a decentralized way!"'
- option: internetarchive_enabled
value: "{{ internetarchive_enabled }}"

View file

@ -5,16 +5,21 @@
nodejs_install: True
nodejs_enabled: True
- name: Install Node.JS
- name: NODEJS - run 'nodejs' role (attempt to install & enable Node.js)
include_role:
name: nodejs
- name: FAIL (STOP INSTALLING) IF nodejs_version is not set to 10.x or 12.x
fail:
msg: "Internet Archive install cannot proceed, as it currently requires Node.js 10.x or 12.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: (nodejs_version != "10.x") and (nodejs_version != "12.x")
- name: "Set 'yarn_install: True' and 'yarn_enabled: True'"
set_fact:
yarn_install: True
yarn_enabled: True
- name: Install Yarn
- name: YARN - run 'yarn' role (attempt to install & enable Yarn package manager)
include_role:
name: yarn
@ -23,40 +28,42 @@
name: libsecret-1-dev
state: present
# CREATE 2 DIRS & RUN YARN
- name: mkdir {{ internetarchive_dir }}
file:
path: "{{ internetarchive_dir }}" # /opt/iiab/internetarchive
state: directory
owner: "root"
path: "{{ internetarchive_dir }}" # /opt/iiab/internetarchive
# owner: root
- name: Run yarn install to get needed modules (CAN TAKE ~15 MINUTES)
- name: Run yarn install to populate {{ internetarchive_dir }}/node_modules (CAN TAKE ~15 MINUTES)
shell: yarn config set child-concurrency 1 && yarn add @internetarchive/dweb-mirror
args:
chdir: "{{ internetarchive_dir }}"
creates: "{{ internetarchive_dir }}/node_modules/@internetarchive/dweb-mirror/internetarchive"
when: internet_available | bool
register: internetarchive_installing
# register: internetarchive_installing
- name: mkdir /library/archiveorg
- name: mkdir {{ content_base }}/archiveorg
file:
path: "/library/archiveorg"
state: directory
owner: "root"
path: "{{ content_base }}/archiveorg" # /library
# owner: root
# CONFIG FILES
- name: "Install from templates: internetarchive.service (systemd), internetarchive.conf (Apache)"
- name: "Install from templates: /etc/systemd/system/internetarchive.service, /etc/{{ apache_conf_dir }}/internetarchive.conf"
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: '0644'
owner: root
group: root
# owner: root
# group: root
# mode: '0644'
with_items:
- { src: 'internetarchive.service.j2', dest: '/etc/systemd/system/internetarchive.service' }
- { src: 'internetarchive.conf', dest: '/etc/apache2/sites-available/internetarchive.conf' }
- { src: 'internetarchive.conf', dest: '/etc/{{ apache_conf_dir }}/internetarchive.conf' } # apache2/sites-available
# RECORD Internet Archive AS INSTALLED

View file

@ -1,32 +1,93 @@
# We need a recent version of node
- name: FAIL (STOP INSTALLING) IF nodejs_version is not set to 10.x or 12.x
fail:
msg: "Internet Archive install cannot proceed, as it currently requires Node.js 10.x or 12.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: internetarchive_install and (nodejs_version != "10.x") and (nodejs_version != "12.x")
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
- name: Install Yarn and Internet Archive
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Assert that "internetarchive_install is sameas true" (boolean not string etc)
assert:
that: internetarchive_install is sameas true
fail_msg: "PLEASE SET 'internetarchive_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Assert that "internetarchive_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: internetarchive_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'internetarchive_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
#- name: Set --reinstall fact
# set_fact:
# internetarchive_upgrade: True
# when: reinstall is defined
- block: # UPDATE IF... internetarchive_installed is defined and internet_available
- name: Stop 'internetarchive' systemd service, if internetarchive_upgrade
systemd:
name: internetarchive
daemon_reload: yes
state: stopped
#when: internetarchive_enabled and internetarchive_upgrade
- name: Update pre-existing install (yarn upgrade) if internetarchive_upgrade
shell: yarn config set child-concurrency 1 && yarn install && yarn upgrade
args:
chdir: "{{ internetarchive_dir }}"
#when: internetarchive_enabled and internetarchive_upgrade
when: internetarchive_installed is defined and internet_available # END BLOCK
# "ELSE" INSTALL...
- name: Install Internet Archive if 'internetarchive_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: internetarchive_install and not internetarchive_installed is defined
when: internetarchive_installed is undefined and internet_available
- name: Set --reinstall fact
set_fact:
internetarchive_upgrade: True
when: reinstall is defined
# STOP SYSTEMD SERVICE
- name: Stop 'internetarchive' systemd service
# ENABLE/DISABLE/RESTART SYSTEMD SERVICE & WEB SERVERS AS NEC ?
- name: Enable & Restart 'internetarchive' systemd service, if internetarchive_enabled
systemd:
name: internetarchive
daemon_reload: yes
enabled: yes
state: restarted
when: internetarchive_enabled | bool
- name: Disable & Stop 'internetarchive' systemd service, if not internetarchive_enabled
systemd:
name: internetarchive
enabled: no
state: stopped
when: internetarchive_enabled and internetarchive_upgrade
when: not internetarchive_enabled
- name: 'Update pre-existing install: yarn upgrade'
shell: yarn config set child-concurrency 1 && yarn install && yarn upgrade
args:
chdir: "{{ internetarchive_dir }}"
when: internetarchive_enabled and internetarchive_upgrade
#- name: Enable/Disable/Restart Apache if primary
- name: SHIM FOR NOW SO ALWAYS DO THE...Enable/Disable/Restart Apache
include_tasks: apache.yml
#when: not nginx_enabled
- name: Enable Internet Archive
include_tasks: enable.yml
when: internetarchive_install or internetarchive_installed is defined
- name: Enable/Disable/Restart NGINX if primary
include_tasks: nginx.yml
when: nginx_enabled | bool
- name: Add 'internetarchive' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: internetarchive
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Internet Archive
- option: description
value: '"Take the Internet Archive experience and materials offline, in a decentralized way!"'
- option: internetarchive_install
value: "{{ internetarchive_install }}"
- option: internetarchive_enabled
value: "{{ internetarchive_enabled }}"

View file

@ -0,0 +1,16 @@
- name: Enable http://box/archive via NGINX, by installing {{ nginx_conf_dir }}/internetarchive-nginx.conf from template
template:
src: internetarchive-nginx.conf.j2 # TO DO: roles/internetarchive/templates/internetarchive-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/internetarchive-nginx.conf" # /etc/nginx/conf.d
when: internetarchive_enabled | bool
- name: Disable http://box/archive via NGINX, by removing {{ nginx_conf_dir }}/internetarchive-nginx.conf
file:
path: "{{ nginx_conf_dir }}/internetarchive-nginx.conf" # /etc/nginx/conf.d
state: absent
when: not internetarchive_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted

View file

@ -0,0 +1,2 @@
# 2020-02-04: Let's try to get http://box/archive working with NGINX, using
# this file. BACKGROUND: https://github.com/iiab/iiab/pull/2120

View file

@ -6,7 +6,7 @@
command: a2dissite kolibri.conf
when: not kolibri_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -6,7 +6,7 @@
command: a2dissite lokole.conf
when: not lokole_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -1,10 +1,10 @@
- name: "SHIM: Enable http://box{{ lokole_url }} via NGINX, by installing {{ nginx_conf_dir }}/lokole-nginx.conf from template" # http://box/lokole
- name: Enable http://box{{ lokole_url }} via NGINX, by installing {{ nginx_conf_dir }}/lokole-nginx.conf from template # http://box/lokole
template:
src: lokole-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/lokole-nginx.conf" # /etc/nginx/conf.d
when: lokole_enabled | bool
- name: "SHIM: Disable http://box{{ lokole_url }} via NGINX, by removing {{ nginx_conf_dir }}/lokole-nginx.conf" # http://box/lokole
- name: Disable http://box{{ lokole_url }} via NGINX, by removing {{ nginx_conf_dir }}/lokole-nginx.conf # http://box/lokole
file:
path: "{{ nginx_conf_dir }}/lokole-nginx.conf" # /etc/nginx/conf.d
state: absent

View file

@ -18,42 +18,37 @@
fail_msg: "PLEASE GIVE VARIABLE 'mongodb_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: EXIT MONGODB PLAYBOOK, IF DEBIAN 10+ (where MongoDB doesn't exist)
meta: end_play
when: (is_debian and not is_raspbian) and (not is_debian_8) and (not is_debian_9)
- debug:
var: mongodb_install
- debug:
var: mongodb_enabled
- debug:
var: mongodb_installed
- 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
- debug:
var: is_debian
- 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: 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
when: mongodb_enabled | bool
# ELSE...
- name: Disable 'mongodb' service, if not mongodb_enabled
systemd:
name: mongodb
enabled: no
state: stopped
when: not mongodb_enabled
- 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
# THE block: APPROACH BELOW WORKS JUST LIKE main2.yml ABOVE.
# BUT IT VISUALLY POLLUTES: MANY BLUE "skipping:" MESSAGES IN ANSIBLE'S OUTPUT.
- name: Add 'mongodb' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: mongodb
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: MongoDB
- option: description
value: '"MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling."'
- option: enabled
value: "{{ mongodb_enabled }}"
# - block: # ENTIRE BLOCK CONDITIONED ON 'when: is_raspbian or not is_debian'
#
# [MOVED TO main2.yml]
#
# when: is_raspbian or not is_debian # CONDITION FOR ENTIRE ABOVE block:

View file

@ -0,0 +1,34 @@
- 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
- 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
when: mongodb_enabled | bool
- name: Disable & Stop 'mongodb' service, if not mongodb_enabled
systemd:
name: mongodb
enabled: no
state: stopped
when: not mongodb_enabled
- name: Add 'mongodb' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: mongodb
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: MongoDB
- option: description
value: '"MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling."'
- option: enabled
value: "{{ mongodb_enabled }}"

View file

@ -0,0 +1,12 @@
- name: Enable http://box/moodle via Apache
command: a2ensite 022-moodle.conf
when: moodle_enabled | bool
- name: Disable http://box/moodle via Apache
command: a2dissite 022-moodle.conf
when: not moodle_enabled
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -1,67 +0,0 @@
- name: Enable 'postgresql-iiab' systemd service, if moodle_enabled
systemd:
name: postgresql-iiab
state: started
enabled: yes
when: moodle_enabled
# if the only service using the backend db disable if not running
- name: Disable 'postgresql-iiab' systemd service, if not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)
systemd:
name: postgresql-iiab
state: stopped
enabled: no
when: not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)
# Apache
- name: Enable http://box/moodle via Apache
command: a2ensite 022-moodle.conf
when: apache_install and moodle_enabled
- name: Disable http://box/moodle via Apache
command: a2dissite 022-moodle.conf
when: apache_install and not moodle_enabled
- name: Restart '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted
when: apache_enabled | bool
# NGINX
- name: Enable http://box/moodle via NGINX, by installing {{ nginx_conf_dir }}/moodle-nginx.conf from template
template:
src: moodle-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/moodle-nginx.conf"
when: nginx_install and moodle_enabled
- name: Disable http://box/moodle via NGINX, by removing {{ nginx_conf_dir }}/moodle-nginx.conf
file:
path: "{{ nginx_conf_dir }}/moodle-nginx.conf"
state: absent
when: nginx_install and not moodle_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted
when: nginx_enabled | bool
- name: Add 'moodle' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: moodle
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Moodle
- option: description
value: '"Access the Moodle learning management system."'
- option: "moodle_base"
value: "{{ moodle_base }}"
- option: moodle_enabled
value: "{{ moodle_enabled }}"

View file

@ -1,19 +1,13 @@
- debug:
var: postgresql_install
- debug:
var: postgresql_enabled
- debug:
var: postgresql_installed
- name: "Set 'postgresql_install: True' and 'postgresql_enabled: True'"
set_fact:
postgresql_install: True
postgresql_enabled: True
- name: POSTGRESQL - run the 'postgresql' role
- name: POSTGRESQL - run 'postgresql' role (attempt to install & enable PostgreSQL)
include_role:
name: postgresql
- name: "Install packages: python-psycopg2, php-pgsql (OS's other than debuntu)"
package:
name:
@ -35,22 +29,22 @@
state: present
when: is_debuntu | bool
- name: "Install package: php{{ php_version }}-zip (ubuntu or debian-9+)"
- name: "Install package: php{{ php_version }}-zip (Ubuntu or Debian 9+)"
package:
name: "php{{ php_version }}-zip"
when: is_ubuntu or (is_debian and not is_debian_8)
- name: "Install package: php-pclzip (debian-8)"
package:
name: php-pclzip
when: is_debian_8 | bool
# - name: "Install package: php-pclzip (debian-8)"
# package:
# name: php-pclzip
# when: is_debian_8 | bool
- name: Determine if Moodle is already downloaded
- name: Does {{ moodle_base }}/config-dist.php exist? (indicating Moodle is/was installed)
stat:
path: "{{ moodle_base }}/config-dist.php"
register: moodle
- name: Download the latest Moodle repo
- name: Clone (i.e. use git to download) {{ moodle_repo_url }} to {{ moodle_base }}
git:
repo: "{{ moodle_repo_url }}"
dest: "{{ moodle_base }}"
@ -63,32 +57,32 @@
- name: Create dir {{ moodle_base }} owned by {{ apache_user }} (for config file?)
file:
state: directory
path: "{{ moodle_base }}"
owner: "{{ apache_user }}"
recurse: yes
state: directory
- name: Create dir {{ content_base }}/dbdata/moodle owned by {{ apache_user }}
file:
state: directory
path: "{{ content_base }}/dbdata/moodle"
owner: "{{ apache_user }}"
# mode: '0755'
state: directory
- name: Create dir {{ moodle_data }} owned by {{ apache_user }}:{{ apache_user }} with write permission 0770 # /library/moodle
- name: Create dir {{ moodle_data }} ({{ apache_user }}:{{ apache_user }}, '0770') # /library/moodle
file:
state: directory
path: "{{ moodle_data }}"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
mode: '0770'
state: directory
- name: Remove Apache's stock moodle.conf
- name: Remove stock /etc/{{ apache_conf_dir }}/moodle.conf
file:
path: "/etc/{{ apache_conf_dir }}/moodle.conf"
state: absent
- name: Install Apache's 022-moodle.conf from template, if moodle_enabled
- name: Install /etc/{{ apache_conf_dir }}/022-moodle.conf from template
template:
src: 022-moodle.j2
dest: "/etc/{{ apache_conf_dir }}/022-moodle.conf"
@ -96,10 +90,10 @@
# group: root
# mode: '0644'
- name: Restart postgresql-iiab
service:
- name: Start 'postgresql-iiab' systemd service, to configure Moodle's DB
systemd:
name: postgresql-iiab
state: restarted
state: started
- name: Create PostgreSQL db user Admin/changeme
postgresql_user:
@ -121,21 +115,21 @@
become: yes
become_user: postgres
- name: Install {{ moodle_base }}/moodle_installer from template
- name: Install {{ moodle_base }}/moodle_installer from template ('0755')
template:
src: moodle_installer
dest: "{{ moodle_base }}"
mode: '0755'
- name: Enable & Restart postgresql-iiab
service:
- name: (Re)Start 'postgresql-iiab' systemd service
systemd:
name: postgresql-iiab
state: restarted
enabled: yes
when: moodle_enabled | bool
#enabled: yes
#when: moodle_enabled | bool
- name: Restart Apache systemd service ({{ apache_service }})
service:
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}"
state: restarted
@ -148,10 +142,10 @@
shell: "{{ moodle_base }}/moodle_installer"
when: config.stat.exists is defined and not config.stat.exists
- name: Give read permission 0644 to {{ moodle_base }}/config.php # /opt/iiab/moodle/config.php
- name: Make {{ moodle_base }}/config.php readable, with permission '0644'
#command: chown -R {{ apache_user }} {{ moodle_base }}
file:
path: "{{ moodle_base }}/config.php"
path: "{{ moodle_base }}/config.php" # /opt/iiab/moodle
mode: '0644'

View file

@ -1,7 +1,82 @@
- name: "Install Moodle"
include_tasks: install.yml
when: moodle_install and not moodle_installed is defined
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
- name: Enable Moodle
include_tasks: enable.yml
when: moodle_install or moodle_installed is defined
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Assert that "moodle_install is sameas true" (boolean not string etc)
assert:
that: moodle_install is sameas true
fail_msg: "PLEASE SET 'moodle_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Assert that "moodle_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: moodle_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'moodle_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Install Moodle if 'moodle_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: moodle_installed is undefined
# - name: Enable 'postgresql-iiab' systemd service, if moodle_enabled
# systemd:
# name: postgresql-iiab
# deamon_reload: yes
# state: started
# enabled: yes
# when: moodle_enabled | bool
#
# # if the only service using the backend db disable if not running
# - name: Disable 'postgresql-iiab' systemd service, if 'not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)'
# systemd:
# name: postgresql-iiab
# state: stopped
# enabled: no
# when: not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)
- name: "Set 'postgresql_enabled: True' if moodle_enabled"
set_fact:
postgresql_enabled: True
when: moodle_enabled | bool
- name: "Set 'postgresql_enabled: False' if 'not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)'"
set_fact:
postgresql_enabled: False
when: not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)
- name: POSTGRESQL - run 'postgresql' role (Enable&Start or Disable&Stop PostgreSQL)
include_role:
name: postgresql
#- name: Enable/Disable/Restart Apache if primary
- name: SHIM FOR NOW SO ALWAYS DO THE...Enable/Disable/Restart Apache
include_tasks: apache.yml
#when: not nginx_enabled
- name: Enable/Disable/Restart NGINX if primary
include_tasks: nginx.yml
when: nginx_enabled | bool
- name: Add 'moodle' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: moodle
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Moodle
- option: description
value: '"Access the Moodle learning management system."'
- option: "moodle_base"
value: "{{ moodle_base }}"
- option: moodle_enabled
value: "{{ moodle_enabled }}"

View file

@ -0,0 +1,16 @@
- name: Enable http://box/moodle via NGINX, by installing {{ nginx_conf_dir }}/moodle-nginx.conf from template
template:
src: moodle-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/moodle-nginx.conf" # /etc/nginx/conf.d
when: moodle_enabled | bool
- name: Disable http://box/moodle via NGINX, by removing {{ nginx_conf_dir }}/moodle-nginx.conf
file:
path: "{{ nginx_conf_dir }}/moodle-nginx.conf" # /etc/nginx/conf.d
state: absent
when: not moodle_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted

View file

@ -6,7 +6,7 @@
command: a2dissite munin24.conf
when: not munin_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -0,0 +1,183 @@
# Stanzas as of 2020-02-04:
#
# - 4 base install
# - Remove the last 3 above, as CentOS & Fedora no longer supported ?
# - 6 double timeout for slow CPUs
# - 7 DB config
# - 2 record as installed
- name: 'Install MySQL packages: mariadb-server, mariadb-client, and 9 php packages (debuntu)'
package:
name:
- mariadb-server
- mariadb-client
- php{{ php_version }}
- php{{ php_version }}-mysql
- php-pear
- php{{ php_version }}-gd
- php{{ php_version }}-imap
- php{{ php_version }}-ldap
- php{{ php_version }}-odbc
- php{{ php_version }}-xml # Was below
- php{{ php_version }}-xmlrpc
state: present
when: is_debuntu | bool
# - name: Install package 'php{{ php_version }}-xml' (debuntu) # WAS: (ubuntu or debian 9+)
# package:
# name: "php{{ php_version }}-xml"
# state: present
# when: is_debuntu | bool
# #when: is_ubuntu or (is_debian and not is_debian_8)
#- name: Install php-xml-parser (debian-8)
# package:
# name: php-xml-parser
# state: present
# when: is_debian_8 | bool
- name: "Install packages: mysql, MySQL-python and 9 php packages (OS's other than debuntu)"
package:
name:
- MySQL-python
- mysql
- php
- php-mysql
- php-pear
- php-gd
- php-imap
- php-ldap
- php-odbc
- php-xml
- php-xmlrpc
state: present
when: not is_debuntu
- include_tasks: centos.yml
when: ansible_distribution == "CentOS"
- include_tasks: fedora.yml
when: ansible_distribution == "Fedora"
# 2019-07-03 @jvonau @holta: the next 50 lines (6 stanzas) double MariaDB's
# default boot timeout (90s to 180s) for slow CPUs like this Ubuntu 18.04.2 VM:
# https://github.com/iiab/iiab/issues/1802
# https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/#systemd
- name: Check if /lib/systemd/system/mariadb.service exists
stat:
path: /lib/systemd/system/mariadb.service
register: mariadb_unit_file
- name: Copy pkg's /lib/systemd/system/mariadb.service to /etc/systemd/system/ to be customized (CREATES TIMESTAMPED BACKUPS OF /etc/systemd/system/mariadb.service e.g. IF OPERATOR CUSTOMIZED IT, EVEN DESPITE WARNING BELOW!)
copy:
force: yes
backup: yes
src: /lib/systemd/system/mariadb.service
dest: /etc/systemd/system/
when: mariadb_unit_file.stat.exists
- name: Symlink /etc/systemd/system/mysql.service -> /etc/systemd/system/mariadb.service
file:
state: link
force: yes
src: /etc/systemd/system/mariadb.service
path: /etc/systemd/system/mysql.service
when: mariadb_unit_file.stat.exists
- name: Symlink /etc/systemd/system/mysqld.service -> /etc/systemd/system/mariadb.service
file:
state: link
force: yes
src: /etc/systemd/system/mariadb.service
path: /etc/systemd/system/mysqld.service
when: mariadb_unit_file.stat.exists
- name: "WARN OPERATOR: Changes made to /etc/systemd/system/mariadb.service WILL BE LOST whenever 'mysql' playbook is run"
lineinfile:
path: /etc/systemd/system/mariadb.service
insertbefore: BOF # Beginning of file
line: "# WARNING: CHANGES TO THIS FILE WILL BE REGULARLY *OVERWRITTEN* BY:\n# /opt/iiab/iiab/roles/mysql/tasks/main.yml\n"
when: mariadb_unit_file.stat.exists
- name: Set systemd boot timeout to 180 seconds for slow machines, in /etc/systemd/system/mariadb.service
lineinfile:
path: /etc/systemd/system/mariadb.service
insertafter: '^\[Service\]$'
regexp: "^TimeoutStartSec="
line: "\n# 2019-07-03: @jvonau @holta doubled MariaDB's default boot timeout, from\n# 90 seconds to 180 seconds, for slow machines like this Ubuntu 18.04.2 VM:\n# https://github.com/iiab/iiab/issues/1802\n# https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/#systemd\nTimeoutStartSec=180\n"
# If the line above were to be run repeatedly (never happens here!) Ansible
# would pollute MariaDB's systemd unit file. As multi-line regexp's are
# not allowed (both regexp's should match, for idempotency). If nec, use
# the 1-liner below, or Ansible's 'blockinfile' which pollutes config files
# in its own way...surrounding blocks with marker lines.
# line: "TimeoutStartSec=180"
when: mariadb_unit_file.stat.exists
# 7 STANZAS BELOW...could later be put into setup.yml or config.yml or or provision.yml ?
# Name of MySQL service varies by OS, so hardcoded in /opt/iiab/iiab/vars/<OS>.yml (formerly in roles/0-init/tasks/main.yml)
- name: Start MySQL systemd service ({{ mysql_service }}) to permit configuration
systemd:
name: "{{ mysql_service }}"
daemon_reload: yes
state: restarted
- name: Install /root/.my.cnf file from template, with root password credentials
template:
src: my.cnf.j2
dest: /root/.my.cnf
owner: root
mode: '0600'
# 'localhost' needs to be the last item for idempotency, see
# http://ansible.cc/docs/modules.html#mysql-user
# unfortunately it still doesn't work
- name: Update MySQL root password for localhost root accounts
mysql_user:
name: root
host: localhost
password: "{{ mysql_root_password }}"
priv: "*.*:ALL,GRANT"
- name: Update MySQL root password for all remaining root accounts (127.0.0.1, ::1)
mysql_user:
name: root
host: "{{ item }}"
password: "{{ mysql_root_password }}"
priv: "*.*:ALL,GRANT"
with_items:
#- "{{ iiab_hostname }}.{{ iiab_domain }}"
- 127.0.0.1
- ::1
- name: Delete anonymous MySQL server user for {{ ansible_hostname }}
mysql_user:
user: ""
host: "{{ ansible_hostname }}"
state: absent
- name: Delete anonymous MySQL server user for localhost
mysql_user:
user: ""
state: absent
- name: Remove the MySQL 'test' database
mysql_db:
db: test
state: absent
# RECORD MySQL AS INSTALLED
- name: "Set 'mysql_installed: True'"
set_fact:
mysql_installed: True
- name: "Add 'mysql_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^mysql_installed'
line: 'mysql_installed: True'

View file

@ -1,194 +1,46 @@
# TO DO:
# - Validate input vars mysql_install & mysql_enabled
# - Put ~13 stanzas just below into install.yml
# - Triggered by... 'when: mysql_installed is undefined'
# - Eliminate stale Fedora/CentOS code & gratuitous when: is_debuntu clauses?
# - Put ~8 stanzas below that into enable-or-disable.yml
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
- name: 'Install MySQL packages: mariadb-server, mariadb-client, and 8 php packages (debuntu)'
package:
name:
- mariadb-server
- mariadb-client
- php{{ php_version }}
- php{{ php_version }}-mysql
- php-pear
- php{{ php_version }}-gd
- php{{ php_version }}-imap
- php{{ php_version }}-ldap
- php{{ php_version }}-odbc
#- php{{ php_version }}-xml
- php{{ php_version }}-xmlrpc
state: present
when: is_debuntu | bool
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Install package 'php{{ php_version }}-xml' (debuntu) # WAS: (ubuntu or debian 9+)
package:
name: "php{{ php_version }}-xml"
state: present
when: is_debuntu | bool
#when: is_ubuntu or (is_debian and not is_debian_8)
- name: Assert that "mysql_install is sameas true" (boolean not string etc)
assert:
that: mysql_install is sameas true
fail_msg: "PLEASE SET 'mysql_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
#- name: Install php-xml-parser (debian-8)
# package:
# name: php-xml-parser
# state: present
# when: is_debian_8 | bool
- name: Assert that "mysql_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: mysql_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'mysql_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: "Install packages: mysql, MySQL-python and 9 php packages (OS's other than debuntu)"
package:
name:
- MySQL-python
- mysql
- php
- php-mysql
- php-pear
- php-gd
- php-imap
- php-ldap
- php-odbc
- php-xml
- php-xmlrpc
state: present
when: not is_debuntu
- include_tasks: centos.yml
when: ansible_distribution == "CentOS"
- include_tasks: fedora.yml
when: ansible_distribution == "Fedora"
- debug:
var: mysql_install
- debug:
var: mysql_enabled
- debug:
var: mysql_installed
# 2019-07-03 @jvonau @holta: the next 50 lines (6 stanzas) double MariaDB's
# default boot timeout (90s to 180s) for slow CPUs like this Ubuntu 18.04.2 VM:
# https://github.com/iiab/iiab/issues/1802
# https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/#systemd
- name: Check if /lib/systemd/system/mariadb.service exists
stat:
path: /lib/systemd/system/mariadb.service
register: mariadb_unit_file
- name: Copy pkg's /lib/systemd/system/mariadb.service to /etc/systemd/system/ to be customized (CREATES TIMESTAMPED BACKUPS OF /etc/systemd/system/mariadb.service e.g. IF OPERATOR CUSTOMIZED IT, EVEN DESPITE WARNING BELOW!)
copy:
force: yes
backup: yes
src: /lib/systemd/system/mariadb.service
dest: /etc/systemd/system/
when: mariadb_unit_file.stat.exists
- name: Symlink /etc/systemd/system/mysql.service -> /etc/systemd/system/mariadb.service
file:
state: link
force: yes
src: /etc/systemd/system/mariadb.service
path: /etc/systemd/system/mysql.service
when: mariadb_unit_file.stat.exists
- name: Symlink /etc/systemd/system/mysqld.service -> /etc/systemd/system/mariadb.service
file:
state: link
force: yes
src: /etc/systemd/system/mariadb.service
path: /etc/systemd/system/mysqld.service
when: mariadb_unit_file.stat.exists
- name: "WARN OPERATOR: Changes made to /etc/systemd/system/mariadb.service WILL BE LOST whenever 'mysql' playbook is run"
lineinfile:
path: /etc/systemd/system/mariadb.service
insertbefore: BOF # Beginning of file
line: "# WARNING: CHANGES TO THIS FILE WILL BE REGULARLY *OVERWRITTEN* BY:\n# /opt/iiab/iiab/roles/mysql/tasks/main.yml\n"
when: mariadb_unit_file.stat.exists
- name: Set systemd boot timeout to 180 seconds for slow machines, in /etc/systemd/system/mariadb.service
lineinfile:
path: /etc/systemd/system/mariadb.service
insertafter: '^\[Service\]$'
regexp: "^TimeoutStartSec="
line: "\n# 2019-07-03: @jvonau @holta doubled MariaDB's default boot timeout, from\n# 90 seconds to 180 seconds, for slow machines like this Ubuntu 18.04.2 VM:\n# https://github.com/iiab/iiab/issues/1802\n# https://mariadb.com/kb/en/library/what-to-do-if-mariadb-doesnt-start/#systemd\nTimeoutStartSec=180\n"
# If the line above were to be run repeatedly (never happens here!) Ansible
# would pollute MariaDB's systemd unit file. As multi-line regexp's are
# not allowed (both regexp's should match, for idempotency). If nec, use
# the 1-liner below, or Ansible's 'blockinfile' which pollutes config files
# in its own way...surrounding blocks with marker lines.
# line: "TimeoutStartSec=180"
when: mariadb_unit_file.stat.exists
- name: Install MySQL if 'mysql_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: mysql_installed is undefined
# RECORD MySQL AS INSTALLED
- name: "Set 'mysql_installed: True'"
set_fact:
mysql_installed: True
- name: "Add 'mysql_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^mysql_installed'
line: 'mysql_installed: True'
# Name of MySQL service varies by OS, so hardcoded in /opt/iiab/iiab/vars/<OS>.yml (formerly in roles/0-init/tasks/main.yml)
- name: Enable & Start MySQL systemd service ({{ mysql_service }}) if mysql_enabled
- name: Enable & Start MySQL ({{ mysql_service }}) systemd service, if mysql_enabled
systemd:
name: "{{ mysql_service }}"
daemon_reload: yes
state: restarted
state: started
enabled: yes
when: mysql_enabled | bool
- name: Install /root/.my.cnf file from template, with root password credentials, if mysql_enabled
template:
src: my.cnf.j2
dest: /root/.my.cnf
owner: root
mode: '0600'
when: mysql_enabled | bool
# 'localhost' needs to be the last item for idempotency, see
# http://ansible.cc/docs/modules.html#mysql-user
# unfortunately it still doesn't work
- name: Update MySQL root password for localhost root accounts, if mysql_enabled
mysql_user:
name: root
host: localhost
password: "{{ mysql_root_password }}"
priv: "*.*:ALL,GRANT"
when: mysql_enabled | bool
- name: Update MySQL root password for all remaining root accounts (127.0.0.1, ::1) if mysql_enabled
mysql_user:
name: root
host: "{{ item }}"
password: "{{ mysql_root_password }}"
priv: "*.*:ALL,GRANT"
with_items:
#- "{{ iiab_hostname }}.{{ iiab_domain }}"
- 127.0.0.1
- ::1
when: mysql_enabled | bool
- name: Delete anonymous MySQL server user for {{ ansible_hostname }}, if mysql_enabled
mysql_user:
user: ""
host: "{{ ansible_hostname }}"
state: absent
when: mysql_enabled | bool
- name: Delete anonymous MySQL server user for localhost, if mysql_enabled
mysql_user:
user: ""
state: absent
when: mysql_enabled | bool
- name: Remove the MySQL 'test' database, if mysql_enabled
mysql_db:
db: test
state: absent
when: mysql_enabled | bool
# we had to start mysql in order to configure it, now turn if off if not enabled
- name: Config is done but now DISABLE MySQL service, if not mysql_enabled
# We had to start MySQL in order to configure it, now turn if off if not enabled
- name: Disable & Stop MySQL ({{ mysql_service }}) systemd service, if not mysql_enabled
systemd:
name: "{{ mysql_service }}"
enabled: no
@ -198,7 +50,7 @@
- name: Add 'mysql' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: mysql
option: "{{ item.option }}"
value: "{{ item.value | string }}"

View file

@ -6,7 +6,7 @@
command: a2dissite nextcloud.conf
when: not nextcloud_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -1,10 +1,10 @@
- name: "SHIM: Enable http://box{{ nextcloud_url }} via NGINX, by installing {{ nginx_conf_dir }}/nextcloud-nginx.conf from template" # http://box/nextcloud
- name: Enable http://box{{ nextcloud_url }} via NGINX, by installing {{ nginx_conf_dir }}/nextcloud-nginx.conf from template # http://box/nextcloud
template:
src: nextcloud-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/nextcloud-nginx.conf" # /etc/nginx/conf.d
when: nextcloud_enabled | bool
- name: "SHIM: Disable http://box{{ nextcloud_url }} via NGINX, by removing {{ nginx_conf_dir }}/nextcloud-nginx.conf" # http://box/nextcloud
- name: Disable http://box{{ nextcloud_url }} via NGINX, by removing {{ nginx_conf_dir }}/nextcloud-nginx.conf # http://box/nextcloud
file:
path: "{{ nginx_conf_dir }}/nextcloud-nginx.conf" # /etc/nginx/conf.d
state: absent

View file

@ -10,7 +10,7 @@
2. Without PHP available via FastCGI, any function at all for PHP-based applications validates NGINX.
3. Current state of IIAB App/Service migrations as of 2020-02-01:
3. Current state of IIAB App/Service migrations as of 2020-02-04:
1. These support "Native" NGINX but ***NOT*** Apache
* Admin Console
@ -18,13 +18,13 @@
* IIAB documentation (http://box/info)
* osm-vector-maps
* OER2Go/RACHEL modules
* usb-lib
* usb-lib [*]
2. These support "Native" NGINX ***AND*** Apache, a.k.a. "dual support" for legacy testing (if suitable "Shims" from *Section iii.* below are preserved!) Both "Native" NGINX and "Shim" proxying from NGINX to Apache port 8090 *cannot be enabled simultaneously* for these IIAB Apps/Service. But if you want to attempt their "Shim" proxying legacy testing mode, change your *primary web server* over to Apache by setting `nginx_enabled: False` in [/etc/iiab/local_vars.yml](http://wiki.laptop.org/go/IIAB/FAQ#What_is_local_vars.yml_and_how_do_I_customize_it.3F) (which will [auto-enable Apache](../0-init/tasks/main.yml#L40-L44) for your testing).
* awstats
* calibre-web
* gitea
* kiwix
* kiwix [*]
* kolibri
* mediawiki
* munin
@ -35,10 +35,15 @@
* elgg
* lokole
* moodle
* nextcloud ([PR #2119](https://github.com/iiab/iiab/pull/2119))
* nextcloud ([PR #2119](https://github.com/iiab/iiab/pull/2119)) [*]
* nodered
4. These each run their own web server, i.e. off of their own [unique port(s)](https://github.com/iiab/iiab/wiki/IIAB-Networking#list-of-ports--services) (IIAB home pages link directly to these destinations). In future we'd like mnemonic URL's for all of these: (e.g. http://box/calibre, http://box/archive, http://box/kalite)
* calibre (menu goes directly to port 8080)
4. These each run their own web server or non-web / backend services, e.g. off of their own [unique port(s)](https://github.com/iiab/iiab/wiki/IIAB-Networking#list-of-ports--services) (IIAB home pages link directly to these destinations). In future we'd like mnemonic URL's for all of these: (e.g. http://box/calibre, http://box/archive, http://box/kalite)
* calibre (menu goes directly to port 8080) [*]
* internetarchive (menu goes directly to port 4244, [PR #2120](https://github.com/iiab/iiab/pull/2120))
* kalite (menu goes directly to ports 8006-8008)
* kalite (menu goes directly to ports 8006-8008) [*]
* minetest [*]
* openvpn [*]
* pbx
[*] Apache, NGINX and the 7 starred roles above could use improvement as of 2020-02-04.

View file

@ -0,0 +1,154 @@
# 1. TEST IF Node.js ALEADY INSTALLED & WARN AS NEC
# 2019-02-03: BELOW TESTS IF 'nodejs' VERSION IS ALREADY INSTALLED:
# IF SO & THIS DOESN'T MATCH nodejs_version AS SET IN defaults_vars.yml
# AND/OR local_vars.yml, INSTALL HALTS WITH AN EXPLANATION (PR #1447)
# 2019-07-04: FOR A SOMEWHAT MORE MODERN "VERSION DETECTOR" SEE:
# github.com/iiab/iiab/blob/master/roles/nextcloud/tasks/install.yml#L1-L40
- name: Try to run 'nodejs -v' to get Node.js version
# 'node -v' doesn't work with older versions e.g. Ubuntu 16.04's nodejs 4.2.6
# Both below convert v10.15.1 to 10.x, but this is safer: (removes non-digits)
shell: nodejs -v | sed 's/[^0-9]*//' | sed 's/[^0-9].*/.x/'
#shell: nodejs -v | sed 's/^[vV]//' | sed 's/\..*/.x/'
register: nodejs_version_installed
#- debug:
# var: nodejs_version_installed
# When nodejs is NOT installed:
# nodejs_version_installed.rc == 0 # Crazy with stderr below, "due to pipes"
# nodejs_version_installed.stdout == ""
# nodejs_version_installed.stderr == "/bin/sh: 1: nodejs: not found"
# BOTH ABOVE (incl non-null stderr) are USED BELOW to confirm install is nec!
#- name: "ENFORCE PRECONDITION: Stop installing (intentionally fail) IF an installed 'nodejs' version isn't {{ nodejs_version }}"
# fail:
# msg: >
# PLEASE REMOVE 'nodejs' VERSION {{ nodejs_version_installed.stdout }} AS
# IT DOES NOT MATCH THE REQUIRED nodejs_version: {{ nodejs_version }} --
# as set in /opt/iiab/iiab/vars/default_vars.yml and/or
# /etc/iiab/local_vars.yml -- then re-run this IIAB installer.
# when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stderr == ""
# Forces < 12 or > 12 to be removed, ignored if file is absent
- name: Remove /etc/apt/sources.list.d/nodesource.list if nodejs_version_installed.stdout is not {{ nodejs_version }}
file:
state: absent
path: /etc/apt/sources.list.d/nodesource.list
when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stdout != ""
# BRUTAL but ensures consistency across OS's / distros like Raspbian Desktop & Ubermix that often include an older version of Node.js
# Forces < 12 or > 12 to be uninstalled
- name: ASK apt/yum/dnf TO REMOVE PRE-EXISTING Node.js {{ nodejs_version_installed.stdout }} (IF IT'S NOT {{ nodejs_version }})
package:
name: nodejs
state: absent
when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stdout != ""
# Forces == 12
- name: Warn if Node.js {{ nodejs_version}} already installed & might be updated
debug:
msg: "WARN: YOUR Node.js {{ nodejs_version }} MIGHT NOW BE UPDATED USING nodesource.com"
when: nodejs_version_installed is defined and nodejs_version_installed.stdout == nodejs_version
# 2. INSTALL Node.js USING nodesource.com
# 2019-02-12: Should not be nec, as stanza below it should overwrite
# /etc/apt/sources.list.d/nodesource.list regardless!
#
#- name: Clear prior /etc/apt/sources.list.d/nodesource.list (permitting Node.js downgrade if nec)
# file:
# path: /etc/apt/sources.list.d/nodesource.list
# state: absent
# when: internet_available and is_debuntu
- name: Set up Node.js {{ nodejs_version }} apt sources (debuntu)
shell: curl -sL https://deb.nodesource.com/setup_{{ nodejs_version }} | bash -
args:
warn: no
creates: /etc/apt/sources.list.d/nodesource.list
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!)
# 2019-03-29: Above works on Debian 10 Buster pre-releases, but fails on Ubuntu
# 19.04 Beta. Comment it out for now, and manually run: "apt install npm" then
# "npm install -g npm@latest" (all *SHOULD* be magically fixed by 2019-04-18 ?)
# Forces update
- name: Install latest Node.js {{ nodejs_version }} which includes /usr/bin/npm (debuntu)
package:
#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
# nodesource.com approach to get a version of npm that works with Sugarizer:
# https://github.com/iiab/iiab/issues/798#issuecomment-404324530
#
# MORE POSITIVELY: this nodesource.com approach (brings in npm 5.6.0 with
# nodejs 8.11.3 for now, to any OS) would also work on Ubuntu 18.04, and
# might even bring about a sane consistency across mainline OS's?
#
# BUT FOR NOW: Ubuntu 18.04's apt (approach below) brings in npm 3.5.2,
# which appears suffic "SO FAR"? 18.04's nodejs 8.10.0 is more reassuring!
#
# CRAZY IDEA: most versions of npm can upgrade themselves to the latest
# (6.2.0 for now) using command "npm install -g npm", if that helps us in
# future, e.g. TK's memory issue etc? If so, be CAREFUL this puts npm
# in /usr/local/bin on Ubuntu 18.04 -- unlike Ubuntu 16.04 and Raspbian
# where it upgrades /usr/bin/npm in place:
# https://askubuntu.com/questions/1036278/npm-is-incorrect-version-on-latest-ubuntu-18-04-installation
# 2019-02-03: OLD WAY (PRIOR TO 2019) BELOW. Since then, @m-anish helped
# us standardize on the above nodesource.com approach i.e.
# https://github.com/nodesource/distributions#debinstall ...across all
# distros (so nodejs & npm always findable in /usr/bin, for Node-RED etc)
# - 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)
# 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
# ("testing" branch) both install Node.js 8.x (instead of 10.x). While the
# 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/ and Disco Dingo (Ubuntu
# 19.04) https://launchpad.net/ubuntu/+source/nodejs to keep us informed!
# 2019-03-29: Debian 10 Buster & Ubuntu 19.04 pre-releases made the jump
# thankfully; currently both offer Node.js 10.15.2
# 3. RECORD Node.js AS INSTALLED
- name: "Set 'nodejs_installed: True'"
set_fact:
nodejs_installed: True
- name: "Add 'nodejs_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^nodejs_installed'
line: 'nodejs_installed: True'

View file

@ -1,164 +1,57 @@
# 2019-02-12: SEE VAR nodejs_version: 10.x (FOR NOW!) IN vars/default_vars.yml
# AND IF NEC OVERRIDE THIS IN /etc/iiab/local_vars.yml
# SEE VAR nodejs_version: 12.x IN /opt/iiab/iiab/vars/default_vars.yml (FOR
# NOW!) AND IF NEC OVERRIDE THIS IN /etc/iiab/local_vars.yml
# Duplicate Node.js code unified by @jvonau. Revised by @holta. Now used by:
# roles/nodered/tasks/main.yml w/ roles/nodered/meta/main.yml
# roles/pbx/tasks/main.yml w/ roles/pbx/meta/main.yml (Asterisk/FreePBX)
# roles/sugarizer/tasks/main.yml w/ roles/sugarizer/meta/main.yml
# Duplicate Node.js code unified by @jvonau. Revised by @holta. Used by:
# roles/nodered/tasks/*.yml formerly w/ roles/nodered/meta/main.yml
# roles/pbx/tasks/*.yml formerly w/ roles/pbx/meta/main.yml (Asterisk/FreePBX)
# roles/sugarizer/tasks/*.yml formerly w/ roles/sugarizer/meta/main.yml
# 1. TEST IF Node.js ALEADY INSTALLED & WARN AS NEC
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
# 2019-02-03: BELOW TESTS IF 'nodejs' VERSION IS ALREADY INSTALLED:
# IF SO & THIS DOESN'T MATCH nodejs_version AS SET IN defaults_vars.yml
# AND/OR local_vars.yml, INSTALL HALTS WITH AN EXPLANATION (PR #1447)
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
# 2019-07-04: FOR A SOMEWHAT MORE MODERN "VERSION DETECTOR" SEE:
# github.com/iiab/iiab/blob/master/roles/nextcloud/tasks/install.yml#L1-L40
- name: Assert that "nodejs_install is sameas true" (boolean not string etc)
assert:
that: nodejs_install is sameas true
fail_msg: "PLEASE SET 'nodejs_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Try to run 'nodejs -v' to get Node.js version
# 'node -v' doesn't work with older versions e.g. Ubuntu 16.04's nodejs 4.2.6
# Both below convert v10.15.1 to 10.x, but this is safer: (removes non-digits)
shell: nodejs -v | sed 's/[^0-9]*//' | sed 's/[^0-9].*/.x/'
#shell: nodejs -v | sed 's/^[vV]//' | sed 's/\..*/.x/'
register: nodejs_version_installed
- name: Assert that "nodejs_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: nodejs_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'nodejs_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
#- debug:
# var: nodejs_version_installed
# When nodejs is NOT installed:
# nodejs_version_installed.rc == 0 # Crazy with stderr below, "due to pipes"
# nodejs_version_installed.stdout == ""
# nodejs_version_installed.stderr == "/bin/sh: 1: nodejs: not found"
# BOTH ABOVE (incl non-null stderr) are USED BELOW to confirm install is nec!
#- name: "ENFORCE PRECONDITION: Stop installing (intentionally fail) IF an installed 'nodejs' version isn't {{ nodejs_version }}"
# fail:
# msg: >
# PLEASE REMOVE 'nodejs' VERSION {{ nodejs_version_installed.stdout }} AS
# IT DOES NOT MATCH THE REQUIRED nodejs_version: {{ nodejs_version }} --
# as set in /opt/iiab/iiab/vars/default_vars.yml and/or
# /etc/iiab/local_vars.yml -- then re-run this IIAB installer.
# when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stderr == ""
# Forces < 12 or > 12 to be removed, ignored if file is absent
- name: Remove /etc/apt/sources.list.d/nodesource.list if nodejs_version_installed.stdout is not {{ nodejs_version }}
file:
state: absent
path: /etc/apt/sources.list.d/nodesource.list
when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stdout != ""
# BRUTAL but ensures consistency across OS's / distros like Raspbian Desktop & Ubermix that often include an older version of Node.js
# Forces < 12 or > 12 to be uninstalled
- name: ASK apt/yum/dnf TO REMOVE PRE-EXISTING Node.js {{ nodejs_version_installed.stdout }} (IF IT'S NOT {{ nodejs_version }})
package:
name: nodejs
state: absent
when: nodejs_version_installed is defined and nodejs_version_installed.stdout != nodejs_version and nodejs_version_installed.stdout != ""
# Forces == 12
- name: Warn if Node.js {{ nodejs_version}} already installed & might be updated
debug:
msg: "WARN: YOUR Node.js {{ nodejs_version }} MIGHT NOW BE UPDATED USING nodesource.com"
when: nodejs_version_installed is defined and nodejs_version_installed.stdout == nodejs_version
- debug:
var: nodejs_install
- debug:
var: nodejs_enabled
- debug:
var: nodejs_installed
# 2. INSTALL Node.js USING nodesource.com
# 2019-02-12: Should not be nec, as stanza below it should overwrite
# /etc/apt/sources.list.d/nodesource.list regardless!
#
#- name: Clear prior /etc/apt/sources.list.d/nodesource.list (permitting Node.js downgrade if nec)
# file:
# path: /etc/apt/sources.list.d/nodesource.list
# state: absent
# when: internet_available and is_debuntu
- name: Set up Node.js {{ nodejs_version }} apt sources (debuntu)
shell: curl -sL https://deb.nodesource.com/setup_{{ nodejs_version }} | bash -
args:
warn: no
creates: /etc/apt/sources.list.d/nodesource.list
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!)
# 2019-03-29: Above works on Debian 10 Buster pre-releases, but fails on Ubuntu
# 19.04 Beta. Comment it out for now, and manually run: "apt install npm" then
# "npm install -g npm@latest" (all *SHOULD* be magically fixed by 2019-04-18 ?)
# Forces update
- name: Install latest Node.js {{ nodejs_version }} which includes /usr/bin/npm (debuntu)
package:
#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
- name: Install Node.js if 'nodejs_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: nodejs_installed is undefined
# 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
# nodesource.com approach to get a version of npm that works with Sugarizer:
# https://github.com/iiab/iiab/issues/798#issuecomment-404324530
#
# MORE POSITIVELY: this nodesource.com approach (brings in npm 5.6.0 with
# nodejs 8.11.3 for now, to any OS) would also work on Ubuntu 18.04, and
# might even bring about a sane consistency across mainline OS's?
#
# BUT FOR NOW: Ubuntu 18.04's apt (approach below) brings in npm 3.5.2,
# which appears suffic "SO FAR"? 18.04's nodejs 8.10.0 is more reassuring!
#
# CRAZY IDEA: most versions of npm can upgrade themselves to the latest
# (6.2.0 for now) using command "npm install -g npm", if that helps us in
# future, e.g. TK's memory issue etc? If so, be CAREFUL this puts npm
# in /usr/local/bin on Ubuntu 18.04 -- unlike Ubuntu 16.04 and Raspbian
# where it upgrades /usr/bin/npm in place:
# https://askubuntu.com/questions/1036278/npm-is-incorrect-version-on-latest-ubuntu-18-04-installation
# 2019-02-03: OLD WAY (PRIOR TO 2019) BELOW. Since then, @m-anish helped
# us standardize on the above nodesource.com approach i.e.
# https://github.com/nodesource/distributions#debinstall ...across all
# distros (so nodejs & npm always findable in /usr/bin, for Node-RED etc)
# - 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)
# 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
# ("testing" branch) both install Node.js 8.x (instead of 10.x). While the
# 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/ and Disco Dingo (Ubuntu
# 19.04) https://launchpad.net/ubuntu/+source/nodejs to keep us informed!
# 2019-03-29: Debian 10 Buster & Ubuntu 19.04 pre-releases made the jump
# thankfully; currently both offer Node.js 10.15.2
# 3. RECORD Node.js AS INSTALLED
- name: "Set 'nodejs_installed: True'"
set_fact:
nodejs_installed: True
- name: "Add 'nodejs_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^nodejs_installed'
line: 'nodejs_installed: True'
- name: Add 'nodejs' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab_state.yml
section: nodejs
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Node.js
- option: description
value: '"Node.js is a JavaScript runtime environment built on Chrome''s V8 JavaScript engine, that executes JavaScript code outside of a browser."'
- option: nodejs_install
value: "{{ nodejs_install }}"
- option: nodejs_enabled
value: "{{ nodejs_enabled }}"

View file

@ -0,0 +1,12 @@
- name: Enable http://box/nodered via Apache
command: a2ensite nodered.conf
when: nodered_enabled | bool
- name: Disable http://box/nodered via Apache
command: a2dissite nodered.conf
when: not nodered_enabled
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -1,68 +0,0 @@
- name: Enable & (Re)start 'nodered' systemd service
systemd:
name: nodered
daemon_reload: yes
enabled: yes
state: restarted
when: nodered_enabled
- name: Disable & Stop 'nodered' systemd service
systemd:
name: nodered
enabled: no
state: stopped
when: not nodered_enabled
# Apache
- name: Enable http://box/nodered via Apache
command: a2ensite nodered.conf
when: apache_install and nodered_enabled
- name: Disable http://box/nodered via Apache
command: a2dissite nodered.conf
when: apache_install and not nodered_enabled
- name: Restart Apache systemd service ({{ apache_service }})
systemd:
name: "{{ apache_service }}"
state: restarted
when: apache_enabled | bool
# NGINX
- name: "SHIM: Enable http://box/nodered_url via NGINX, by installing {{ nginx_conf_dir }}/nodered-nginx.conf from template"
template:
src: nodered-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/nodered-nginx.conf"
# mode: '0666'
when: nginx_install and nodered_enabled
- name: "SHIM: Disable http://box/nodered_url via NGINX, by removing {{ nginx_conf_dir }}/nodered-nginx.conf"
file:
path: "{{ nginx_conf_dir }}/nodered-nginx.conf"
state: absent
when: nginx_install and not nodered_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted
when: nginx_enabled | bool
- name: Add 'nodered' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
section: nodered
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Node-RED
- option: description
value: '"Node-RED is a flow-based development tool for visual programming developed originally by IBM for wiring together hardware devices, APIs and online services as part of the Internet of Things. Node-RED provides a web browser-based flow editor, which can be used to create JavaScript functions."'
- option: nodered_install
value: "{{ nodered_install }}"
- option: nodered_enabled
value: "{{ nodered_enabled }}"

View file

@ -1,31 +1,24 @@
# 2019-01-16: @jvonau's PR #1403 moved installation of Node.js (8.x for now) &
# npm to roles/nodejs/tasks/main.yml
- debug:
var: nodejs_install
- debug:
var: nodejs_enabled
- debug:
var: nodejs_installed
- name: "Set 'nodejs_install: True' and 'nodejs_enabled: True'"
set_fact:
nodejs_install: True
nodejs_enabled: True
# 2020-01-04 no longer triggered by roles/nodered/meta/main.yml
- name: NODEJS - run the 'nodejs' role
- name: NODEJS - run 'nodejs' role (attempt to install & enable Node.js)
include_role:
name: nodejs
- name: FAIL (STOP THE INSTALL) IF nodejs_installed is undefined
- name: FAIL (STOP THE INSTALL) IF 'nodejs_installed is undefined'
fail:
msg: "Sugarizer install cannot proceed, as Node.js failed to install."
msg: "Node-RED install cannot proceed, as Node.js is not installed."
when: nodejs_installed is undefined
- name: FAIL (STOP THE INSTALL) IF nodejs_version != "12.x"
- name: FAIL (STOP THE INSTALL) IF 'nodejs_version != "12.x"'
fail:
msg: "Sugarizer install cannot proceed, as it currently requires Node.js 12.x, and your nodejs_version appears to be {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc!"
msg: "Node-RED install cannot proceed, as it currently requires Node.js 12.x, whereas nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc."
when: nodejs_version != "12.x"

View file

@ -1,5 +1,66 @@
- include_tasks: install.yml
when: nodered_install and not nodered_installed is defined
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
- include_tasks: enable.yml
when: nodered_install or nodered_installed is defined
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Assert that "nodered_install is sameas true" (boolean not string etc)
assert:
that: nodered_install is sameas true
fail_msg: "PLEASE SET 'nodered_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Assert that "nodered_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: nodered_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'nodered_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Install Node-RED if nodered_installed is not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: nodered_installed is undefined
- name: Enable & (Re)start 'nodered' systemd service, if nodered_enabled
systemd:
name: nodered
daemon_reload: yes
enabled: yes
state: restarted
when: nodered_enabled | bool
- name: Disable & Stop 'nodered' systemd service, if not nodered_enabled
systemd:
name: nodered
enabled: no
state: stopped
when: not nodered_enabled
#- name: Enable/Disable/Restart Apache if primary
- name: SHIM FOR NOW SO ALWAYS DO THE...Enable/Disable/Restart Apache
include_tasks: apache.yml
#when: not nginx_enabled
- name: Enable/Disable/Restart NGINX if primary
include_tasks: nginx.yml
when: nginx_enabled | bool
- name: Add 'nodered' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: nodered
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Node-RED
- option: description
value: '"Node-RED is a flow-based development tool for visual programming developed originally by IBM for wiring together hardware devices, APIs and online services as part of the Internet of Things. Node-RED provides a web browser-based flow editor, which can be used to create JavaScript functions."'
- option: nodered_install
value: "{{ nodered_install }}"
- option: nodered_enabled
value: "{{ nodered_enabled }}"

View file

@ -0,0 +1,16 @@
- name: Enable http://box/nodered via NGINX, by installing {{ nginx_conf_dir }}/nodered-nginx.conf from template
template:
src: nodered-nginx.conf.j2
dest: "{{ nginx_conf_dir }}/nodered-nginx.conf" # /etc/nginx/conf.d
when: nodered_enabled | bool
- name: Disable http://box/nodered via NGINX, by removing {{ nginx_conf_dir }}/nodered-nginx.conf
file:
path: "{{ nginx_conf_dir }}/nodered-nginx.conf" # /etc/nginx/conf.d
state: absent
when: not nodered_enabled
- name: Restart 'nginx' systemd service
systemd:
name: nginx
state: restarted

View file

@ -0,0 +1,72 @@
- name: "Set 'nodejs_install: True' and 'nodejs_enabled: True'"
set_fact:
nodejs_install: True
nodejs_enabled: True
- name: NODEJS - run 'nodejs' role (attempt to install & enable Node.js)
include_role:
name: nodejs
- name: FAIL (STOP THE INSTALL) IF 'nodejs_installed is undefined'
fail:
msg: "PBX install cannot proceed, as Node.js is not installed."
when: nodejs_installed is undefined
- name: FAIL (STOP THE INSTALL) IF 'nodejs_version != "10.x"'
fail:
msg: "PBX install cannot proceed, as it currently requires Node.js 10.x, whereas nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc."
when: nodejs_version != "10.x"
#- name: TODO: Check if asterisk and freepbx are already installed
- debug: # Crazy spacing below is tuned for 80-column screens
msg: >-
####################################################################WARNING:
ONLY UBUNTU 18.04, DEBIAN 9 & RASPBIAN ARE SUPPORTED AS OF FEB 2019. Please
assist Internet-in-a-Box communities worldwide if you can make
Asterisk and FreePBX work on other OS's / distros, Thank
You! http://FAQ.IIAB.IO ###############################################################################
- name: Check if freepbx is already installed
stat:
path: /etc/systemd/system/freepbx.service
register: freepbx_installed
- debug:
msg: >-
FreePBX already installed. Reinstall shall be skipped
when: freepbx_installed.stat.exists
- name: Install Asterisk (debuntu)
include_tasks: asterisk.yml
when: internet_available and pbx_install and (not pbx_installed) and is_debuntu and (not freepbx_installed.stat.exists)
#when: internet_available and pbx_install and (not pbx_installed) and ((is_debian and ansible_distribution_major_version == "9") or is_ubuntu_18)
- name: Install FreePBX (debuntu)
include_tasks: freepbx.yml
when: internet_available and pbx_install and (not pbx_installed) and is_debuntu and (not freepbx_installed.stat.exists)
#when: internet_available and pbx_install and (not pbx_installed) and ((is_debian and ansible_distribution_major_version == "9") or is_ubuntu_18)
- name: Enable FreePBX (debuntu)
include_tasks: freepbx_enable.yml
when: internet_available and pbx_install and (not pbx_installed) and is_debuntu
#when: internet_available and pbx_install and (not pbx_installed) and ((is_debian and ansible_distribution_major_version == "9") or is_ubuntu_18)
- name: Asterisk - Install chan_dongle
include: chan_dongle.yml
when: asterisk_chan_dongle | bool
# RECORD PBX AS INSTALLED
- name: "Set 'pbx_installed: True'"
set_fact:
pbx_installed: True
- name: "Add 'pbx_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^pbx_installed'
line: 'pbx_installed: True'

View file

@ -1,81 +1,41 @@
- debug:
var: nodejs_install
- debug:
var: nodejs_enabled
- debug:
var: nodejs_installed
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
- name: "Set 'nodejs_install: True' and 'nodejs_enabled: True'"
set_fact:
nodejs_install: True
nodejs_enabled: True
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: NODEJS - run the 'nodejs' role
include_role:
name: nodejs
- name: Assert that "pbx_install is sameas true" (boolean not string etc)
assert:
that: pbx_install is sameas true
fail_msg: "PLEASE SET 'pbx_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: FAIL (STOP THE INSTALL) IF nodejs_installed is undefined
fail:
msg: "PBX install cannot proceed, as Node.js failed to install."
when: nodejs_installed is undefined
- name: Fail if nodejs_version is incorrect
fail:
msg: >-
PBX: Refusing to install as nodejs_version is not 10.x. Please fix that
(looking into /etc/iiab/local_vars.yml and
/opt/iiab/iiab/vars/default_vars.yml) and then rerun.
when: pbx_install and (nodejs_version != "10.x")
#- name: TODO: Check if asterisk and freepbx are already installed
- debug: # Crazy spacing below is tuned for 80-column screens
msg: >-
####################################################################WARNING:
ONLY UBUNTU 18.04, DEBIAN 9 & RASPBIAN ARE SUPPORTED AS OF FEB 2019. Please
assist Internet-in-a-Box communities worldwide if you can make
Asterisk and FreePBX work on other OS's / distros, Thank
You! http://FAQ.IIAB.IO ###############################################################################
- name: Check if freepbx is already installed
stat:
path: /etc/systemd/system/freepbx.service
register: freepbx_installed
- debug:
msg: >-
FreePBX already installed. Reinstall shall be skipped
when: freepbx_installed.stat.exists
- name: Install Asterisk (debuntu)
include_tasks: asterisk.yml
when: internet_available and pbx_install and (not pbx_installed) and is_debuntu and (not freepbx_installed.stat.exists)
#when: internet_available and pbx_install and (not pbx_installed) and ((is_debian and ansible_distribution_major_version == "9") or is_ubuntu_18)
- name: Install FreePBX (debuntu)
include_tasks: freepbx.yml
when: internet_available and pbx_install and (not pbx_installed) and is_debuntu and (not freepbx_installed.stat.exists)
#when: internet_available and pbx_install and (not pbx_installed) and ((is_debian and ansible_distribution_major_version == "9") or is_ubuntu_18)
- name: Enable FreePBX (debuntu)
include_tasks: freepbx_enable.yml
when: internet_available and pbx_install and (not pbx_installed) and is_debuntu
#when: internet_available and pbx_install and (not pbx_installed) and ((is_debian and ansible_distribution_major_version == "9") or is_ubuntu_18)
- name: Asterisk - Install chan_dongle
include: chan_dongle.yml
when: asterisk_chan_dongle | bool
- name: Assert that "pbx_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: pbx_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'pbx_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
# RECORD PBX AS INSTALLED
- name: Install PBX if pbx_installed is not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: pbx_installed is undefined
- name: "Set 'pbx_installed: True'"
set_fact:
pbx_installed: True
- name: "Add 'pbx_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^pbx_installed'
line: 'pbx_installed: True'
- name: Add 'pbx' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: pbx
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: PBX
- option: description
value: '"Full-featured PBX for rural telephony etc, that can integrate with GSM (mobile phone) networks. Based on Asterisk (Voice over IP, SIP telephone numbers) and FreePBX (web-based GUI to administer it)."'
- option: pbx_install
value: "{{ pbx_install }}"
- option: pbx_enabled
value: "{{ pbx_enabled }}"

View file

@ -0,0 +1,94 @@
- name: Install 'postgresql' package
package:
name: postgresql
state: present
- name: Install 'postgresql-client' package (debuntu)
package:
name: postgresql-client
state: present
when: is_debuntu | bool
- name: Install 'postgresql-server' package (OS's other than debuntu)
package:
name: postgresql-server
state: present
when: not is_debuntu
- name: Install /etc/systemd/system/postgresql-iiab.service from template
template:
src: postgresql-iiab.service
dest: /etc/systemd/system/postgresql-iiab.service
# owner: root
# group: root
# mode: '0644'
- name: Create PostgreSQL data dir /library/pgsql-iiab, owned by postgres:postgres
file:
path: /library/pgsql-iiab
owner: postgres
group: postgres
mode: '0700'
state: directory
- name: Make sure locale {{ postgresql_locale }} is enabled (debuntu) # en_US.UTF-8
lineinfile:
dest: /etc/locale.gen
line: "{{ postgresql_locale }} UTF-8"
when: is_debuntu | bool
- name: Generate locales (debuntu)
command: /usr/sbin/locale-gen
when: is_debuntu | bool
- name: Initialize the PostgreSQL db, creating /library/pgsql-iiab/pg_hba.conf (debuntu)
#command: su - postgres -c "/usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab"
command: /usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab
args:
creates: /library/pgsql-iiab/pg_hba.conf
become: yes
become_user: postgres
when: is_debuntu | bool
- name: Initialize the PostgreSQL db, creating /library/pgsql-iiab/pg_hba.conf (OS's other than debuntu)
#command: su - postgres -c "/usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab"
command: /usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab
args:
creates: /library/pgsql-iiab/pg_hba.conf
become: yes
become_user: postgres
when: not is_debuntu
- name: Install /library/pgsql-iiab/postgresql.conf owned by postgres:postgres, from template
template:
backup: yes
src: postgresql.conf.j2
dest: /library/pgsql-iiab/postgresql.conf
owner: postgres
group: postgres
mode: '0640'
# Likely No Longer Nec! Given stanza below does the same...
#- name: 'Stop postgresql service: /etc/init.d/postgresql stop (debuntu)'
# command: "/etc/init.d/postgresql stop"
# ignore_errors: True
# when: postgresql_install and is_debuntu
- name: Disable & Stop stock 'postgresql' systemd service
systemd:
name: postgresql
state: stopped
enabled: no
# RECORD PostgreSQL AS INSTALLED
- name: "Set 'postgresql_installed: True'"
set_fact:
postgresql_installed: True
- name: "Add 'postgresql_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^postgresql_installed'
line: 'postgresql_installed: True'

View file

@ -1,122 +1,55 @@
# TO DO:
# - Validate input vars postgresql_install & postgresql_enabled
# - Put ~13 stanzas just below into install.yml
# - Triggered by... 'when: postgresql_installed is undefined'
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
- name: Install 'postgresql' package
package:
name: postgresql
state: present
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: Install 'postgresql-client' package (debuntu)
package:
name: postgresql-client
state: present
when: is_debuntu | bool
- name: Assert that "postgresql_install is sameas true" (boolean not string etc)
assert:
that: postgresql_install is sameas true
fail_msg: "PLEASE SET 'postgresql_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Install 'postgresql-server' package (OS's other than debuntu)
package:
name: postgresql-server
state: present
when: not is_debuntu
- name: Assert that "postgresql_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: postgresql_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'postgresql_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: Install /etc/systemd/system/postgresql-iiab.service from template
template:
src: postgresql-iiab.service
dest: /etc/systemd/system/postgresql-iiab.service
# owner: root
# group: root
# mode: '0644'
- name: Create PostgreSQL data dir /library/pgsql-iiab, owned by postgres:postgres
file:
path: /library/pgsql-iiab
owner: postgres
group: postgres
mode: '0700'
state: directory
- name: Make sure locale {{ postgresql_locale }} is enabled (debuntu) # en_US.UTF-8
lineinfile:
dest: /etc/locale.gen
line: "{{ postgresql_locale }} UTF-8"
when: is_debuntu | bool
- name: Generate locales (debuntu)
command: /usr/sbin/locale-gen
when: is_debuntu | bool
- name: Initialize the PostgreSQL db, creating /library/pgsql-iiab/pg_hba.conf (debuntu)
#command: su - postgres -c "/usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab"
command: /usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab
args:
creates: /library/pgsql-iiab/pg_hba.conf
become: yes
become_user: postgres
when: is_debuntu | bool
- name: Initialize the PostgreSQL db, creating /library/pgsql-iiab/pg_hba.conf (OS's other than debuntu)
#command: su - postgres -c "/usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab"
command: /usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab
args:
creates: /library/pgsql-iiab/pg_hba.conf
become: yes
become_user: postgres
when: not is_debuntu
- name: Install /library/pgsql-iiab/postgresql.conf owned by postgres:postgres, from template
template:
backup: yes
src: postgresql.conf.j2
dest: /library/pgsql-iiab/postgresql.conf
owner: postgres
group: postgres
mode: '0640'
# Likely No Longer Nec! Given stanza below does the same...
#- name: 'Stop postgresql service: /etc/init.d/postgresql stop (debuntu)'
# command: "/etc/init.d/postgresql stop"
# ignore_errors: True
# when: postgresql_install and is_debuntu
- name: Disable & Stop stock 'postgresql' systemd service
systemd:
name: postgresql
state: stopped
enabled: no
- debug:
var: postgresql_install
- debug:
var: postgresql_enabled
- debug:
var: postgresql_installed
# RECORD PostgreSQL AS INSTALLED
- name: "Set 'postgresql_installed: True'"
set_fact:
postgresql_installed: True
- name: "Add 'postgresql_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^postgresql_installed'
line: 'postgresql_installed: True'
- name: Install PostgreSQL if 'postgresql_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: postgresql_installed is undefined
- name: Enable & Start 'postgresql-iiab' systemd service, if 'postgresql_enabled'
- name: Enable & Start 'postgresql-iiab' systemd service, if postgresql_enabled
systemd:
name: postgresql-iiab
state: started
daemon_reload: yes
enabled: yes
state: started
when: postgresql_enabled | bool
- name: Disable 'postgresql-iiab' systemd service, if not 'postgresql_enabled'
- name: Disable & Stop 'postgresql-iiab' systemd service, if not postgresql_enabled
systemd:
name: postgresql-iiab
state: stopped
enabled: no
state: stopped
when: not postgresql_enabled
- name: Add 'postgresql' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}"
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab_state.yml
section: postgresql
option: "{{ item.option }}"
value: "{{ item.value | string }}"

View file

@ -6,7 +6,7 @@
command: a2dissite sugarizer.conf
when: not sugarizer_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -1,64 +1,32 @@
# 0. ATTEMPT INSTALL-THEN-ASSERT OF (1) HARD PREREQ Node.js (2) SOFT PREREQ MongoDB
# 0. INSTALL/ASSERT PREREQ #1: MongoDB
- debug:
var: nodejs_install
- debug:
var: nodejs_enabled
- debug:
var: nodejs_installed
# 3 stanzas moved up to main.yml, so Debian finishes "BIG-sized" IIAB install
# (WITH LOUD RED WARNINGS!)
# 1. INSTALL/ASSERT PREREQ #2: Node.js
- name: "Set 'nodejs_install: True' and 'nodejs_enabled: True'"
set_fact:
nodejs_install: True
nodejs_enabled: True
- name: NODEJS - run the 'nodejs' role
- name: NODEJS - run 'nodejs' role (attempt to install & enable Node.js)
include_role:
name: nodejs
- name: FAIL (STOP THE INSTALL) IF nodejs_installed is undefined
- name: FAIL (STOP THE INSTALL) IF 'nodejs_installed is undefined'
fail:
msg: "Sugarizer install cannot proceed, as Node.js failed to install."
msg: "Sugarizer install cannot proceed, as Node.js is not installed."
when: nodejs_installed is undefined
- name: FAIL (STOP THE INSTALL) IF nodejs_version != "12.x"
- name: FAIL (STOP THE INSTALL) IF 'nodejs_version != "12.x"'
fail:
msg: "Sugarizer install cannot proceed, as it currently requires Node.js 12.x, and your nodejs_version appears to be {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc!"
msg: "Sugarizer install cannot proceed, as it currently requires Node.js 12.x, whereas nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml, /etc/iiab/local_vars.yml, /opt/iiab/iiab/roles/nodejs, etc."
when: nodejs_version != "12.x"
- debug:
var: mongodb_install
- debug:
var: mongodb_enabled
- debug:
var: mongodb_installed
- name: "Set 'mongodb_install: True' and 'mongodb_enabled: True'"
set_fact:
mongodb_install: True
mongodb_enabled: True
- name: MONGODB - run the 'mongodb' role
include_role:
name: mongodb
# 2020-01-29: FOR NOW LET'S TRY A VERY SOFT (BEST EFFORT) PREREQ, AS Sugarizer
# TRADITIONALLY CAN WORK (?) EVEN WITHOUT MongoDB. IF LATER WE INSTEAD WANT TO
# ENFORCE MongoDB...AS A MEDIUM-STRENGTH PREREQ...OR AS A HARD (STRICT) PREREQ
# ...THEN UNCOMMENT EITHER BELOW:
#
#- name: EXIT SUGARIZER PLAYBOOK (BUT CONTINUE INSTALLING IIAB) IF mongodb_installed is undefined
# meta: end_play
# when: mongodb_installed is undefined
#
#- name: FAIL (STOP THE INSTALL) IF mongodb_installed is undefined
# fail:
# msg: "Sugarizer install cannot proceed, as MongoDB failed to install."
# when: mongodb_installed is undefined
# 1. DOWNLOAD+LINK /opt/iiab/sugarizer
# 2. DOWNLOAD+LINK /opt/iiab/sugarizer
- name: Clone llaske/sugarizer ({{ sugarizer_git_version }} branch/version) from GitHub to /opt/iiab/{{ sugarizer_dir_version }} (MAY DOWNLOAD 600+ MB)
git:
@ -76,7 +44,7 @@
state: link
# 2. DOWNLOAD+LINK /opt/iiab/sugarizer-server
# 3. DOWNLOAD+LINK /opt/iiab/sugarizer-server
# 2018-07-11: http://download.iiab.io/packages/sugarizer-server-1.0.tar.gz
# was flawed, as documented at:
@ -109,13 +77,7 @@
state: link
# 3. INSTALL A GOOD VERSION OF Node.js AND npm
# 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
# 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules
# 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules (TWICE, BIG JOB THEN SMALL JOB)
# Re-running "npm install" USED TO fail on Raspbian 9 if not other OS's ?
# Strategies considered to avoid re-running it:

View file

@ -19,52 +19,35 @@
quiet: yes
- name: Install Sugarizer if 'sugarizer_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: sugarizer_installed is undefined
# 3 stanzas moved up from install.yml, so Debian finishes "BIG" IIAB install:
# (WITH LOUD RED WARNINGS!)
- name: "Set 'mongodb_install: True' and 'mongodb_enabled: True'"
set_fact:
mongodb_install: True
mongodb_enabled: True
# Auto-starts mongodb via the requires= line in unit file
- name: Enable & Restart 'sugarizer' systemd service, if sugarizer_enabled
systemd:
name: sugarizer
daemon_reload: yes # in case mongodb.service changed, etc
enabled: yes
state: restarted
when: sugarizer_enabled | bool
- name: MONGODB - run 'mongodb' role (attempt to install & enable MongoDB)
include_role:
name: mongodb
# Stops sugarizer but not mongodb
- name: Disable & Stop 'sugarizer' systemd service, if not sugarizer_enabled
systemd:
name: sugarizer
enabled: no
state: stopped
when: not sugarizer_enabled
- name: EXIT 'sugarizer' ROLE & CONTINUE, IF 'mongodb_installed is undefined'
fail: # FORCE IT RED THIS ONCE!
msg: MongoDB INSTALLATION FAILED, likely because your OS is Debian. Nevertheless IIAB will continue (consider this a warning!)
when: mongodb_installed is undefined
ignore_errors: yes
# Stops mongodb (in the past this would've been called via meta/main.yml)
- name: Run mongodb/tasks/enable.yml to stop MongoDB, if not sugarizer_enabled
include_tasks: roles/mongodb/tasks/enable.yml
when: not sugarizer_enabled
# ELSE...
- name: Enable/Disable/Restart Apache if primary
include_tasks: apache.yml
when: not nginx_enabled
- name: Install/Enable/Disable/Record Sugarizer (main2.yml) IF 'mongodb_installed is defined'
include_tasks: main2.yml
when: mongodb_installed is defined
- name: Enable/Disable/Restart NGINX if primary
include_tasks: nginx.yml
when: nginx_enabled | bool
# THE block: APPROACH BELOW WORKS JUST LIKE main2.yml ABOVE.
# BUT IT VISUALLY POLLUTES: MANY BLUE "skipping:" MESSAGES IN ANSIBLE'S OUTPUT.
- name: Add 'sugarizer' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: sugarizer
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Sugarizer
- option: description
value: '"The Sugar Learning Platform began with the famous One Laptop Per Child project, written in Python. Sugarizer is the new HTML/JavaScript implementation of Sugar, usable in most all browsers."'
- option: sugarizer_enabled
value: "{{ sugarizer_enabled }}"
# - block: # ENTIRE BLOCK CONDITIONED ON 'when: mongodb_installed is defined'
#
# [MOVED TO main2.yml]
#
# when: mongodb_installed is defined # CONDITION FOR ENTIRE ABOVE block:

View file

@ -0,0 +1,64 @@
- name: Install Sugarizer if 'sugarizer_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: sugarizer_installed is undefined
- block: # 2 STANZAS BELOW, CONDITIONED ON 'when: sugarizer_enabled | bool'
# sugarizer.service line 'Requires=mongodb.service' auto-starts MongoDB (but record that in var too)
- name: "Set 'mongodb_enabled: True' if sugarizer_enabled"
set_fact:
mongodb_enabled: True
- name: Enable & Restart 'sugarizer' systemd service, if sugarizer_enabled
systemd:
name: sugarizer
daemon_reload: yes # In case mongodb.service changed, etc
enabled: yes
state: restarted
when: sugarizer_enabled | bool # CONDITION FOR 2-STANZA block: ABOVE
- block: # 3 STANZAS BELOW, CONDITIONED ON 'when: not sugarizer_enabled'
# Stops 'sugarizer' but not 'mongodb'
- name: Disable & Stop 'sugarizer' systemd service, if not sugarizer_enabled
systemd:
name: sugarizer
enabled: no
state: stopped
# Disable & Stop 'mongodb' via 2 stanzas below
# (meta/main.yml did this in the past)
- name: "Set 'mongodb_enabled: False' if not sugarizer_enabled"
set_fact:
mongodb_enabled: False
- name: MONGODB - run 'mongodb' role, to Disable & Stop MongoDB, if not sugarizer_enabled
include_role:
name: mongodb
when: not sugarizer_enabled # CONDITION FOR 3-STANZA block: ABOVE
- name: Enable/Disable/Restart Apache if primary
include_tasks: apache.yml
when: not nginx_enabled
- name: Enable/Disable/Restart NGINX if primary
include_tasks: nginx.yml
when: nginx_enabled | bool
- name: Add 'sugarizer' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: sugarizer
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Sugarizer
- option: description
value: '"The Sugar Learning Platform began with the famous One Laptop Per Child project, written in Python. Sugarizer is the new HTML/JavaScript implementation of Sugar, usable in most all browsers."'
- option: sugarizer_enabled
value: "{{ sugarizer_enabled }}"

View file

@ -6,7 +6,7 @@
command: a2dissite wordpress.conf
when: not wordpress_enabled
- name: Restart '{{ apache_service }}' systemd service
- name: (Re)Start '{{ apache_service }}' systemd service
systemd:
name: "{{ apache_service }}" # apache2 or httpd, as set in /opt/iiab/iiab/vars/<OS>.yml
state: restarted

View file

@ -0,0 +1,41 @@
- name: "Yarn | GPG"
apt_key:
url: https://dl.yarnpkg.com/debian/pubkey.gpg
state: present
- name: "Yarn | Ensure Debian sources list file exists"
file:
path: /etc/apt/sources.list.d/yarn.list
owner: root
mode: '0644'
state: touch
- name: "Yarn | Ensure Debian package is in sources list"
lineinfile:
dest: /etc/apt/sources.list.d/yarn.list
regexp: 'deb https://dl.yarnpkg.com/debian/ stable main'
line: 'deb https://dl.yarnpkg.com/debian/ stable main'
state: present
- name: "Yarn | Update APT cache"
apt:
update_cache: yes
- name: "Yarn | Install"
package:
name: yarn
state: latest
when: internet_available and is_debuntu
# RECORD Yarn AS INSTALLED
- name: "Set 'yarn_installed: True'"
set_fact:
yarn_installed: True
- name: "Add 'yarn_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^yarn_installed'
line: 'yarn_installed: True'

View file

@ -1,41 +1,48 @@
- name: "Yarn | GPG"
apt_key:
url: https://dl.yarnpkg.com/debian/pubkey.gpg
state: present
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
- name: "Yarn | Ensure Debian sources list file exists"
file:
path: /etc/apt/sources.list.d/yarn.list
owner: root
mode: '0644'
state: touch
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
- name: "Yarn | Ensure Debian package is in sources list"
lineinfile:
dest: /etc/apt/sources.list.d/yarn.list
regexp: 'deb http://dl.yarnpkg.com/debian/ stable main'
line: 'deb http://dl.yarnpkg.com/debian/ stable main'
state: present
- name: Assert that "yarn_install is sameas true" (boolean not string etc)
assert:
that: yarn_install is sameas true
fail_msg: "PLEASE SET 'yarn_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: "Yarn | Update APT cache"
apt:
update_cache: yes
- name: Assert that "yarn_enabled | type_debug == 'bool'" (boolean not string etc)
assert:
that: yarn_enabled | type_debug == 'bool'
fail_msg: "PLEASE GIVE VARIABLE 'yarn_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet: yes
- name: "Yarn | Install"
package:
name: yarn
state: latest
when: internet_available and is_debuntu
- debug:
var: yarn_install
- debug:
var: yarn_enabled
- debug:
var: yarn_installed
# RECORD Yarn AS INSTALLED
- name: Install Yarn if 'yarn_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks: install.yml
when: yarn_installed is undefined
- name: "Set 'yarn_installed: True'"
set_fact:
yarn_installed: True
- name: "Add 'yarn_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^yarn_installed'
line: 'yarn_installed: True'
- name: Add 'yarn' variable values to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab_state.yml
section: yarn
option: "{{ item.option }}"
value: "{{ item.value | string }}"
with_items:
- option: name
value: Yarn
- option: description
value: '"Fast, reliable, and secure dependency management. Comparable to npm. Released by Facebook in October 2016."'
- option: yarn_install
value: "{{ yarn_install }}"
- option: yarn_enabled
value: "{{ yarn_enabled }}"

View file

@ -61,7 +61,7 @@ fi
#fi
if [ "$REINSTALL" == "1" ]; then
if [ ! $1 == "internetarchive" ]; then # special handling
#if [ ! $1 == "internetarchive" ]; then # special handling
if [ $1 == "calibre-web" ]; then # role directory & installed marker differ
sed -i -e '/^calibreweb/d' $IIAB_STATE_FILE
elif [ $1 == "httpd" ]; then # role directory & installed marker differ
@ -72,8 +72,8 @@ if [ "$REINSTALL" == "1" ]; then
# sed -i -e '/^pan_bluetooth/d' $IIAB_STATE_FILE
else
sed -i -e "/^$1/d" $IIAB_STATE_FILE
fi
fi
fi
#fi
fi
if [ $# -eq 2 ]; then

View file

@ -284,10 +284,11 @@ squid_enabled: False
dansguardian_install: False
dansguardian_enabled: False
# 2020-01-23: postgresql_install is completely ignored as PostgreSQL is
# installed on demand as a dependency -- by Moodle &/or Pathagar as nec --
# but for now we set fake value 'postgresql_install: True' for
# 'postgresql_installed is defined' tests e.g. in 0-init/tasks/validate_vars.yml
# 2020-02-04: postgresql_install is completely ignored as PostgreSQL is
# installed on demand as a dependency -- by Moodle &/or Pathagar -- but for now
# we set fake value 'postgresql_install: True' so that
# 'postgresql_installed is defined' input validation works, e.g. in
# 0-init/tasks/validate_vars.yml
postgresql_install: True
postgresql_enabled: False
@ -381,10 +382,11 @@ mosquitto_install: False
mosquitto_enabled: False
mosquitto_port: 1883
# 2020-01-23: nodejs_install is completely ignored as Node.js is installed on
# 2020-02-04: nodejs_install is completely ignored as Node.js is installed on
# demand as a dependency -- by Node-RED, Sugarizer and/or Internet Archive --
# but for now we set fake value 'nodejs_install: True' for
# 'nodejs_installed is defined' tests e.g. in 0-init/tasks/validate_vars.yml
# but for now we set fake value 'nodejs_install: True' so that
# 'nodejs_installed is defined' input validation works, e.g. in
# 0-init/tasks/validate_vars.yml
nodejs_install: True
nodejs_enabled: False
# Node.js version used by roles/nodejs/tasks/main.yml for 3 roles:
@ -454,11 +456,12 @@ moodle_enabled: False
# If using Moodle intensively, set apache_high_php_limits in 3-BASE-SERVER
# MongoDB (/library/dbdata/mongodb) greatly enhances the Sugarizer experience.
# The roles/mongodb playbook (was?) invoked by roles/sugarizer/meta/main.yml
# 2020-01-23: mongodb_install is completely ignored as MongoDB is installed on
# This role was formerly installed by roles/sugarizer/meta/main.yml
#
# 2020-02-04: mongodb_install is completely ignored as MongoDB is installed on
# demand as a dependency -- by Sugarizer -- but for now we set fake value
# 'mongodb_install: True' for 'mongodb_installed is defined' tests e.g. in
# 0-init/tasks/validate_vars.yml
# 'mongodb_install: True' so that 'mongodb_installed is defined' input
# validation works, e.g. in 0-init/tasks/validate_vars.yml
mongodb_install: True
# FYI 'mongodb_enabled: False' works when Sugarizer is disabled. Required by
# mongodb/tasks/enable.yml to shut down the service and log status, but that is
@ -549,8 +552,16 @@ vnstat_enabled: True
# 9-LOCAL-ADDONS
# Internet Archive Decentralized Web - create your own offline version box:4244
# (or http://box/archive) arising from digital library https://dweb.archive.org
# 2020-02-04: yarn_install is completely ignored as the Yarn package manager is
# installed on demand as a dependency -- by Internet Archive -- but for now we
# set fake value 'yarn_install: True' so that 'yarn_installed is defined' input
# validation works, e.g. in 0-init/tasks/validate_vars.yml
yarn_install: True
yarn_enabled: False
# Internet Archive Offline / Decentralized Web - create your own offline
# version (http://box:4244 or later http://box/archive?) arising from digital
# library https://dweb.archive.org
internetarchive_install: False
internetarchive_enabled: False
internetarchive_port: 4244 # for http://box:4244