https://github.com/ansibleguy/sw_odoo_community
Ansible Role to provision Odoo Community
https://github.com/ansibleguy/sw_odoo_community
Last synced: 3 months ago
JSON representation
Ansible Role to provision Odoo Community
- Host: GitHub
- URL: https://github.com/ansibleguy/sw_odoo_community
- Owner: ansibleguy
- License: other
- Created: 2024-08-05T16:45:14.000Z (11 months ago)
- Default Branch: latest
- Last Pushed: 2025-02-15T13:14:35.000Z (4 months ago)
- Last Synced: 2025-04-05T14:07:18.403Z (3 months ago)
- Language: Jinja
- Homepage:
- Size: 180 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# Ansible Role - Provision Odoo Community
Role to deploy [Odoo Community-Edition](https://www.odoo.com/documentation/17.0/administration/on_premise.html)
This role will work to install a self-hosted enterprise-edition installation - but will not completely automate it, as you need a custom setup-binary for it.
[](https://github.com/ansibleguy/sw_odoo_community/actions/workflows/lint.yml)
**Molecule Integration-Tests**:
* Status: [](https://github.com/ansibleguy/_meta_cicd/blob/latest/templates/usr/local/bin/cicd/molecule.sh.j2) |
[](https://github.com/ansibleguy/sw_odoo_community/actions/workflows/integration_test_result.yml)
* Logs: [API](https://ci.ansibleguy.net/api/job/ansible-test-molecule-sw_odoo_community/logs?token=2b7bba30-9a37-4b57-be8a-99e23016ce70&lines=1000) | [Short](https://badges.ansibleguy.net/log/molecule_sw_odoo_community_test_short.log) | [Full](https://badges.ansibleguy.net/log/molecule_sw_odoo_community_test.log)Internal CI: [Tester Role](https://github.com/ansibleguy/_meta_cicd) | [Jobs API](https://github.com/O-X-L/github-self-hosted-jobs-systemd)
**Tested:**
* Debian 12----
## Install
```bash
# latest
ansible-galaxy role install git+https://github.com/ansibleguy/sw_odoo_community# from galaxy
ansible-galaxy install ansibleguy.sw_odoo_community# or to custom role-path
ansible-galaxy install ansibleguy.sw_odoo_community --roles-path ./roles# install dependencies
ansible-galaxy install -r requirements.yml
```----
## Usage
### Config
```yaml
odoo:
hostnames: 'erp.template.ansibleguy.net'
admin_pwd: !vault |
...db:
pwd: !vault |
...
```You might want to use 'ansible-vault' to encrypt your passwords:
```bash
ansible-vault encrypt_string
```### Execution
Run the playbook:
```bash
ansible-playbook -K -D -i inventory/hosts.yml playbook.yml
```There are also some useful **tags** available:
* webserverTo debug errors - you can set the 'debug' variable at runtime:
```bash
ansible-playbook -K -D -i inventory/hosts.yml playbook.yml -e debug=yes
```----
## Functionality
* **Package installation**
* Ansible dependencies (_minimal_)* **Configuration**
* **Default config**:
* Auto-generated passwords
* Addons directory: `/var/lib/odoo/addons`
* **Default opt-ins**:
* Install postgresql database
* Install nginx webserver
* Daily Database-Backup job----
## Info
**Odoo Documentation**: [Odoo Documentation](https://docs.oxl.at/software/odoo.html)
* **Note:** this role currently only supports debian-based systems
* **Note:** Most of the role's functionality can be opted in or out.
For all available options - see the default-config located in [the main defaults-file](https://github.com/ansibleguy/sw_odoo_community/blob/latest/defaults/main/1_main.yml)!
* **Warning:** Not every setting/variable you provide will be checked for validity. Bad config might break the role!
* **Warning:** Make sure to only allow Port 80/443 to the server as odoo will listen on 8069 and optionally 8072!
* **Note:** You might want to [block login-failure using Fail2Ban](https://www.odoo.com/documentation/17.0/administration/on_premise/deploy.html#blocking-brute-force-attacks)
* **Note:** The `Master password` on the setup-screen is the `admin_pwd` set by this role. It is saved in the `/etc/odoo/odoo.conf` file.
* **Tip:** You can enhance your Odoo-community functionality using community apps. You especially might want to check out the ones provided by the [Odoo Community Association](https://github.com/OCA?q=&type=all&language=&sort=stargazers)
To install 3th-party apps you have to:
* Select your Odoo-Version and Download its ZIP
![]()
* Move the ZIP to your server and place it inside the addons-directory (`/var/lib/odoo/addons` by default in this setup)* Unzip it: `cd /var/lib/odoo/addons && unzip project-17.0.zip`
* Move the modules you want/need: `mv project-17.0/project_* /var/lib/odoo/addons/`
* Clean-up: `rm -r /var/lib/odoo/addons/project-17.0/`
* Restart odoo: `systemctl restart odoo.service`
* **Note:** If you want to change to the **enterprise-edition** you will have to set `odoo.enterprise: true` so the community repository will get removed.
Docs: [odoo Docs](https://www.odoo.com/documentation/17.0/administration/on_premise/community_to_enterprise.html#on-linux-using-an-installer)
You have to:
* Install the community-edition first
* Stop the service: `systemctl stop odoo.service`
* Download the enterprise binary `.deb` and install it as root: `dpkg -i odoo_17.0+e.latest_all.deb`NOTE: Migrating from enterprise back to community edition is not easy!
* **Tip:** You can reset your admin-user password like this:
```bash
# generate hash
export MYPWD='MY_PASSWORD'
python3 -c "from os import environ; from passlib.context import CryptContext; print(CryptContext(['pbkdf2_sha512']).hash(environ['MYPWD']))"
# update hash in DB
su --login postgres
psql
\c odoo
# check we have the correct account
SELECT login, password FROM res_users WHERE id=2;
# update it (change HASH to the value you got by running the 'python3' command above)
UPDATE res_users SET password='HASH' WHERE id=2;
```* **Note:** You can restore the database from a dump like this:
```bash
su --login postgres
# make sure to backup your current state
pg_dumpall | xz > "./odoo_$(date '+%Y-%m-%d_%H-%M').sql.xz"# restore
xzcat odoo_.sql.xz | psql -d odoo
```You can also manage your databases from this URL: `https:///web/database/manager`
Also note that the Odoo online setups might use newer versions than you can use on-premise. So you might need to contact the support on how to migrate the database.
* **Note:** The file backups are created from `/var/lib/odoo/` - this contains data like the `filestore`
* **Note:** If you want to limit outbound connections you might need to allow HTTP+S connections to these:
```
nightly.odoo.com
apps.odoo.com
partner-autocomplete.odoo.com
www.odoo.com
```* **Note:** For PDF generation and printing to work - you will have to install [wkhtmltopdf](https://github.com/wkhtmltopdf/packaging/releases)
You may want to check the log file if any errors occur: `tail -f /var/log/odoo/odoo-server.log`
You may also need to add the system parameter: `report.url=http://127.0.0.1:8069` (wkhtmltopdf `UnknownNetworkError`)
Also add your Odoo FQDN to your `/etc/hosts` and redirect it to `127.0.0.1` instead of using actual public IPs (*if you are behind proxies*)
You can test it manually: `wkhtmltopdf https:///web/login /tmp/test1.pdf` and `wkhtmltopdf http://127.0.0.1:8069/web/login /tmp/test2.pdf`