1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/distweb/tasks/main.yml

96 lines
3 KiB
YAML
Raw Normal View History

2019-03-28 19:51:57 +00:00
# We need a recent version of node
- name: FAIL (STOP INSTALLING) IF nodejs_version is not set to 10.x
fail:
msg: "Archorg install cannot proceeed, as it currently requires Node.js 10.x, and your nodejs_version is set to {{ nodejs_version }}. Please check the value of nodejs_version in /opt/iiab/iiab/vars/default_vars.yml and possibly also /etc/iiab/local_vars.yml"
2019-04-04 17:59:05 +00:00
when: distweb_install and (nodejs_version != "10.x")
2019-03-28 19:51:57 +00:00
- name: Clone distributed web mirror supported by Internet Archive
git:
repo: https://github.com/internetarchive/dweb-mirror
2019-04-04 17:59:05 +00:00
dest: "{{ distweb_dir }}"
2019-03-28 19:51:57 +00:00
force: yes
depth: 1
when: internet_available
- name: Install packages needed by Distributed Web
package:
name:
- libsecret-1-dev
- cmake
state: present
- name: Run 'sudo npm install --allow-root --unsafe-perm=true' to create /opt/iiab/distweb/node_modules (CAN TAKE ~5 MINUTES)
command: sudo npm install --allow-root --unsafe-perm=true
2019-03-28 19:51:57 +00:00
args:
2019-04-04 17:59:05 +00:00
chdir: "{{ distweb_dir }}"
2019-03-28 19:51:57 +00:00
# CONFIG FILES
2019-04-04 17:59:05 +00:00
- name: "Install from templates: distweb.service (systemd), distweb.conf (Apache)"
2019-03-28 19:51:57 +00:00
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0644
owner: root
group: root
with_items:
2019-04-04 17:59:05 +00:00
- { src: 'distweb.service.j2', dest: '/etc/systemd/system/distweb.service' }
- { src: 'distweb.conf', dest: '/etc/apache2/sites-available/distweb.conf' }
2019-03-28 19:51:57 +00:00
2019-04-04 17:59:05 +00:00
- name: Create symlink distweb.conf from sites-enabled to sites-available, for short URLs http://box/sugar & http://box/distweb (if distweb_enabled)
2019-03-28 19:51:57 +00:00
file:
2019-04-04 17:59:05 +00:00
src: /etc/apache2/sites-available/distweb.conf
path: /etc/apache2/sites-enabled/distweb.conf
2019-03-28 19:51:57 +00:00
state: link
2019-04-04 17:59:05 +00:00
when: distweb_enabled and is_debuntu
2019-03-28 19:51:57 +00:00
2019-04-04 17:59:05 +00:00
- name: Remove symlink /etc/apache2/sites-enabled/distweb.conf (if not distweb_enabled)
2019-03-28 19:51:57 +00:00
file:
2019-04-04 17:59:05 +00:00
path: /etc/apache2/sites-enabled/distweb.conf
2019-03-28 19:51:57 +00:00
state: absent
2019-04-04 17:59:05 +00:00
when: not distweb_enabled and is_debuntu
2019-03-28 19:51:57 +00:00
# RESTART/STOP SYSTEMD SERVICE
# with "systemctl daemon-reload" in case mongodb.service changed, etc
2019-04-04 17:59:05 +00:00
- name: Enable & Restart 'distweb' systemd service (if distweb_enabled)
2019-03-28 19:51:57 +00:00
systemd:
2019-04-04 17:59:05 +00:00
name: distweb
2019-03-28 19:51:57 +00:00
daemon_reload: yes
enabled: yes
state: restarted
2019-04-04 17:59:05 +00:00
when: distweb_enabled
2019-03-28 19:51:57 +00:00
2019-04-04 17:59:05 +00:00
- name: Disable & Stop 'distweb' systemd service (if not distweb_enabled)
2019-03-28 19:51:57 +00:00
systemd:
2019-04-04 17:59:05 +00:00
name: distweb
2019-03-28 19:51:57 +00:00
daemon_reload: yes
enabled: no
state: stopped
2019-04-04 17:59:05 +00:00
when: not distweb_enabled
2019-03-28 19:51:57 +00:00
2019-04-04 17:59:05 +00:00
- name: Restart Apache service ({{ apache_service }}) to enable/disable http://box/distweb (not just http://box:{{ distweb_port }})
2019-03-28 19:51:57 +00:00
systemd:
name: "{{ apache_service }}" # httpd or apache2
state: restarted
2019-04-04 17:59:05 +00:00
when: distweb_enabled
2019-03-28 19:51:57 +00:00
2019-04-04 17:59:05 +00:00
- name: Add 'distweb' variable values to {{ iiab_ini_file }}
2019-03-28 19:51:57 +00:00
ini_file:
path: "{{ iiab_ini_file }}"
2019-04-04 17:59:05 +00:00
section: distweb
2019-03-28 19:51:57 +00:00
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- option: name
value: Archive Org Distributed Web
- option: description
value: '"Dweb-mirror is intended to make the Internet Archive experience and UI available offline."'
2019-04-04 17:59:05 +00:00
- option: distweb_enabled
value: "{{ distweb_enabled }}"