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

Cleaner internetarchive & assoc deps

This commit is contained in:
root 2020-02-04 18:19:44 -05:00
parent 027832889b
commit e54b6225c9
14 changed files with 258 additions and 147 deletions

View file

@ -1,14 +1,14 @@
# Assume (enforce) we only get here if elgg_install: True
# Assume (enforce) 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: "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 }}

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

@ -40,12 +40,12 @@
# enabled: no
# when: not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)
- name: "Set 'postgresql_enabled: True'" if moodle_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)'
- 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)

View file

@ -48,7 +48,7 @@
value: "{{ item.value | string }}"
with_items:
- option: name
value: Nodejs
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: install

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 http://dl.yarnpkg.com/debian/ stable main'
line: 'deb http://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