Forge Home


Manages the Moodle Learning Management System




6,505 latest version

4.3 quality score

Version information

  • 0.1.7 (latest)
  • 0.1.6
  • 0.1.5
  • 0.1.4
  • 0.1.3
  • 0.1.1
  • 0.1.0
released Apr 7th 2016
This version is compatible with:
  • Puppet Enterprise >= 3.0.0 < 2015.4.0
  • Puppet >= 3.0.0 < 5.0.0
  • Debian

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this declaration to your Puppetfile:

mod 'alanpetersen-moodle', '0.1.7'
Learn more about managing modules with a Puppetfile

Add this module to a Bolt project:

bolt module add alanpetersen-moodle
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install alanpetersen-moodle --version 0.1.7

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.



alanpetersen/moodle — version 0.1.7 Apr 7th 2016


Table of Contents

  1. Overview
  2. Requirements
  3. Usage
  4. Example Usage
  5. Limitations
  6. Links


This module installs and configures a Moodle instance.


This module have some external dependencies:

  • PHP 5.4 or higher -- this is a Moodle 3.x requirement. Installing on Ubuntu 14.04 will have this dependency
  • Apache Webserver
  • MySQL Database


To manage a Moodle instance, use the moodle class.

    class { 'moodle':

Available parameters are:

  • install_dir - directory where the Moodle distribution will be extracted. Since Moodle distributions contain the moodle root folder, this directory should end with /moodle. For example /opt/www/moodle. The parent directory must already exist on the node.
  • download_base - the base URL for downloading the Moodle distribution. Defaults to
  • moodle_version - the version of Moodle to download. Defaults to 3.0.1.
  • default_lang - The default language setting for Moodle. Defaults to en.
  • wwwrooturl - The root URL for the Moodle web site. Defaults to http://$::fqdn.
  • www_owner - The OS user that will own the Moodle base directories (web and data).
  • www_group - The OS group that will own the Moodle base directories (web and data).
  • dataroot - The Moodle data directory. Defaults to /opt/moodledata.
  • create_db - A boolean indicating whether or not the module should manage the database. Defaults to true.
  • create_db_user - A boolean indicating whether or not the module should manage the database user. Defaults to true.
  • dbtype - The database type to use. Currently, only MySQL databases are supported, so mysqli is the default (and only supported) value. This will change once PostgreSQL support is added.
  • dbhost - Hostname for the database server. Defaults to localhost.
  • dbname - The database name for the Moodle data. Defaults to moodle.
  • dbuser - The database username. Defaults to root.
  • dbpass - The database password. Defaults to empty string.
  • dbport - The TCP/IP port for the database server. Defaults to 3306 (the MySQL default)
  • dbsocket -
  • prefix - Table prefix for Moodle-related tables. Defaults to mdl_.
  • fullname - The full name for the Moodle site.
  • shortname - The short name for the Moodle site.
  • summary - A summary description for the Moodle site.
  • adminuser - The Moodle administrative user. Defaults to admin.
  • adminpass - The Moodle administrator's password. Defaults to adminpass.
  • adminemail - The Moodle administrator's email address. Defaults to

Example Usage

Note: this module only manages moodle. It does not manage the underlying database server or web server.

For example, to install moodle into /opt/moodle and use Apache and MySQL, you could create a profile such as:

$install_dir = '/opt/moodle'
class { 'apache':
  mpm_module => 'prefork',
class { 'apache::mod::php': }
class { 'mysql::server': }
class { 'mysql::bindings': php_enable => true, }
apache::vhost { $::fqdn:
  docroot        => $install_dir,
  manage_docroot => false,
  port           => '80',
class { 'moodle':
  install_dir => $install_dir,
  dbtype      => $dbtype,
  dbuser      => 'moodleuser',
  dbpass      => 'moodleP@ss',
  fullname    => 'Test Moodle Site',
  shortname   => 'Test',
  summary     => 'A moodle test site created via beaker',
  adminuser   => 'moodleadmin',
  adminpass   => 'adminP@ss',
  adminemail  => '',
  require     => Class['mysql::server', 'apache::mod::php'],

This example assumes that one is using the puppetlabs/apache and puppetlabs/mysql modules.


Currently only MySQL is supported for a database. PHP 5.4 or higher is also required (a Moodle 3.x requirement).


For Moodle adminstration, please consult the official Moodle documentation:

Moodle Install Guide