Skip to content

Commit

Permalink
Merge pull request DEAN-ngo#95 from DEAN-ngo/ansible
Browse files Browse the repository at this point in the history
Ansible
  • Loading branch information
ltoning authored Oct 7, 2022
2 parents 033ee5e + 6c58f7d commit afac66b
Show file tree
Hide file tree
Showing 108 changed files with 3,356 additions and 1,254 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
images
output*
pishrink.sh
.DS_Store
ansible/roles/common/files/ElimuPi-Web-Interface
ansible/inventory.yml
1,156 changes: 0 additions & 1,156 deletions ElimuPi_installer.py

This file was deleted.

122 changes: 77 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,105 @@
# elimupi2.0.1
## ElimuPi

The purpose of this project is to provide a DEAN digital classroom environment for educational project in Tanzania and Kenia. This includes providing full Android tablet support without any direct internet connectivity.
The purpose of this project is to provide a DEAN digital classroom environment for educational project in Tanzania and Kenya. This includes providing full Android tablet support without any direct internet connectivity.

Please visit https://www.dean.ngo/ict4e/digital-classroom-box-elimupi/ for more information
Please visit https://www.dean.ngo/solutions/elimupi/ for more information.

## Introduction

This version of the ElimuPi build supports:

- FDROID Android application store
- Web pages for management of the sytem and content management (WordPress)
- WiKiPedia alike functions (KiWix)
- Kolibri learning system
- Dynamic content addition through USB storage
- Secured WiFi access point
- Local DHCP, DNS

## Installation
1. Install a base RaspBian image on a SD card and create a empty file called 'ssh' in the root of the boot partition. This will enable SSH access to the Raspberry Pi. After you finished previous steps insert the SD card into the Raspberry Pi
This version of the ElimuPi build supports:

- [F-Droid](https://f-droid.org/) an Android application store.
- Web pages for management of the system and content management (WordPress).
- WiKiPedia alike functions based on [Kiwix](https://www.kiwix.org/en/about/).
- [Kolibri](https://learningequality.org/kolibri/) learning system.
- Dynamic content addition through USB storage.
- Secured WiFi Access Point.
- Local DHCP, DNS.

# Installation

## Prerequisites:
- PC or laptop with Linux, Windows with [WSL](https://ubuntu.com/wsl) or MacOS operating system installed.
- A Raspberry Pi model 4 with a wired TCP connection to LAN.
- A Micro SD-card class 10 > 8GB
- Git installed.
- Ansible 2.10 > installed.
- [ssh_askpass](https://packages.ubuntu.com/search?keywords=ssh-askpass) installed.
- [Raspberry Pi Imager](https://www.raspberrypi.com/software/) installed.
- [Raspberry Pi OS Lite 64 bits image , Release date: September 6th 2022.](https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2022-09-07/2022-09-06-raspios-bullseye-arm64-lite.img.xz)
- Ansible vault password ( contact DEAN development)

## Install Raspberry Pi OS

2. Connect the external Hard Drive to the Raspberry Pi
- Use Raspberry PI Imager to write the downloaded image to the SD-card using instructions at https://www.raspberrypi.com/documentation/computers/getting-started.html#installing-the-operating-system.
- Insert the SD-card.
- Start Raspberry PI Imager.
- Under **Operating system** select **Choose OS --> Use Custom** and select the downloaded image - [Raspberry Pi OS Lite 64 bits image , Release date: September 6th 2022.](https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2022-09-07/2022-09-06-raspios-bullseye-arm64-lite.img.xz)
- Under **Storage** and select the SD-card device.
- Select **Advanced options** --> **Enable SSH** --> **Use password authentication**.
- Set **Username** to: **pi** and **Password** to : **elimupi** and select **SAVE**.
- Select **WRITE**.

When the image has been successfully written insert the SD-card into the Raspberry Pi and boot the device connected to local LAN.

3. Powerup the RaspberryPi and wait for the initial boot process to complete
## Build ElimuPi Image

4. Connect with the Raspberry pi using SSH (`ssh pi@<ipv4>`; default password: raspberry)

5. Expand your microSD card partition by running `sudo raspi-config`, choose Advanced Options and there choose Expand Filesystem. Exit the menu (press the escape key a few times) and restart the Raspberry Pi: `sudo reboot`
Provision the ElimuPi software by running the ansible-play book against local Raspberry Pi and build Elimupi the image.

6. Type/Paste in the following command after reboot.
- Find the Pi's assigned IP address on your local LAN. ( via Wifi router or a nmap).
- Git clone this repo and cd elimupi/ansible directory of this repo.
- Adjust the current IP adresss of key : ansible_host in file inventory.yml to your Pi's local assigned IP address.
- Increment version release number variable, **elimupi_release**: in file ansible/group_vars/all/vars.yml if needed.
- Install Ansible collections:

`wget https://raw.githubusercontent.com/DEANpeterV/elimupi2.0/master/ElimuPi_installer.py && chmod 700 ElimuPi_installer.py && python3 ElimuPi_installer.py`
`ansible-galaxy collection install -r collections.yml`

*Please note that this will change the 'pi' user's password to: elimupi
- Install Ansible roles.

7. After the reboot, connect to the Raspberry Pi through SSH again and continue the installation by running `python3 ElimuPi_installer.py` again.
`ansible-galaxy install -r roles.yml`

8. After another reboot, the Raspberry Pi is ready for use!
- Run playbook

All default username and passwords will be pi/elimupi unless noted differently.
`ansible-playbook -i ./inventory.yml playbook-raspberrypi.yml --ask-vault-pass`

The default password for the WiFi 'elimu' is : 1234567890
The installation will take approximately 20 minutes to finish and there shouldn't be any errors.

## User access
The end users can access the available resources after they are connected to the Wifi network.
## Create ElimuPi image copy

The following links are provided to access the resources:
- Create a image copy of the SD-card with the ElimuPi software installed using instructions at https://beebom.com/how-clone-raspberry-pi-sd-card-windows-linux-macos/
- Shrink cloned the image file ( Linux Only) using [PiShrink](https://github.com/Drewsif/PiShrink).
- gzip the shrinked image file.
- Name the image: **ElimuPi_Image_2022-09-06-raspios-bullseye-arm64_lite_Release_<-Version->.img.gz** e.g

- **Main interface** - www.elimupi.online
- **Kolibri** - kolibri.elimupi.online
- **Kiwix** - wiki.elimupi.online
- **files** - files.elimupi.online
- **Moodle** - moodle.elimupi.online
This should produce a 2.8GB gzipped compressed Elimupi image file.

After you finished the installation you need to visit khan.elimupi.online and create an Admin account.
The image file can than be directly written to other SD-cards using Raspberry Pi Imager selecting the image with Use Custom Operation System option.

Then you need to login with the Admin account and go to Manage --> "Please follow the directions to register your device, so that it can synchronize with the central server."
# Connecting to Elimupi

- Disconnect the Raspberry PI's TCP wired connection.
- Connect your device via WiFi to SSID: **elimu** using passcode: **1234567890**
- Point your browser to http://start.elimupi.online

## Notes
**NOTE1**: This install is tested to work with Raspbian OS #1414 SMP Fri Apr 30 13:20:47 BST 2021
## Default users
All default username and passwords will be **pi/elimupi** unless noted differently.

**NOTE2**: for WIFI to work on the RaspberryPi 2 unit, you must have the WIFI USB dongle inserted during installation so that the install script can configure it properly. RaspberryPi 3 models have on board WiFi and don't need a WIFI USB dongle.
The default password for the Wifi AP with SSID: 'elimu' is : 1234567890

**NOTE3**: If using PUTTY set the setting 'window'->'translation'->'Remote Character Set' to 'use font encoding' to display the lines correctly.
## User access
The end users can access the available resources after they are connected to the Wifi network.

**NOTE4**: For Kolibri content use Kolibri Studio - https://studio.learningequality.org
The following links are provided to access the resources:

Last updated : 2021/08/09
- **Main interface** - [start.elimupi.online](http://start.elimupi.online)
- **Kolibri** - [kolibri.elimupi.online](http://kolibri.elimupi.online)
- **Kiwix** - [wiki.elimupi.online](http://wiki.elimupi.online)
- **Fdroid** - [fdroid.elimupi.online](http://fdroid.elimupi.online)
- **Files** - [files.elimupi.online](http://files.elimupi.online)
- **Moodle** - [moodle.elimupi.online](http://moodle.elimupi.online)
- **Admin** - [admin.elimupi.online](http://admin.elimupi.online)

Applicable Licenses: See licenses file.
After you finished the installation you need to visit [admin.elimupi.online](http://admin.elimupi.online) login with the Admin account and go to Manage --> "Please follow the directions to register your device, so that it can synchronize with the central server."

Original source : https://github.com/rachelproject/rachelpios
## Notes
**NOTE1**: This install is tested to work with [Raspberry Pi OS Lite 64 bits image , Release date: September 6th 2022.](https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2022-09-07/2022-09-06-raspios-bullseye-arm64-lite.img.xz) on a Raspberry Pi model 4.
3 changes: 3 additions & 0 deletions ansible/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

log/*
!log/.gitkeep
16 changes: 16 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[defaults]
inventory = hosts
host_key_checking = False
log_path = log/ansible.log
timeout = 30
pipelining = True
#ask_vault_pass = True
# Not using date because that would trigger an update of te files with every run.
ansible_managed = Ansible managed - Last modified by {uid} - From {host}
interpreter_python = /usr/bin/python3

[privilege_escalation]
become = True
#become_ask_pass = True
#ssh_args = -F /dev/null -o PreferredAuthentications=password -o PasswordAuthentication=yes
ssh_args = -o ControlMaster=auto -o ControlPersist=30m
5 changes: 5 additions & 0 deletions ansible/collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
collections:
- name: community.mysql
# - name: ansible.posix
# - name: community.general
50 changes: 50 additions & 0 deletions ansible/group_vars/all/secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
$ANSIBLE_VAULT;1.1;AES256
33663533383563383536353663623437333366326439373639303564326265376333303837356531
3039646634643330323434643634633434313537643866630a353061386565323965366162306639
62653664616261313762396663653839343165306338383231343236366466373734353964643862
6237356333623932350a643031383932323836306633666435313532653436363264656333653037
63373038393764393334663566383965356335353965383964636562396663323639633564663565
34623834376535656633313838666139346462373435613539353966633130386539333466653931
38353733663461326534323433336361613463353631646132396632653162666538323331316361
36656637636430303732313962323739623931656365633536313433326365356137313062386166
66623639323465623634303835366231646631336639386666343033313831663364616433653864
36376362366532396561356162626532333963386134366162373633366362373861356537626336
64303562326231353033386662386435663035663132333062626332366130363466393339316632
62386635613836646332393137396632343530306336353466333032646164643736623962626532
31663039633739643035626432396532383232383536366664303134623732666437393932396237
61666532343264346263623562303966623031613537323032366536363263613263316237326638
64616264313433336132656131356634656339376265616134626637376363373835363266656438
36363965646264373033633430613432373366343136386565646335623266353930303162303534
35343733336461383134333964323235613162303835336464353461333030633263353461653163
33366535613833326664343632643139653532633433313439306633336433643635613730353865
34333362363434346362653032313535323562666430363665323563633265333962356136313536
39643866346365346165393532316630383335373836316465366364343036333239393363373866
38376238306431633563643039313432633039656334656333383138356432633734636261386137
64623662656535383161623362633830636430393564313561316330326162303530393631386661
36396431383139666666633366636632356538336632306561396538633965623365343338306565
34303364396534383663366537383263663538636265383130656435626265343966353138313531
65376536663662643836633032633731363337656136333835323634353533643538646165653436
35633861396232393438396137383065383266636166313632626430396438343166353533326432
37306339663364646334613731383362323835633363383035353431323530663931363164343636
38626438633637646437353035376136333362376537316537646234373739313865396531366562
64353662366432363033373937623466626363386662366438326633643665663732353132333133
31396535393734653462333136613732326464623536323830366334346337336130393538643836
61323464396566313033643637616539643965363764343533353365363236313531303934306234
38333534363965363362623739666238663335323662393037316239633638336165376335623764
33303562306231303632373232343938326464326236343662366464643036666161636334396138
65663237343838336264623161626132633063666233616430333037383066393837623236303766
37666333666665393663316435346239373932636232396364326334376463366465633632653165
65316666633031383463306461623963323837303133626562333930373964356431613361373432
36656330653630333461373162336134313537313539313837613930323631643364633766653431
34303731356166363662663063336134376137323435613238353536353362663761656166363865
62393633636536633630643933666465356465656232306134343639613937303331353930326431
30643866633735393937626465646537623465363261623762636635666664363933383935333863
65623734613461323538623837633366613536626134306533636164313866663734623037323563
62613464313462623464313266613734653036653038333662313362363864633632373331346331
63396562363164383762653664643533336264646531626265643133343237316162616463386234
62623036366562633835623031326133653436643536353163663536653630386361343263346135
37323433353039663938346666363232383462333738396436376262376232626662633736656164
35353638326666326561386430336433613939613336643331393435356136663437353538353763
62313563653230306537613537353561633736303463363239343061346363336661316439396632
33303636616266656630633466626265376163636363303934653131373261303638643039343233
37366431336434366632326431353165393061633865663234313262626361343865
102 changes: 102 additions & 0 deletions ansible/group_vars/all/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
# Elimupi release version
elimupi_release: 3.0.0

elimupi_release_file: "/root/elimupi_release-{{ elimupi_release }}-{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}"


# Kiwix
#
# A path where to save the data.
kiwix_data_directory: /mnt/content/wiki
kiwix_directory_mode: "0755"

kiwix_version: kiwix-tools_linux-armhf-3.2.0-1
vikidia_version: vikidia_en_all_nopic_2021-03
wiktionary_version: wiktionary_en_simple_all_nopic_2022-07

ansible_host_key_checking: false

# Moodle DB
mysql_root_password:

mysql_enabled_on_startup: true

mysql_databases:
- name: moodle
collation: utf8mb4_unicode_ci
encoding: utf8mb4
replicate: 1

mysql_users:
- name: elimu
host: "localhost"
password: elimu
priv: "moodle.*:SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER"

mysql_packages:
- mariadb-client
- mariadb-server
- python3-mysqldb

# Moodle config

# The version of moodle to install.
moodle_version: 310

# A path where to save the data.
moodle_data_directory: /mnt/content/moodledata

# The permissions of the created directories.
moodle_directory_mode: "0750"

# Details to connect to the database.
moodle_database_type: mariadb
moodle_database_hostname: localhost
moodle_database_name: moodle
moodle_database_username: elimu
moodle_database_password: elimu
moodle_database_prefix: ""

moodle_httpd_data_directory: /var
moodle_httpd_owner: www-data
moodle_httpd_group: www-data

# The URL where to serve content.
moodle_wwwroot: "http://moodle.elimupi.online"

# Kolibri config
# The databases and storage

kolibri_install: True
kolibri_enabled: True

# Kolibri folder to store its data and configuration files.
#kolibri_home: "{{ content_base }}/kolibri"
kolibri_home: "/mnt/content/kolibri-home"

kolibri_http_port: 8080
kolibri_url: /kolibri/
kolibri_path: "{{ iiab_base }}/kolibri"
kolibri_exec_path: /usr/bin/kolibri

# Kolibri system user
#kolibri_user: kolibri
kolibri_user: pi

# Kolibri setup will be provisioned with default administration account, preset and
# language. You could turn this to 'False' while reinstalling kolibri.
kolibri_provision: False

# Kolibri Facility name
kolibri_facility: 'DEAN - Elimupi'

# Kolibri Preset type: formal, nonformal, informal
kolibri_preset: 'formal'

# Kolibri default language (ar,bn-bd,en,es-es,fa,fr-fr,hi-in,mr,nyn,pt-br,sw-tz,ta,te,ur-pk,yo,zu)
kolibri_language: 'en'

# Kolibri admin account
kolibri_admin_user: 'admin'
kolibri_admin_password: ''
12 changes: 12 additions & 0 deletions ansible/inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
all:
hosts:
raspberrypi:
ansible_user: pi
ansible_ssh_pass: elimupi
ansible_host: 192.168.2.40
#ansible_host: 192.168.1.54
dockerpi:
ansible_host: 127.0.0.1
ansible_port: 5022
ansible_user: pi
Empty file added ansible/log/.gitkeep
Empty file.
8 changes: 8 additions & 0 deletions ansible/playbook-dockerpi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: 'Provision Image'
hosts: dockerpi
become: true

vars:
roles:
- common
8 changes: 8 additions & 0 deletions ansible/playbook-raspberrypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: 'Provision Image'
hosts: raspberrypi
become: yes

vars:
roles:
- common
1 change: 1 addition & 0 deletions ansible/roles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- src: geerlingguy.mysql
2 changes: 2 additions & 0 deletions ansible/roles/common/.galaxy_install_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
install_date: Wed Mar 17 16:07:06 2021
version: develop
File renamed without changes.
5 changes: 5 additions & 0 deletions ansible/roles/common/files/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Only for local access
127.0.0.1 elimupi.online localhost elimupi

# Remote access/shared
10.11.0.1 start.elimupi.online local.elimupi.online kolibri.elimupi.online fdroid.elimupi.online moodle.elimupi.online files.elimupi.online wiki.elimupi.online admin.elimupi.online
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit afac66b

Please sign in to comment.