Hyper Open Edge Cloud

How To Create a Matomo Instance Configuration File

How To Create a Matomo Instance Configuration File
  • Last Update:2022-05-09
  • Version:001
  • Language:en


  1. Add a new download-base section 
  2. Create a new file "matomo-instance.cfg"
  3. Create a new file "buildout.hash.cfg"
  4. Add a new section "custom-application-deployment"
  5. Verification

This tutorial will teach you how to add a matomo instance configuration file.


Add a new section to be extended by other donwload section

Since we may need to add multiple files later, we add a section here as the Download Base. Later when we need to add a new file, we could extend this section to avoid duplicate code.
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:filename}

Create a new template file "matomo-instance.cfg.in"

Create a new file "matomo-instance.cfg.in"
The file we created here is just a template, which means it's not the real output configuration file in instance. The real output configuration file will be created according to the content of this template file. To generate the real configuration file, we need to add some content in file software.cfg to tell slapos the information about the file we want to create, like the output file location, the output file name...
So edit file "software.cfg", add a new section about the instance of matomo
The variable template is the configuration template file we created before, and the variable rendered is where we want to put it in our instance. context is some parameters that will be passed to the template file.  
On the other hand, we need to register it in part of section buildout to make sure the instance configuration file will be created. So add a new line template-matomo-instance in it.

parts =
# to create file instance-matomo.cfg in instance of apache-php
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/${:filename}
rendered = ${buildout:directory}/instance-matomo.cfg
extensions = jinja2.ext.do
context =
    key gzip_location gzip:location
    key python3_location python3:location

Create a new file "buildout.hash.cfg"

Create a new file buildout.hash.cfg
To verify the correctness of the file content, we generally need to check the MD5sum code of it. To make this step more easy, we can add a new file named buildout.hash.cfg. If we register the section name and the file name we added to this file, it will help us to update the md5sum code automatically.
Besides, in file software.cfg, add a new line buildout.hash.cfg in extends of section buildout to make the auto-update function work.
In file buildout.hash.cfg, we register the name of template file we added and reserve a position for the md5sum code of corresponding file.
# THIS IS NOT A BUILDOUT FILE, despite purposedly using a compatible syntax.
# The only allowed lines here are (regexes):
# - "^#" comments, copied verbatim
# - "^[" section beginings, copied verbatim
# - lines containing an "=" sign which must fit in the following categorie.
#   - "^\s*filename\s*=\s*path\s*$" where "path" is relative to this file
#     Copied verbatim.
#   - "^\s*hashtype\s*=.*" where "hashtype" is one of the values supported
#     by the re-generation script.
#     Re-generated.
# - other lines are copied verbatim
# Substitution (${...:...}), extension ([buildout] extends = ...) and
# section inheritance (< = ...) are NOT supported (but you should really
# not need these here).

filename = matomo-instance.cfg.in
md5sum =

Checking automatic updates of code

Open a new terminal and run the following command in it:

cd ~/srv/project/slapos/software/matomo

And you will find the md5sum code in file "buildout.hash.cfg" update automatically

Check output instance file 

Run the following command at the terminal to rebuild:

cd ~/srv/project/slapos/software/matomo
slapos node software --all
slapos node instance --all

And when you try to create your instance by command "slapos node instance --all", there will be some errors, which is normal because there are many things we haven't configured. So now just check if there exist a file named instance-matomo.cfg in directory "~/srv/projet/slapos/runner/software/matomo-instance.cfg".

You can use linux command find to check if output file exist:
find ~/srv/project/runner/instance/ -name matomo.conf
Normally, you will get the result like this: