1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 03:32:12 +00:00
iiab/roles/internetarchive/tasks/install.yml
2024-05-03 08:50:27 -04:00

91 lines
3 KiB
YAML

# 1. INSTALL 3 PREREQS
- 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: Assert that 10.x <= nodejs_version ({{ nodejs_version }}) <= 22.x
assert:
that: nodejs_version is version('10.x', '>=') and nodejs_version is version('22.x', '<=')
fail_msg: "Internet Archive install cannot proceed, as it currently requires Node.js 10.x - 22.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"
quiet: yes
- name: "Set 'yarn_install: True' and 'yarn_enabled: True'"
set_fact:
yarn_install: True
yarn_enabled: True
- name: YARN - run 'yarn' role (attempt to install & enable Yarn package manager)
include_role:
name: yarn
- name: Install package 'libsecret-1-dev'
package:
name: libsecret-1-dev
state: present
- name: Record (initial) disk space used
shell: df -B1 --output=used / | tail -1
register: df1
# 2. CREATE 2 DIRS, WIPE /opt/iiab/internetarchive/node_modules & RUN YARN
- name: mkdir {{ internetarchive_dir }}
file:
state: directory
path: "{{ internetarchive_dir }}" # /opt/iiab/internetarchive
- name: Wipe dir {{ internetarchive_dir }}/node_modules (can be ~126+ MB) so './runrole --reinstall internetarchive' gets you the latest code
file:
state: absent
path: "{{ internetarchive_dir }}/node_modules"
- name: Run 'yarn add https://github.com/internetarchive/dweb-mirror' to download/populate {{ internetarchive_dir }}/node_modules (CAN TAKE ~5 MINUTES)
shell: yarn config set child-concurrency 1 && yarn add https://github.com/internetarchive/dweb-mirror
args:
chdir: "{{ internetarchive_dir }}"
creates: "{{ internetarchive_dir }}/node_modules/@internetarchive/dweb-mirror/internetarchive"
- name: mkdir {{ content_base }}/archiveorg
file:
state: directory
path: "{{ content_base }}/archiveorg" # /library
# 3. CONFIG FILES
- name: "Install from template: /etc/systemd/system/internetarchive.service"
template:
src: internetarchive.service.j2
dest: /etc/systemd/system/internetarchive.service
# 4. RECORD Internet Archive AS INSTALLED
- name: Record (final) disk space used
shell: df -B1 --output=used / | tail -1
register: df2
- name: Add 'internetarchive_disk_usage = {{ df2.stdout|int - df1.stdout|int }}' to {{ iiab_ini_file }}
ini_file:
path: "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
section: internetarchive
option: internetarchive_disk_usage
value: "{{ df2.stdout|int - df1.stdout|int }}"
- name: "Set 'internetarchive_installed: True'"
set_fact:
internetarchive_installed: True
- name: "Add 'internetarchive_installed: True' to {{ iiab_state_file }}"
lineinfile:
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
regexp: '^internetarchive_installed'
line: 'internetarchive_installed: True'