Cyberithub

How to Install Mojo on Ubuntu 20.04 LTS (Focal Fossa)

Advertisements

In this article, I will take you through the steps to install Mojo on Ubuntu 20.04 LTS (Focal Fossa). Mojo is a free and open source system of configuration and tools for verifying the success of juju deployments. It takes care of entire deployment process which basically starts from creating an entirely empty environment with no VMs to VMs with the services deployed on them. It allows us to test all the operations that we may want to run on Juju environments such as scaling out, updating charms, updating code or content on running service units, uploading data into your application and so on.

Mojo ensures minimum exposure to critical resources such as SSL secrets and password. At the same time, it also ensures maximum exposure to all other deployment parameters hence providing all round repeatable deployment process. More on official website. It is fairly easy to install on almost all the famous Linux distributions. Here we will see the steps to install Mojo on Ubuntu 20.04 LTS based systems.

 

How to Install Mojo on Ubuntu 20.04 LTS (Focal Fossa)

How to Install Mojo on Ubuntu 20.04 LTS (Focal Fossa)

Also Read: How to Install pg_dump and pg_restore on Ubuntu 20.04 LTS (Focal Fossa)

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS System.

b) You should have sudo or root access to run privileged commands.

c) You should have snap and apt utility available in your system.

d) You should have Juju installed in your System.

 

Step 2: Update Your Server

In the first step, you must think about downloading and installing all the available updates from default Ubuntu repo and then upgrade the packages to the latest version by using sudo apt update && sudo apt upgrade command as shown below.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
Hit:1 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Hit:3 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:6 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:8 https://download.sublimetext.com apt/stable/ InRelease
Get:9 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [59.8 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [275 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [95.3 kB]
Get:13 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [940 B]
Get:14 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [410 kB]
Get:15 http://in.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [944 B]
Get:16 http://in.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [7,972 B]
Get:17 http://in.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.5 kB]
Fetched 1,216 kB in 8s (157 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done

 

Step 3: Install Mojo

Mojo can be installed using two different methods. You can use any of the below method depending on your use case and tools availability.

a) Using Snap

It is quite easy to install Mojo as a snap package from Snap store by using sudo snap install --classic mojo command as shown below. You can also check more information about mojo package before installing it in your system using snap info mojo command.

cyberithub@ubuntu:~$ sudo snap install --classic mojo
[sudo] password for cyberithub:
mojo 1.0.0+580 from Stuart Bishop (stub) installed

b) Using PPA Repo

Before installing Mojo through PPA repo, it is first required to install the dependency package Juju from the PPA repo. To install Juju, you need to first add the Juju stable repo by using sudo add-apt-repository ppa:juju/stable command as shown below.

cyberithub@ubuntu:~$ sudo add-apt-repository ppa:juju/stable
Stable releases of Juju 2.X for ubuntu
More info: https://launchpad.net/~juju/+archive/ubuntu/stable
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:5 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Hit:6 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease
Get:7 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:8 http://ppa.launchpad.net/juju/stable/ubuntu focal InRelease [17.5 kB]
Hit:9 https://download.sublimetext.com apt/stable/ InRelease
Hit:10 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Hit:11 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease
Get:12 http://ppa.launchpad.net/juju/stable/ubuntu focal/main i386 Packages [500 B]
Get:13 http://ppa.launchpad.net/juju/stable/ubuntu focal/main amd64 Packages [792 B]
Get:14 http://ppa.launchpad.net/juju/stable/ubuntu focal/main Translation-en [552 B]
Fetched 242 kB in 6s (41.9 kB/s)
Reading package lists... Done

Then run sudo apt-get update && sudo apt-get install juju to update the package cache and install juju packages from the added repo as shown below.

cyberithub@ubuntu:~$ sudo apt-get update && sudo apt-get install juju
Hit:1 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:5 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:6 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Get:7 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:8 http://ppa.launchpad.net/juju/stable/ubuntu focal InRelease
Hit:9 https://download.sublimetext.com apt/stable/ InRelease
Hit:10 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Hit:11 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease
Fetched 222 kB in 2s (97.8 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libapache-pom-java libcmis-0.5-5v5 libcommons-logging-java libcommons-parent-java libgpgmepp6 libjuh-java libjurt-java libmwaw-0.3-3 libneon27-gnutls
liborcus-0.15-0 libreoffice-style-tango libridl-java libunoil-java libwps-0.4-4 libxmlsec1-nss
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
juju-2.0 lxd
Suggested packages:
juju-core
The following NEW packages will be installed:
juju juju-2.0 lxd
0 upgraded, 3 newly installed, 0 to remove and 2 not upgraded.
Need to get 59.7 MB of archives.
After this operation, 327 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
................................................................

Once the required Juju and other dependencies are installed, it is now time to install Mojo by first adding the PPA repo by using sudo add-apt-repository ppa:mojo-maintainers/ppa command as shown below.

cyberithub@ubuntu:~$ sudo add-apt-repository ppa:mojo-maintainers/ppa

More info: https://launchpad.net/~mojo-maintainers/+archive/ubuntu/ppa
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:6 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:8 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease [18.0 kB]
Hit:9 https://download.sublimetext.com apt/stable/ InRelease
Get:10 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:11 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal/main amd64 Packages [1,940 B]
Get:12 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal/main i386 Packages [1,936 B]
Get:13 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal/main Translation-en [800 B]
Fetched 359 kB in 4s (95.2 kB/s)
Reading package lists... Done

After adding PPA repo, you need to run sudo apt update command to update the package cache about newly added repo.

cyberithub@ubuntu:~$ sudo apt update
Hit:1 https://dl.winehq.org/wine-builds/ubuntu focal InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:4 http://ppa.launchpad.net/flatpak/stable/ubuntu focal InRelease
Hit:5 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:6 http://ppa.launchpad.net/libreoffice/ppa/ubuntu focal InRelease
Hit:7 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:8 https://download.sublimetext.com apt/stable/ InRelease
Get:9 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:10 http://ppa.launchpad.net/mojo-maintainers/ppa/ubuntu focal InRelease
Fetched 222 kB in 3s (83.8 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.

Finally install Mojo package by using sudo apt install mojo command as shown below. This will download and install the package along with all its dependencies.

cyberithub@ubuntu:~$ sudo apt install mojo
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
brz bzr cloud-image-utils debootstrap ibverbs-providers libaio1 libibverbs1 libiscsi7 liblxc-common liblxc1 libpam-cgfs librados2 librbd1 librdmacm1 lxc
lxc-templates lxc-utils lxcfs python-babel-localedata python3-argcomplete python3-babel python3-breezy python3-codetree python3-configobj
python3-deprecated python3-dulwich python3-fastimport python3-github python3-gitlab python3-gpg python3-jinja2 python3-juju-deployer python3-jujuclient
python3-openssl python3-pbr python3-pylxd python3-requests-toolbelt python3-setuptools python3-websocket python3-wrapt python3-ws4py qemu-block-extra
qemu-utils sharutils uidmap
Suggested packages:
brz-doc python3-breezy.tests arch-test squid-deb-proxy-client qemu-user-static btrfs-tools lvm2 lxctl python3-breezy-dbg python3-kerberos
python-configobj-doc python-gitlab-doc python-jinja2-doc python-openssl-doc python3-openssl-dbg python-setuptools-doc python3-cherrypy3 | python3-tornado
python-ws4py-doc sharutils-doc bsd-mailx | mailx
The following NEW packages will be installed:
brz bzr cloud-image-utils debootstrap ibverbs-providers libaio1 libibverbs1 libiscsi7 liblxc-common liblxc1 libpam-cgfs librados2 librbd1 librdmacm1 lxc
lxc-templates lxc-utils lxcfs mojo python-babel-localedata python3-argcomplete python3-babel python3-breezy python3-codetree python3-configobj
python3-deprecated python3-dulwich python3-fastimport python3-github python3-gitlab python3-gpg python3-jinja2 python3-juju-deployer python3-jujuclient
python3-openssl python3-pbr python3-pylxd python3-requests-toolbelt python3-setuptools python3-websocket python3-wrapt python3-ws4py qemu-block-extra
qemu-utils sharutils uidmap
0 upgraded, 46 newly installed, 0 to remove and 2 not upgraded.
Need to get 17.5 MB of archives.
After this operation, 99.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
.............................................................

 

Step 4: Check Version

After successful installation, you can check the installed version by using mojo --version command as shown below.

cyberithub@ubuntu:~$ mojo --version
1.0.0

 

Step 5: Add a Model

If you have a controller registered then in the next step, you can add a model say example-model by using juju add-model example-model command as shown below.

cyberithub@ubuntu:~$ juju add-model example-model
Added 'example-model' model on localhost/localhost with credential 'localhost' for user 'admin'

 

Step 6: Export variables

Then to save some future typing, you can export below variables to further simplify the steps.

cyberithub@ubuntu:~$ export MOJO_SERIES=trusty
cyberithub@ubuntu:~$ export MOJO_PROJECT=mojo-example-project
cyberithub@ubuntu:~$ export MOJO_WORKSPACE=$MOJO_PROJECT
cyberithub@ubuntu:~$ export MOJO_SPEC="git+lp:~mojo-maintainers/mojo/+git/mojo-specs"
cyberithub@ubuntu:~$ export MOJO_STAGE=mojo-stage/devel

 

Step 7: Create a Project

In the next step, you can create a $MOJO_PROJECT by using mojo project-new -c containerless $MOJO_PROJECT command as shown below.

cyberithub@ubuntu:~$ mojo project-new -c containerless $MOJO_PROJECT
2023-05-14 14:41:48 [INFO] Checking mojo-example-project project path at /home/cyberithub/.local/share/mojo/mojo-example-project ...
2023-05-14 14:41:48 [INFO] Containerless project has no container config
2023-05-14 14:41:48 [INFO] Checking mojo-example-project project container at /home/cyberithub/.local/share/mojo/mojo-example-project/trusty ...
2023-05-14 14:41:48 [INFO] Checking mojo-example-project project container is setup ...

 

Step 8: Create a Workspace

Then you need to create a workspace using mojo workspace-new $MOJO_SPEC $MOJO_WORKSPACE command as shown below.

cyberithub@ubuntu:~$ mojo workspace-new $MOJO_SPEC $MOJO_WORKSPACE
2023-05-14 14:41:48 [INFO] Checking mojo-example-project project path at /home/cyberithub/.local/share/mojo/mojo-example-project ...
2023-05-14 14:41:48 [INFO] Containerless project has no container config
2023-05-14 14:41:48 [INFO] Checking mojo-example-project project container at /home/cyberithub/.local/share/mojo/mojo-example-project/trusty ...
2023-05-14 14:41:48 [INFO] Checking mojo-example-project project container is setup ...
cyberithub@ubuntu:~$ mojo workspace-new $MOJO_SPEC $MOJO_WORKSPACE
2023-05-14 14:42:35 [INFO] Using pre-existing container (class=containerless, root=/home/cyberithub/.local/share/mojo/mojo-example-project/trusty)
2023-05-14 14:42:35 [INFO] Cloning repository at /home/cyberithub/.local/share/mojo/mojo-example-project/trusty/mojo-example-project/spec from ssh://git.launchpad.net/~mojo-maintainers/mojo/+git/mojo-specs
The authenticity of host 'git.launchpad.net (185.125.188.44)' can't be established.
RSA key fingerprint is SHA256:UNOzlP66WpDuEo34Wgs8mewypV0UzqHLsIFoqwe8dYo.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
.......................................................

2023-05-14 14:42:42 [INFO] Workspace created.

 

Step 9: Run Your Mojo Spec

Now you are ready to run Mojo Spec using mojo run command to configure your environment as specified in the mojo specification.

cyberithub@ubuntu:~$ mojo run
2023-05-14 14:43:44 [INFO] Using pre-existing container (class=containerless, root=/home/cyberithub/.local/share/mojo/mojo-example-project/trusty)
2023-05-14 14:43:44 [INFO] Cloning repository at /home/cyberithub/.local/share/mojo/mojo-example-project/trusty/mojo-example-project/spec from ssh://git.launchpad.net/~mojo-maintainers/mojo/+git/mojo-specs
........................................

 

Step 10: Check Status

Once the mojo run completes, you will have a fully deployed juju model with a machine running the website. You can check the deployment status by using juju status command as shown below. You can also verify the deployment by loading your machine ip in the browser.

cyberithub@ubuntu:~$ juju status

 

Step 11: Destroy Project

Once everything is deployed and tested, you can destroy the project by using mojo project-destroy $MOJO_PROJECT command as shown below.

cyberithub@ubuntu:~$ mojo project-destroy $MOJO_PROJECT
2023-05-14 14:50:15 [INFO] Using pre-existing container (class=containerless, root=/home/cyberithub/.local/share/mojo/mojo-example-project/trusty)
2023-05-14 14:50:15 [INFO] Using pre-existing container (class=containerless, root=/home/cyberithub/.local/share/mojo/mojo-example-project/trusty)
2023-05-14 14:50:15 [INFO] Destroying project: mojo-example-project, series: trusty
2023-05-14 14:50:15 [INFO] Using no container. Not destroying a container
2023-05-14 14:50:15 [INFO] Destroying project root: /home/cyberithub/.local/share/mojo/mojo-example-project

 

Step 12: Destroy Model

Then finally you can destroy the model by using juju destroy-model example-model command as shown below.

cyberithub@ubuntu:~$ juju destroy-model example-model
WARNING! This command will destroy the "example-model" model.
This includes all machines, applications, data and other resources.

Continue [y/N]? y
Destroying model
Waiting for model to be removed.....
Model destroyed.

 

Step 13: Uninstall Mojo

Once you are done with Mojo, you can choose to uninstall it from your system by using any of the below method depending on how you installed it.

a) Using Snap

If you installed the tool as snap package then to remove, you need to run sudo snap remove mojo command as shown below.

cyberithub@ubuntu:~$ sudo snap remove mojo
[sudo] password for cyberithub:
mojo removed

b) Using Apt

If you installed mojo from PPA repository then for removal, you need to run sudo apt remove mojo command as shown below.

cyberithub@ubuntu:~$ sudo apt remove mojo
[sudo] password for cyberithub:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
cloud-image-utils ibverbs-providers libaio1 libibverbs1 libiscsi7 liblxc-common liblxc1 libpam-cgfs librados2 librbd1 librdmacm1 lxc lxc-templates
lxc-utils lxcfs python-babel-localedata python3-argcomplete python3-babel python3-codetree python3-jinja2 python3-juju-deployer python3-jujuclient
python3-pbr python3-pylxd python3-requests-toolbelt python3-websocket python3-ws4py qemu-block-extra qemu-utils uidmap
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
mojo
0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
After this operation, 750 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 219109 files and directories currently installed.)
Removing mojo (1.0.0-3~bzr599~ubuntu20.04.1) ...
userdel: mojo mail spool (/var/mail/mojo) not found
groupdel: group 'mojo' does not exist
Not automatically cleaning up: /srv/mojo

Leave a Comment