ThePrudents.moodle

Installing Moodle on Ubuntu 14.04 in the BluMix Cloud Using Ansible

Build Status

Introduction

Moodle is a free software platform for managing online courses. Its full name is Modular Object-Oriented Dynamic Learning Environment. Moodle offers various features to create a smooth online learning experience, whether for a few students or many.

With Moodle, you can set up assignments, quizzes, discussions, and much more. Since it is modular, you can extend its features with plugins.

While Moodle usually runs on LAMP (Linux, Apache, MySQL, and PHP), it can also work with other web servers, such as nginx and even on Windows with IIS.

However, Moodle's flexibility can make it challenging for teachers who have their own favorite themes and plugins, making the installation process difficult for users who aren’t tech-savvy.

Luckily, using Ansible, a deployment automation tool, can make your installation process much easier!

Background

Challenges to Address

  • Specify the Moodle components you need.
  • Optionally install MySQL (you can also use an external database).
  • Optionally set up a LAMP stack (this can be for upgrading Moodle).
  • Optionally install any specific Moodle plugins and themes.
  • Install the essential Moodle components.

Let’s go through this step by step.

Describing Required Moodle Components

According to the official installation guide on https://docs.moodle.org/30/en/Step-by-step_Installation_Guide_for_Ubuntu, we need to note the required packages and PHP extensions:

pkg_dependencies:
  - git
  - curl
  - python-dev
  - libmysqlclient-dev
  - graphviz
  - aspell
  - clamav
  - unzip

php_extensions:
  - php5-mysql
  - php5-intl
  - php5-xmlrpc
  - php5-pspell
  - php5-curl
  - php5-gd
  - php5-ldap

We also need to define our database settings, the domain for the Moodle instance, and its preferred location. Don’t forget to check for the latest stable version of Moodle.

moodle_db_type: 'mysqli' # Other options include 'pgsql', 'mariadb', 'mssql', 'sqlsrv', or 'oci'
moodle_db_host: '{{mysql_host}}'
moodle_db_name: 'moodle'
moodle_db_user: 'moodle'
moodle_db_pass: 'moodle'
moodle_app_domain: "moodle.dev"
moodle_app_root: "/opt/moodle"
moodle_app_wwwroot: "{{ moodle_app_root }}/moodle"
moodle_app_datadir: "{{moodle_app_root}}/moodledata"
moodle_app_plugindir: "{{moodle_app_root}}/downloadedplugins"
moodle_git_version: "MOODLE_30_STABLE"
moodle_artifact_baseurl: https://download.moodle.org/download.php/direct/stable30
moodle_archive_version: "moodle-latest-30.tgz"

moodle_user: "{{ansible_user_id}}"
moodle_admin_user: "6NHkm*S!^W4w"

You can install Moodle from a git repository or by downloading it. Using git is typically easier to maintain:

option_install_moodle: git

Optional MySQL Installation

Even though Moodle works with multiple databases, MySQL is the most common on Unix systems. To install MySQL, you only need to enter your desired root credentials:

mysql_host: "127.0.0.1"
mysql_root_user: root
mysql_root_password: SOMEROOTSECUREPASSWORD

Moodle has specific MySQL configuration preferences, which you can set through a custom my.cnf template.

Optional LAMP Installation

For the LAMP stack, we can install Apache in either worker or prefork mode, influencing how PHP will be installed:

apache_mode: worker # Options are prefork or worker
apache2_disable_default: true

php_family: default # Options can be 5.4, 5.5, 5.6, or default

You can find more details on how to install Apache and PHP by checking the respective recipes in the provided links.

Optional Custom Moodle Plugins and Themes

Most plugins and themes are added by unzipping them into the correct folders. You just need to tell us which plugins you want:

moodle_plugins:
  - {
    name: auth_googleoauth2,
    desc: "Authentication: Google, Facebook, Github, etc.",
    url: "https://moodle.org/plugins/download.php/9695/auth_googleoauth2_moodle30_2015110600.zip",
    dest: auth
    }
  - {
    name: mod_checklist,
    desc: "Activities: Checklist",
    url: "https://moodle.org/plugins/download.php/9703/mod_checklist_moodle30_2015110800.zip",
    dest: mod
    }

Installing Moodle Core Components

In this step, we set up Moodle's directories, configure the database, and set up the Apache site for this Moodle instance. For more details, check the GitHub link provided.

Running the Code

To start the provisioning process, you will need Ansible and a tool called Prudentia. Both are written in Python. To install:

sudo apt-get install git
sudo apt-get install python-pip
pip install -U pip
pip install -U ansible==1.9.4
pip install prudentia

To use the Moodle role, the syntax is:

roles:
   - {
       role: "pr-moodle",
       moodle_db_host: '127.0.0.1',
       moodle_db_name: 'moodle',
       moodle_db_user: 'moodle',
       moodle_db_pass: 'yoursupersecurepassword',
       moodle_app_domain: "yourdomainname.com"
     }

Provisioning the Box

To execute the provisioning, you will set some static parameters:

WORKSPACE=./
BOX_PLAYBOOK=$WORKSPACE/boxes/prod.yml
BOX_NAME=moodle_staging
BOX_ADDRESS=192.168.0.17
BOX_USER=youruser
BOX_PWD=yourpass

prudentia ssh <<EOF
unregister $BOX_NAME

register
$BOX_PLAYBOOK
$BOX_NAME
$BOX_ADDRESS
$BOX_USER
$BOX_PWD

provision $BOX_NAME
EOF

Running on BluMix

IBM Bluemix is a cloud platform developed by IBM that supports several programming languages and services. Let’s choose the Ubuntu 14.04.3 LTS image.

You will need to assign a public IP address to your instance and wait for it to initialize.

Don’t forget to set up DNS once you have your public IP address.

Now you can execute the provisioning. After running, you should see a successful log from the Ansible provisioner.

After about five minutes, Moodle will be ready for configuration. When you go to the site, you will see Moodle’s initial welcome screen, indicating that everything is set up properly.

Possible Improvements

In an ideal situation, the installation process could be made completely non-interactive. Moodle seems to allow this, but the current documentation does not provide a straightforward way to do it.

Suggestions from readers on this topic are very welcome!

Informazioni sul progetto

zero dependency role to install Moodle on debian system

Installa
ansible-galaxy install ThePrudents.moodle
Licenza
Unknown
Download
70
Proprietario
StarterSquad team