1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/sugarizer/tasks/main.yml

165 lines
5.5 KiB
YAML
Raw Normal View History

2018-07-11 23:51:10 +00:00
# 0. CLEAN UP PRIOR VERSIONS OF SUGARIZER (NEEDS WORK!)
- name: Wipe /library/www/html/sugarizer* if installing sugarizer-1.0
shell: "rm -rf {{ doc_root }}/sugarizer*"
when: sugarizer_version == "sugarizer-1.0"
2018-07-11 23:51:10 +00:00
# 1. DOWNLOAD /opt/iiab/sugarizer
2018-07-11 23:51:10 +00:00
- name: Clone llaske/sugarizer ({{ sugarizer_git_version }}) from GitHub to /opt/iiab
git:
repo: https://github.com/llaske/sugarizer
2018-07-12 00:38:19 +00:00
dest: "{{ sugarizer_location }}/{{ sugarizer_version }}"
2018-07-11 23:51:10 +00:00
version: "{{ sugarizer_git_version }}"
2018-07-12 01:27:40 +00:00
force: yes
2018-07-13 01:04:04 +00:00
depth: 1
2018-07-12 00:12:30 +00:00
when: internet_available
2018-07-11 23:51:10 +00:00
- name: Create symbolic link /opt/iiab/sugarizer -> /opt/iiab/{{ sugarizer_version }}
file:
src: "{{ sugarizer_location }}/{{ sugarizer_version }}"
dest: "{{ sugarizer_location }}/sugarizer"
2017-11-20 04:09:54 +00:00
state: link
2017-05-27 18:09:50 +00:00
2018-07-11 23:51:10 +00:00
# 2. DOWNLOAD /opt/iiab/sugarizer-server
2018-07-12 01:27:40 +00:00
# July 2018: http://download.iiab.io/packages/sugarizer-server-1.0.tar.gz
# was flawed, as documented at:
# https://github.com/iiab/iiab/pull/814#issuecomment-404211098
# Versions of MongoDB, npm (& Node.js ?) matter! Sugarizer 1.0 Context:
2018-07-11 23:51:10 +00:00
# https://github.com/iiab/iiab/issues/798
# Going forward let's "git clone" IIAB's preferred versions, of sugarizer
2018-07-12 01:29:49 +00:00
# AND sugarizer-server, as specified in roles/sugarizer/defaults/main.yml
2018-07-11 23:51:10 +00:00
- name: Clone llaske/sugarizer-server ({{ sugarizer_server_git_version }}) from GitHub to /opt/iiab
git:
2018-07-11 23:11:29 +00:00
repo: https://github.com/llaske/sugarizer-server
2018-07-12 00:38:19 +00:00
dest: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
2018-07-11 23:51:10 +00:00
version: "{{ sugarizer_server_git_version }}"
2018-07-12 01:27:40 +00:00
force: yes
2018-07-13 01:04:04 +00:00
depth: 1
2018-07-12 00:12:30 +00:00
when: internet_available
- name: Create symbolic link /opt/iiab/sugarizer-server -> /opt/iiab/{ sugarizer_server_version }}
2018-05-17 22:23:44 +00:00
file:
src: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
dest: "{{ sugarizer_location }}/sugarizer-server"
state: link
2018-07-11 23:51:10 +00:00
# 3. INSTALL A GOOD VERSION OF Node.js AND npm
2018-07-12 01:40:04 +00:00
# Both Raspbian and Debian 9 STILL need this approach as of July 2018,
2018-07-11 23:51:10 +00:00
# as documented at https://github.com/iiab/iiab/issues/798#issuecomment-404324530
- name: Set up Node.js 8.x apt sources (debuntu but avoid ubuntu-18)
shell: curl -sL https://deb.nodesource.com/setup_8.x | bash -
when: internet_available and is_debuntu and not is_ubuntu_18
2018-07-11 23:11:29 +00:00
- name: Install latest Node.js which includes /usr/bin/npm (debuntu but avoid ubuntu-18)
package:
name: nodejs
# name: nodejs=8.x
state: latest
# state: present
when: internet_available and is_debuntu and not is_ubuntu_18
- name: Install Node.js and npm (ubuntu-18)
package:
name: "{{ item }}"
state: latest
when: internet_available and is_ubuntu_18
2017-09-22 07:14:14 +00:00
with_items:
- nodejs
- npm
- name: Install npm (OS's other than debuntu)
package:
name: "{{ item }}"
state: present
when: internet_available and not is_debuntu
with_items:
2018-04-28 20:48:01 +00:00
- nodejs
- npm
2018-07-11 23:51:10 +00:00
# 4. RUN "npm install" TO POPULATE ~35MB /opt/iiab/sugarizer-server/node_modules
2018-07-12 01:40:04 +00:00
# Re-running "npm install" fails on Raspbian 9 if not other OS's
2018-07-12 01:49:03 +00:00
- name: Check for /opt/iiab/{{ sugarizer_server_version }}/node_modules
2017-12-08 06:20:01 +00:00
stat:
2018-05-17 22:23:44 +00:00
path: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules"
2018-07-12 00:25:36 +00:00
register: nmtest
2018-05-17 21:36:50 +00:00
ignore_errors: true
2017-09-04 18:43:00 +00:00
2018-07-12 01:49:03 +00:00
- name: Set a flag to prevent re-running of "npm install"
set_fact:
2018-07-12 00:25:36 +00:00
node_modules_exists: True
when: nmtest.stat is defined and nmtest.stat.exists
2017-09-04 18:43:00 +00:00
2018-07-11 23:51:10 +00:00
- name: Create the express framework for Node.js (OS's other than Fedora 18)
shell: npm install
args:
chdir: "{{ sugarizer_location }}/{{ sugarizer_server_version }}"
creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/node_modules"
#creates: "{{ sugarizer_location }}/{{ sugarizer_server_version }}/server/node_modules"
2018-07-12 00:25:36 +00:00
when: not is_F18 and not node_modules_exists
2018-07-11 23:51:10 +00:00
- name: Create the express framework for Node.js (Fedora 18)
shell: npm install
args:
chdir: "{{ sugarizer_location }}/sugarizer/server"
2018-07-12 00:25:36 +00:00
when: is_F18 and not node_modules_exists
2018-07-11 23:51:10 +00:00
# 5. PLACE CONFIG FILES
- name: Configure sugarizer.service (systemd), sugarizer.conf (Apache) and sugarizer.ini
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
2018-05-22 16:52:31 +00:00
mode: "{{ item.mode }}"
owner: root
group: root
2017-05-27 18:09:50 +00:00
with_items:
- { src: 'sugarizer.service.j2', dest: '/etc/systemd/system/sugarizer.service', mode: '0644' }
- { src: 'sugarizer.ini', dest: '{{ sugarizer_location }}/{{ sugarizer_server_version }}/env/sugarizer.ini', mode: '0644' }
- { src: 'sugarizer.conf', dest: '/etc/apache2/sites-available', mode: '0644' }
2017-05-27 18:09:50 +00:00
2018-07-12 01:40:04 +00:00
- name: Create symlink for short URL http://box/sugarizer
2018-07-11 17:06:37 +00:00
file:
src: /etc/apache2/sites-available/sugarizer.conf
dest: /etc/apache2/sites-enabled/sugarizer.conf
state: link
2017-05-27 18:09:50 +00:00
2018-07-11 23:51:10 +00:00
# 6. RESTART/STOP SYSTEMD SERVICE
2017-05-27 18:09:50 +00:00
- name: Enable services (all OS's)
service:
name: "{{ item.name }}"
enabled: yes
state: restarted
2017-09-22 07:14:14 +00:00
with_items:
2018-07-12 01:03:06 +00:00
- { name: mongodb }
2017-12-08 06:20:01 +00:00
- { name: sugarizer }
2017-09-22 07:14:14 +00:00
when: sugarizer_enabled
2017-05-27 18:09:50 +00:00
- name: Disable service (all OS's)
service:
name: "{{ item.name }}"
enabled: no
state: stopped
2017-09-22 07:14:14 +00:00
with_items:
- { name: sugarizer }
2017-09-22 07:14:14 +00:00
when: not sugarizer_enabled
2017-05-27 18:09:50 +00:00
2017-11-27 01:05:27 +00:00
- name: Add 'sugarizer' to list of services at /etc/iiab/iiab.ini
ini_file:
2017-11-20 04:02:07 +00:00
dest: "{{ service_filelist }}"
section: sugarizer
option: "{{ item.option }}"
value: "{{ item.value }}"
2017-05-27 18:09:50 +00:00
with_items:
2017-12-08 06:20:01 +00:00
- 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: enabled
value: "{{ sugarizer_enabled }}"