automation featured image

How to Automate Canvas LMS Installation with Ansible

In the article How to install Canvas LMS on Ubuntu 22.04 I provided steps to install the open source Canvas learning management system from Github repository onto your own server. But who wants to type all those commands into the terminal manually? And what does differ us from monkeys after all? Using tools for automation does!

Script below automates Canvas LMS deployment on Ubuntu 22.04 using Ansible configuration management tool.

Before you begin installation check out our Canvas LMS hosting service. You can start using the LMS right away without need to manage own servers.

How to use Ansible to Automate Canvas LMS installation

Prepare the server

Get started by installing Ansible and Git on your server.

$ sudo apt install ansible git

Clone the repository with Canvas LMS installation script

Clone canvaslms ansible installation repository from Github.

$ git clone 
$ cd canvaslms-ansible-installation

Create Inventory for Ansible

Create an Ansible inventory file from the file “production.example” and replace web_server_ip, db_server_ip, redis_server_ip with IP addresses or hostnames of your servers.

$ cp production.example production
$ vim production

If you are installing on the localhost you can put something like this in the inventory file:

localhost:22 ansible_connection=local ansible_python_interpreter="/usr/bin/env python3"

localhost:22 ansible_connection=local ansible_python_interpreter="/usr/bin/env python3"

localhost:22 ansible_connection=local ansible_python_interpreter="/usr/bin/env python3"

Modify variables

Next copy and edit the variables file:

$ cp roles/common/vars/main.yml.example roles/common/vars/main.yml
$ vim roles/common/vars/main.yml

The variables file is self explanatory, but here is an example in case you still have doubts.

variables file for ansible playbook
Variables file for Ansible playbook

Run Ansible playbook to install the open source Canvas LMS system

When you are done with inventory and variables you can finally run the playbook which does all the job installing Canvas LMS on your server. Some of the tasks in the playbook, such as yarn installation and canvas compile assets task take decent time to complete, so take a 10-15 minutes break from the computer and allow Ansible to do the job.

$ ansible-playbook -i production master.yml

If the Ansible playbook fails on some step then you need to troubleshoot the issue and re-start playbook from the failed task using ‘–start-at-task=”task name”‘ runtime variable. For example:

$ ansible-playbook -i production --start-at-task="install yarn" master.yml

Instead of running complete installation you can install only web server, database server or redis server components individually by running webservers.yml, dbservers.yml or redis.yml playbooks.

$ ansible-playbook -i production webservers.yml
$ ansible-playbook -i production dbservers.yml
$ ansible-playbook -i production redis.yml

Summary: automation makes life easier!

Manual installation of the open source Canvas LMS system is time consuming and prone to errors. Utilize automation tools like bash scripts, Python and Ansible to free yourself from typing commands into terminal over and over!

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.