This is the systems part of welcoming a new organization to a multi-db odoo. For them to have “their own Odoo”, we will add a new database to the Ansible inventory of the multi-db Odoo instance that will host them.
In inventory/group_vars/all.yml
:
Configure Domain-to-Database Mapping: Under nginx_configs
, add a mapping for the new domain to the respective database.
nginx_configs:
# Existing domain mappings...
'example.newdomain.com' example_db_name;
# Other domain mappings...
This configuration routes requests for ‘example.newdomain.com’ to the example_db_name
database.
Continue in inventory/group_vars/all.yml
:
Specify Modules for New Database: In odoo_role_odoo_community_modules_dict
, add an entry for the new database. List the required modules.
odoo_role_odoo_community_modules_dict:
example_db_name:
- module1
- module2
In inventory/host_vars/<domain>/config.yml
:
Add Database to Odoo Role: Include the new database name in the odoo_role_odoo_dbs
list.
odoo_role_odoo_dbs:
- example_db_name
Domain Configuration: Add the new database’s domain to the domains
list.
domains:
- example.newdomain.com
The following sections are adapted from the Merge Request template to add a new DB at processos.org
For each database change, please do:
odoo_role_odoo_dbs
domains
odoo_role_odoo_community_modules_dict
.nginx_configs
.Don’t modify this one, it’s only informative
environment | host_vars file to modify |
domain name | root domain |
---|---|---|---|
trial | inventory/host_vars/proves.processos.org/config.yml |
example.proves.processos.org |
proves.processos.org |
prod | inventory/host_vars/processos.org/config.yml |
example.processos.org |
processos.org |
odoo-provisioning
with this inventory against trial and/or prod servers.There are 2 ways to inform odoo about the multiple dbs/instances. Method 1 only supports one word per subdomain. Method 2 can compound multiple words (i.e. test.erp.example.org).
Every DB needs to be named after the subdomain name in order for odoo to map it correctly.
e.g. prod.example.org (DB name should be prod)
test.example.org (DB name should be test)
In the config file located on odoo-example-inventory/inventory/host_vars/prod.example.org/config.yml set the variable odoo_role_enable_dbfilter_from_header: true
.
In the nginx configuration located on odoo-example-inventory/inventory/group_vars/all.yml map each domain with the equivalent DB. In this case it is not necessary the DB name to match the subdomain name.
nginx_configs:
upstream:
- |
map $http_host $odoo_dbfilter {
'prod.example.org' odoo;
'test.example.org' test;
}
upstream odoo { server 127.0.0.1:8069; }