call_learning.moodle
Ansible Role: Moodle
This role installs Moodle (version 4.1 and above) on RedHat and Debian/Ubuntu servers. It has been tested with Ansible version 6.0.
Requirements
You need a recent long-term support (LTS) version of Ubuntu or RedHat that has PHP version 8.0 or higher, Apache 2.4, and either Postgres or MySQL installed.
Role Variables
You can find available variables and their default values in the defaults/main.yml
file.
Dependencies
No extra software is needed if your server is already set up with a LAMP (Linux, Apache, MySQL, PHP) stack. If you need to install the entire environment, consider using:
- geerlingguy.php: for installing PHP 8.x or earlier.
- geerlingguy.apache: for installing Apache 2.x.
- geerlingguy.postgresql: for installing Postgres.
- geerlingguy.mysql: for installing MySQL.
Example Playbook
License
MIT / BSD
Author Information
This role was created in 2017 by Laurent David, based on templates from Jeff Geerling, who is the author of Ansible for DevOps.
Testing
Prerequisites
You must have Ansible installed.
We use testing methods from Jeff Geerling as a foundation, which heavily relies on Molecule. We are now using GitHub Actions to run tests with every commit (you can find them in the .github/workflow
folder):
lint.yml
checks the project for syntax errors.molecule.yml
runs each test scenario to ensure the Ansible playbook is valid.
Note: Since installing Postgres and MySQL can take some time using the original Jeff Geerling image, we prebuild these images every month using Packer. You can find this process in the molecule-images
folder, which you can ignore if you're just looking for information about the role.
- After launching Docker, you can rerun the playbook by executing:
container_id=xxxxyyy
docker exec --tty $container_id env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
To test a specific playbook, such as the check_moodle.py
part:
container_id=xxxxyyy
docker exec $container_id env TERM=xterm env ANSIBLE_FORCE_COLOR=1 ansible-playbook -i 'localhost,' -M /etc/ansible/roles/role_under_test/library /etc/ansible/roles/role_under_test/tests/test-check-moodle.yml
Library Testing
There is a small module in the library folder that checks if Moodle is installed and configured. More information can be found in the README.md of the library folder.
#TODO
- Tag tasks:
- Pure setup without running Moodle installation (just folders and source code).
- Installation with Moodle setup.
- Optional tasks like changing passwords, updates, or dumping the database.
ansible-galaxy install call_learning.moodle