Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coopdevs/odoo-role
Ansible role provisioning Odoo.
https://github.com/coopdevs/odoo-role
ansible ansible-role odoo
Last synced: 6 days ago
JSON representation
Ansible role provisioning Odoo.
- Host: GitHub
- URL: https://github.com/coopdevs/odoo-role
- Owner: coopdevs
- License: gpl-3.0
- Created: 2018-04-04T18:25:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-14T10:35:10.000Z (5 months ago)
- Last Synced: 2024-06-14T22:15:48.349Z (5 months ago)
- Topics: ansible, ansible-role, odoo
- Language: Shell
- Size: 221 KB
- Stars: 12
- Watchers: 10
- Forks: 20
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
An Odoo Ansible Provisioning Role
=========================================This an Ansible role for provisioning Odoo. It supports:
* Odoo 12
* Odoo 11
* Odoo 10I has not been tested yet with Odoo 13.
Requirements
------------A PostgreSQL(9.5+).
By now this role only supports peer authentication for PostgreSQL database access.
So you need to create a database in PostgreSQL, one user with access to that database, and one system user with same username.
For instance, you can create an `odoo` user in PostgreSQL with access to the created database, and an user named `odoo` in your system.
Role Variables
--------------Available variables are listed below, along with default values:
* Edition
This role supports installing Odoo following two different strategies: `git` (from a git repository) and `tar` (a package or compressed release file).
```yml
# Odoo releases download strategy: tar or git
odoo_role_download_strategy: tar# Vars for tar download strategy
# supported any other formats supported by ansible unarchive, i.e. by unzip or gtar)
# Releases from Odoo.com odoo nightly
odoo_role_odoo_version: 11.0 # not used outside this file
odoo_role_odoo_release: 20190505 # not used outside this file
odoo_role_odoo_url: "https://nightly.odoo.com/{{ odoo_role_odoo_version }}/nightly/src/odoo_{{ odoo_role_odoo_version }}.{{ odoo_role_odoo_release }}.tar.gz"
# Releases from an Odoo comunity backports updated fork
# odoo_role_odoo_release: "11.0_2019-05-05"
# odoo_role_odoo_url: "https://gitlab.com/coopdevs/OCB/-/archive/{{ odoo_role_odoo_release }}/OCB-{{ odoo_role_odoo_release }}.tar.gz"
odoo_role_odoo_download_path: "{{ odoo_role_odoo_path }}/../odoo_releases/odoo_{{ odoo_role_odoo_version }}.{{ odoo_role_odoo_release }}.tar.gz"# Vars for git download strategy
odoo_role_odoo_git_url: "https://github.com/OCA/OCB.git"
# OCA's OCB, branch 11.0. LTS probably until 14.0 release. 13.0 is scheduled for October 2019.
odoo_role_odoo_git_ref: "11.0"
# Variable to define pip version
odoo_role_pip_version: "23.1.2"# Variable for force reinstall existing python version in pyenv. When set to false, the role will not reinstall the python version (using `--skip-existing` flag).
odoo_role_force_pyenv_version: false
```* Users and group
```yml
odoo_role_odoo_user: odoo
odoo_role_odoo_group: odoo
```* Directories structure
```yml
odoo_role_odoo_venv_path: /opt/.odoo_venv
odoo_role_odoo_path: /opt/odoo
odoo_role_odoo_bin_path: "{{ odoo_role_odoo_path }}/build/scripts-2.7/odoo"
odoo_role_odoo_python_path: "{{ odoo_venv_path }}/bin/python"
odoo_role_odoo_config_path: /etc/odoo
odoo_role_odoo_log_path: /var/log/odoo
odoo_role_odoo_modules_path: /opt/odoo/modules
```* Databases
```yml
# Array of DBs that the role will create.
odoo_role_odoo_dbs: [ "odoo" ]
# In a multidb environment, where more than one group use the same instance with isolated views,
# each db name must match the DNS name it will accessed from in order for Odoo to direct the queries to the right DB.
odoo_role_odoo_dbs: [ "odoo.some.coop", "erp.another.org" ]
# Only in multidb environment, select DB based on the HTTP Host header.
odoo_role_dbfilter_enabled: true
# This is the password Odoo asks to user allow them to create, delete, etc. DBs
odoo_role_odoo_db_admin_password: 1234
# Whether to populate db with example data or not.
odoo_role_demo_data: false
# Give the chance to select a database before login (when dbfilter disabled), and enable db manager web interface
odoo_role_list_db: false
```* Odoo HTTP server settings
```yml
# Set this to 127.0.0.1 when Odoo runs behind a reverse proxy
odoo_role_odoo_http_interface: 0.0.0.0
# Set this to true when Odoo runs behind a reverse proxy
odoo_role_odoo_proxy_mode: false
# Specify how many HTTP workers you need (default is 1)
odoo_role_workers: 2
```* Odoo other server settings
```yml
# Customize the Odoo timeouts
odoo_role_limit_time_cpu: 60
odoo_role_limit_time_real: 120# Customize the Odoo memory limits
odoo_role_limit_memory_hard: 2684354560
odoo_role_limit_memory_soft: 2147483648
```* Core modules list to install/update
```yml
# List of modules to install before running the server. "Shared" part is common to all db's, specific db modules goes into their "db" part
odoo_role_odoo_core_modules_dict:
shared:
- base
db1:
- account
```* Community modules list to install/update
```yml
# List of modules to install before running the server. "Shared" part is common to all db's, specific db modules goes into their "db" partodoo_role_odoo_community_modules_dict:
shared:
- web_responsive
db1:
- mis_reports
```* Force update odoo modules
In order to force update an odoo module or a list of modules execute provisioning with the command```
-e "odoo_role_modules_force_update=['l10n_es']"
```* Development mode
Odoo has a mode to auto-reload the server when the code changes and read the views from the code to agile the development process. Using the command line parameter [`--dev`](https://www.odoo.com/documentation/12.0/reference/cmdline.html#developer-features) we can run Odoo in a development mode.
```yaml
odoo_role_dev_mode: true
```If this mode is active, the systemd unit is not created and you need to run the Odoo process manually.
You can start it with the following command:```sh
./odoo-bin -c /etc/odoo/odoo.conf --dev all
```* [Rest Framework](https://github.com/OCA/rest-framework/tree/12.0/base_rest) support
If you need to use the Rest Framework and want to start the server in development mode, use:
```yaml
odoo_role_enable_rest_framework: true
```This option add to the Odoo configuration file the section and option to development mode:
* [Queue Job](https://github.com/OCA/queue/blob/12.0/queue_job) support
If you need to use the module [queue\_job](https://github.com/OCA/queue/blob/12.0/queue_job), use:
```yaml
odoo_role_enable_queue_job: true
```This option add to the Odoo configuration file the option to enable queue\_job as a new thread/process:
* Server-wide modules
If you need to install some wide-server modules apart from `db_filter` and `queue_job`, use:
```yaml
odoo_role_odoo_server_wide_modules: ['module1', 'module2']
```By default, it configures as a server-wide modules `web` and `base` -as long as they are mandatory from Odoo v12- in every case and `db_filter` and `queue_job` if the corresponding variables are set to `true` .
* Workers configuration
You can also define how many workers you want to use to execute the jobs:
```yaml
odoo_role_channels: root:2
```* [sentry](https://github.com/OCA/server-tools/tree/12.0/sentry) support
If you want to use the module [setnry](https://github.com/OCA/server-tools/tree/12.0/sentry), use:
```yaml
odoo_role_enable_sentry: true
odoo_role_sentry_dsn: https://your_sentry_url
```* i18n Overwrite
We can force the i18n overwrite using the next variable:
```yaml
odoo_role_i18n_overwrite: true
```You can define this var in the inventory or use it when execute a playbook:
```bash
ansible-playbook playbooks/provision.yml -i ../my-inventory/inventory/hosts --ask-vault-pass --limit=host -e "{odoo_role_i18n_overwrite: true}"
```* Environment variables
If you need to define a set of environment variables for your server, you can use the `environment_variables` dict var:
```yaml
environment_variables:
var_name1: "var_value1"
var_name2: "var_value2"
var_name3: "var_value3"
```This option add a file in `/etc/default/odoo` with the vars and add to the Systemd service the `EnvironmentFile` attribute pointing to `/etc/default/odoo.
Role Tags
---------------* Using the `only-modules` Tag
This tag helps you install or update Odoo modules without performing a full setup. Run the playbook with the `--tags` option:
```bash
ansible-playbook playbook.yml --tags "only-modules"
```Developer aids
---------------* A [template](/templates/00-aliases.sh) with [`ct`](https://xardin.netlify.app/sys-admin/color-tail-output-in-odoo-logs/) alias is rendered to `/etc/profile.d/`.
* Add [`odoo-backup`](https://janikvonrotz.ch/2020/04/02/automate-odoo-backups-with-this-script/) and [`odoo-restore`](https://janikvonrotz.ch/2020/05/19/restore-odoo-database-with-this-script/) scripts.You can skip this by setting the `odoo_role_dev_helpers` var to `false`.
```yaml
odoo_role_dev_helpers: true
```x
Community Roles
---------------#### Deploy
To use community roles, you need to deploy this modules in the server. This role manage the modules deployment with `pip`.
You can define a `requirements.txt` file to manage the modules and ensure the version installed:
```
# requirements.txt
odoo11-addon-contract==11.0.2.1.0
odoo11-addon-contract-sale-invoicing==11.0.1.0.0
odoo11-addon-contract-variable-qty-timesheet==11.0.1.0.0
odoo11-addon-contract-variable-quantity==11.0.1.2.1
```> The default `requirements.txt` file path is `"{{ inventory_dir }}/../files/requirements.txt"`.
>
> You can change it with the `odoo_role_community_modules_requirements_path` var.
>
> This allows you to have different `requirements.txt` files and use them on a conditional way.
>
> For example, you could set it `{{ inventory_dir }}/../files/requirements-dev.txt`
> and use it for dev envs redefining the variable at `host_vars` level.# Install
Once the modules are in the server, you need to install them in the database.
Define a `odoo_role_odoo_community_modules` var with the list of the modules names you want to install.
```yml
# inventory/group_vars/all.yml
odoo_role_odoo_community_modules: 'contract,contract_sale_invoicing'
```Dependencies
------------This role is not depending on other roles (yet).
Example Playbook
----------------```yaml
- hosts: odoo_servers
roles:
- role: coopdevs.odoo-role
vars:
odoo_role_odoo_db_name: odoo-db
odoo_role_odoo_db_admin_password: "{{ odoo_admin_password }}"
odoo_role_download_strategy: tar
odoo_role_odoo_version: 11.0
odoo_role_odoo_release: 20180424
```Developing & Testing
-------For developing and testing the role, we use [`devenv`](https://github.com/coopdevs/devenv) to manage local virtual machines in Linux environments.
You can use the `.devenv` file in `tests` folder to create a virtual machine.
```bash
devenv
```Then, you can test the role with the following command:
```bash
ansible-playbook devenv.yml -i inventory
```It will provision a virtual machine with postgresql and then, execute the role.
Release
-------To publish a new release:
* Go to [releases](https://github.com/coopdevs/odoo-role/releases) and click on `Draft a new release`.
* Create a new tag on `Choose a tag` and update the description with the changelog, as the example below:```
## What's Changed
* feat: invert add-ons paths order by @oyale in https://github.com/coopdevs/odoo-role/pull/135
* Add pytest and coverage packages to dev environments by @oyale in https://github.com/coopdevs/odoo-role/pull/136**Full Changelog**: https://github.com/coopdevs/odoo-role/compare/v0.3.4...v0.3.5
```* After publishing the release go to [`ansible galaxy`](https://galaxy.ansible.com/) to import the new release. You should find the odoo-role repository under `My content`.
License
-------GPLv3
Author Information
------------------@ygneo