geoffreyvanwyk.moodle
Ansible Role for Moodle
This role sets up, installs, and updates Moodle on Ubuntu servers.
It also allows you to add plugins to Moodle from Git.
Requirements
- Any required software or tools that aren't part of Ansible or this role should be listed here. For example, if the role uses the EC2 module, you should mention that the boto package is required.
- This role is tested only on long-term support versions of Ubuntu that still get standard support.
- Currently, it only uses the Apache web server, which it will install automatically.
Role Variables
You can set various options for this role, including those in defaults/main.yml
, vars/main.yml
, and others you can specify when running the role.
Deployment of Source Code
moodle_deploy_repository: https://github.com/moodle/moodle # Public repository
moodle_deploy_version: MOODLE_403_STABLE # Branch, tag, or commit
moodle_deploy_update: yes # Get new commits or not
moodle_deploy_destination: /var/www/html/moodle # The web document root
The Moodle source code can only be deployed from a public repository via HTTPS. For stable versions, specify the appropriate Git branch. If there are new commits available, moodle_deploy_update
will decide if the Moodle instance should be updated. The moodle_deploy_destination
is also where the web server will serve Moodle from.
PHP
php_version: 8.1
The PHP version is set automatically based on the moodle_version
.
Database Setup
moodle_db_install: yes # Should a database service be installed?
moodle_cfg_dbtype: pgsql # Database type: pgsql or mariadb
moodle_cfg_dbname: moodle # Database name
moodle_cfg_dbuser: moodler # Database user
moodle_cfg_dbpass: ***** # Randomly created password
If the database service is installed, the specified user will have full control over the database. If you don't specify a password, a random one will be generated.
Web Hosting
moodle_web_service: apache2 # Can be apache2 or nginx, but only apache is currently supported
moodle_web_root: subdirectory # Where Moodle is hosted
moodle_web_protected_directories: ... # Check defaults/main.yml for defaults
moodle_web_protected_files: ... # Check defaults/main.yml for defaults
moodle_web_protocol: http # 'https' or 'http'
moodle_web_domain: 127.0.0.1 # Domain name of the web service
moodle_web_path: moodle # Subdirectory based on virtual host
The moodle_web_root
variable indicates if Moodle is served from a subdirectory of an existing virtual host or if a new virtual host is needed.
Installation & Server Configuration
moodle_cfg_wwwroot: ... # Based on web protocol, domain, and path
moodle_cfg_dataroot: ... # Based on web domain and path
moodle_site_fullname: Modular Object-Orientated Dynamic Learning Environment
moodle_site_shortname: Moodle
moodle_site_summary: >
Moodle is the most customizable and trusted eLearning solution, empowering educators to improve the world.
moodle_admin_username: moodler
moodle_admin_password: N3verstople@rning
moodle_admin_email: [email protected]
moodle_support_email: "{{ moodle_admin_email }}"
Plugins
moodle_plugins_git: []
A list of plugins to install from a Git repository, as they are not in the official plugins directory. For each plugin, you need to provide:
- The plugin's name (like mod_questionnaire, block_xp).
- The URL to the repository.
- The version reference (branch, tag, or commit).
Plugins not listed will be removed.
Dependencies
A list of other roles that this role depends on can be found in requirements.yml
.
Example Playbook
Here’s an example of how to use this role:
- hosts: servers
roles:
- role: geoffreyvanwyk.moodle
moodle_plugins_git:
- name: theme_learningsandboxonline
repository: https://github.com/geoffreyvanwyk/moodle-theme_learningsandboxonline
version: MOODLE_403_STABLE
License
Copyright © 2023 Geoffrey Bernardo van Wyk https://geoffreyvanwyk.dev
This role falls under the GNU General Public License, allowing you to share and modify it freely. However, it comes with no warranty.
Author Information
This role was created by Geoffrey Bernardo van Wyk in 2023.
Deploys, installs, and upgrades Moodle.
ansible-galaxy install geoffreyvanwyk.moodle